Skip to content

Commit 5b7db8f

Browse files
author
Luke Pickering
committed
adds optional proxy python binding generation
1 parent 1f74f5e commit 5b7db8f

3 files changed

Lines changed: 48 additions & 13 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ list(GET VERSION_LIST 2 duneanaobj_VERSION_PATCH)
99

1010
LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake/Modules)
1111

12+
option(duneanaobj_PYTHON_ENABLED "Whether to build python bindings to proxy classes." OFF)
13+
1214
include(CPM)
1315

1416
SET(SRProxy_MIN_VERSION 0.46.0)

duneanaobj/StandardRecord/CMakeLists.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
execute_process(COMMAND git rev-parse --short=8 HEAD
2-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../..
2+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../..
33
OUTPUT_VARIABLE duneanaobj_GITSHORTHASH8
44
RESULT_VARIABLE GIT_CMD_SUCCESS
55
OUTPUT_STRIP_TRAILING_WHITESPACE)
@@ -74,19 +74,19 @@ SET(SR_HEADER_FILES
7474
)
7575

7676
add_library(duneanaobj_StandardRecord SHARED ${SR_IMPL_FILES})
77-
target_link_libraries(duneanaobj_StandardRecord PUBLIC ROOT::MathCore)
78-
target_include_directories(duneanaobj_StandardRecord PUBLIC
79-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..>
77+
target_link_libraries(duneanaobj_StandardRecord PUBLIC ROOT::Physics ROOT::MathCore)
78+
target_include_directories(duneanaobj_StandardRecord PUBLIC
79+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..>
8080
$<INSTALL_INTERFACE:include>)
81-
target_include_directories(duneanaobj_StandardRecord PRIVATE
81+
target_include_directories(duneanaobj_StandardRecord PRIVATE
8282
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> #root puts this in the dictionary
8383
)
8484
set_target_properties(duneanaobj_StandardRecord PROPERTIES EXPORT_NAME StandardRecord)
8585
install(TARGETS duneanaobj_StandardRecord EXPORT duneanaobj_targets DESTINATION lib)
8686
install(FILES ${SR_HEADER_FILES} DESTINATION include/duneanaobj/StandardRecord)
87-
install(FILES
88-
${CMAKE_CURRENT_BINARY_DIR}/libStandardRecordDict_rdict.pcm
89-
${CMAKE_CURRENT_BINARY_DIR}/libStandardRecordDict.rootmap
87+
install(FILES
88+
${CMAKE_CURRENT_BINARY_DIR}/libStandardRecordDict_rdict.pcm
89+
${CMAKE_CURRENT_BINARY_DIR}/libStandardRecordDict.rootmap
9090
DESTINATION lib)
9191

9292
add_library(duneanaobj::StandardRecord ALIAS duneanaobj_StandardRecord)
@@ -99,4 +99,4 @@ foreach(HDR ${SR_HEADER_FILES})
9999
endforeach()
100100

101101
add_subdirectory(Proxy)
102-
add_subdirectory(Flat)
102+
add_subdirectory(Flat)

duneanaobj/StandardRecord/Proxy/CMakeLists.txt

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,51 @@ GenSRProxy(
66
EPILOG_FWD ${CMAKE_CURRENT_SOURCE_DIR}/EpilogFwd.h
77
INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../../.. ${ROOT_INCLUDE_DIRS}
88
DEPENDENCIES ${SR_HEADER_FILE_FQPS}
9+
EMIT_PYTHON_BINDINGS
910
VVERBOSE)
1011

1112
add_library(duneanaobj_StandardRecordProxy SHARED SRProxy.cxx)
12-
target_link_libraries(duneanaobj_StandardRecordProxy PUBLIC SRProxy::BasicTypes)
13-
target_include_directories(duneanaobj_StandardRecordProxy PUBLIC
13+
target_link_libraries(duneanaobj_StandardRecordProxy PUBLIC SRProxy::BasicTypes duneanaobj_StandardRecord)
14+
target_include_directories(duneanaobj_StandardRecordProxy PUBLIC
1415
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../..>
1516
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../../..>
1617
$<INSTALL_INTERFACE:include>)
1718

1819
install(TARGETS duneanaobj_StandardRecordProxy EXPORT duneanaobj_targets DESTINATION lib)
19-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/SRProxy.h
20-
${CMAKE_CURRENT_BINARY_DIR}/FwdDeclare.h
20+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/SRProxy.h
21+
${CMAKE_CURRENT_BINARY_DIR}/FwdDeclare.h
2122
DESTINATION include/duneanaobj/StandardRecord/Proxy)
2223

2324
add_library(duneanaobj::StandardRecordProxy ALIAS duneanaobj_StandardRecordProxy)
25+
26+
if(duneanaobj_PYTHON_ENABLED)
27+
find_package(Python3 REQUIRED COMPONENTS Development Interpreter)
28+
29+
# PYTHON PATHS
30+
set(duneanaobj_PYTHONPATH "python/${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}")
31+
32+
include(FetchContent)
33+
34+
FetchContent_Declare(
35+
pybind11
36+
GIT_REPOSITORY https://github.com/pybind/pybind11.git
37+
GIT_TAG f5fbe86 # release-3.0.1
38+
)
39+
40+
FetchContent_MakeAvailable(pybind11)
41+
42+
pybind11_add_module(pySRProxy SHARED SRProxy.pybind.cxx)
43+
44+
target_include_directories(pySRProxy
45+
PRIVATE
46+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
47+
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src/include>
48+
)
49+
50+
target_link_libraries(pySRProxy
51+
PRIVATE
52+
duneanaobj::StandardRecordProxy)
53+
54+
install(TARGETS pySRProxy
55+
LIBRARY DESTINATION ${duneanaobj_PYTHONPATH})
56+
endif()

0 commit comments

Comments
 (0)