Skip to content

Commit 4f0b63a

Browse files
committed
Add pybind11 modules to CMake
1 parent 57d8e29 commit 4f0b63a

7 files changed

Lines changed: 114 additions & 7 deletions

File tree

com_nvidia_gxf/gxf/core/CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,16 @@ target_link_libraries(core
125125
)
126126
add_library(GXF::core ALIAS core)
127127

128+
#######################################################################################
129+
# Pybind11 extensions
130+
#######################################################################################
131+
132+
pybind11_add_module(core_pybind SHARED "bindings/core.cpp")
133+
target_link_libraries(core_pybind PUBLIC GXF::core)
134+
135+
128136
install(
129-
TARGETS core_c_api;core_internal;core
137+
TARGETS core_c_api;core_internal;core;core_pybind
130138
EXPORT gxfCoreTargets
131139
PUBLIC_HEADER
132140
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gxf/core

com_nvidia_gxf/gxf/cuda/CMakeLists.txt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,26 @@ gxf_core_add_extension_library(
4242
CUDA::cudart
4343
)
4444

45+
#######################################################################################
46+
# Pybind11 extensions
47+
#######################################################################################
48+
49+
pybind11_add_module(cuda_pybind SHARED "bindings/cuda.cpp")
50+
target_link_libraries(cuda_pybind PUBLIC GXF::common GXF::core GXF::std CUDA::cudart)
51+
52+
53+
install(
54+
TARGETS cuda_pybind
55+
EXPORT gxfCoreTargets
56+
PUBLIC_HEADER
57+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gxf/cuda
58+
ARCHIVE
59+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/gxf/cuda
60+
LIBRARY
61+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/gxf/cuda
62+
COMPONENT Core
63+
)
64+
4565
if(BUILD_TESTING)
4666
add_subdirectory(tests)
47-
endif()
67+
endif()

com_nvidia_gxf/gxf/cuda/tests/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ gxf_core_add_extension_library(
2020
PUBLIC_HEADERS test_cuda_helper.hpp
2121
PUBLIC_DEPENDS
2222
CUDA::cublas
23+
GXF::cuda
2324
GXF::common
2425
GXF::core
25-
GXF::cuda
2626
GXF::std
2727
GTest::gtest_main
2828
NO_INSTALL
@@ -35,9 +35,9 @@ gxf_add_gtests(
3535
test_cuda_stream_dotproduct.yaml
3636
test_cuda_unit.yaml
3737
DEPENDS
38+
GXF::cuda
3839
GXF::common
3940
GXF::core
40-
GXF::cuda
4141
GXF::std
4242
GTest::gtest_main
4343
)

com_nvidia_gxf/gxf/multimedia/CMakeLists.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,29 @@ gxf_core_add_extension_library(
2828
GXF::std
2929
)
3030

31+
32+
#######################################################################################
33+
# Pybind11 extensions
34+
#######################################################################################
35+
36+
pybind11_add_module(video_pybind SHARED "bindings/video.cpp")
37+
target_link_libraries(video_pybind PUBLIC GXF::core GXF::std)
38+
39+
pybind11_add_module(camera_pybind SHARED "bindings/camera.cpp")
40+
target_link_libraries(camera_pybind PUBLIC GXF::core GXF::std)
41+
42+
install(
43+
TARGETS video_pybind;camera_pybind
44+
EXPORT gxfCoreTargets
45+
PUBLIC_HEADER
46+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gxf/multimedia
47+
ARCHIVE
48+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/gxf/multimedia
49+
LIBRARY
50+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/gxf/multimedia
51+
COMPONENT Core
52+
)
53+
3154
if(BUILD_TESTING)
3255
add_subdirectory(tests)
3356
endif()

com_nvidia_gxf/gxf/python_codelet/CMakeLists.txt

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,34 @@ gxf_core_add_extension_library(
1818
SOURCES
1919
py_codelet.cpp
2020
python_codelet.cpp
21-
pydata.hpp
2221
PUBLIC_HEADERS
22+
pydata.hpp
2323
py_codelet.hpp
2424
PUBLIC_DEPENDS
2525
GXF::core
2626
GXF::std
2727
pybind11::pybind11
2828
Python3::Python
2929
)
30+
31+
#######################################################################################
32+
# Pybind11 extensions
33+
#######################################################################################
34+
35+
pybind11_add_module(pycodelet SHARED "bindings/pycodelet.cpp")
36+
target_link_libraries(pycodelet PUBLIC GXF::core GXF::std GXF::python_codelet)
37+
38+
pybind11_add_module(pydata_pybind SHARED "bindings/pydata.cpp")
39+
target_link_libraries(pydata_pybind PUBLIC GXF::core GXF::std)
40+
41+
install(
42+
TARGETS pycodelet;pydata_pybind
43+
EXPORT gxfCoreTargets
44+
PUBLIC_HEADER
45+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gxf/multimedia
46+
ARCHIVE
47+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/gxf/multimedia
48+
LIBRARY
49+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/gxf/multimedia
50+
COMPONENT Core
51+
)

com_nvidia_gxf/gxf/python_codelet/py_codelet.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace gxf {
3636

3737
/// C++ side bridge of python codelet. This is the type which all python codelets register.
3838
/// Mandatory params - codelet_name_, codelet_filepath_
39-
class __attribute__((visibility("hidden"))) PyCodeletV0 : public Codelet {
39+
class PyCodeletV0 : public Codelet {
4040
public:
4141
gxf_result_t registerInterface(Registrar* registrar) override;
4242
gxf_result_t start() override;

com_nvidia_gxf/gxf/std/CMakeLists.txt

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,42 @@ target_link_libraries(std
224224
add_library(GXF::std ALIAS std)
225225
set(GXF_EXTENSION_LIBRARY_TARGETS "std;${GXF_EXTENSION_LIBRARY_TARGETS}" PARENT_SCOPE)
226226

227+
#######################################################################################
228+
# Pybind11 extensions
229+
#######################################################################################
230+
231+
pybind11_add_module(vault_pybind SHARED "bindings/vault.cpp")
232+
target_link_libraries(vault_pybind PUBLIC GXF::core GXF::std)
233+
234+
pybind11_add_module(allocator_pybind SHARED "bindings/allocator.cpp")
235+
target_link_libraries(allocator_pybind PUBLIC GXF::core GXF::std)
236+
237+
pybind11_add_module(clock_pybind SHARED "bindings/clock.cpp")
238+
target_link_libraries(clock_pybind PUBLIC GXF::core GXF::std)
239+
240+
pybind11_add_module(receiver_pybind SHARED "bindings/receiver.cpp")
241+
target_link_libraries(receiver_pybind PUBLIC GXF::core GXF::std)
242+
243+
pybind11_add_module(tensor_pybind SHARED "bindings/tensor.cpp")
244+
target_link_libraries(tensor_pybind PUBLIC GXF::core GXF::std)
245+
246+
pybind11_add_module(scheduling_terms_pybind SHARED "bindings/scheduling_terms.cpp")
247+
target_link_libraries(scheduling_terms_pybind PUBLIC GXF::core GXF::std)
248+
249+
pybind11_add_module(timestamp_pybind SHARED "bindings/timestamp.cpp")
250+
target_link_libraries(timestamp_pybind PUBLIC GXF::core GXF::std)
251+
252+
pybind11_add_module(eos_pybind SHARED "bindings/eos.cpp")
253+
target_link_libraries(eos_pybind PUBLIC GXF::core GXF::std)
254+
255+
pybind11_add_module(transmitter_pybind SHARED "bindings/transmitter.cpp")
256+
target_link_libraries(transmitter_pybind PUBLIC GXF::core GXF::std)
257+
258+
pybind11_add_module(scheduling_condition_pybind SHARED "bindings/scheduling_condition.cpp")
259+
target_link_libraries(scheduling_condition_pybind PUBLIC GXF::core GXF::std)
260+
227261
install(
228-
TARGETS std_internal;std
262+
TARGETS std_internal;std;vault_pybind;allocator_pybind;clock_pybind;receiver_pybind;tensor_pybind;scheduling_terms_pybind;timestamp_pybind;eos_pybind;transmitter_pybind;scheduling_condition_pybind
229263
EXPORT gxfCoreTargets
230264
PUBLIC_HEADER
231265
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gxf/std

0 commit comments

Comments
 (0)