From a44708629e1aba6fb2078aee424a9fc58d89c980 Mon Sep 17 00:00:00 2001 From: Damien Nguyen Date: Wed, 22 Jan 2025 10:20:26 +0100 Subject: [PATCH] Add pybind11 modules to CMake --- com_nvidia_gxf/gxf/core/CMakeLists.txt | 10 +++++- com_nvidia_gxf/gxf/cuda/CMakeLists.txt | 22 +++++++++++- com_nvidia_gxf/gxf/cuda/tests/CMakeLists.txt | 4 +-- com_nvidia_gxf/gxf/multimedia/CMakeLists.txt | 23 ++++++++++++ .../gxf/python_codelet/CMakeLists.txt | 24 ++++++++++++- .../gxf/python_codelet/py_codelet.hpp | 2 +- com_nvidia_gxf/gxf/std/CMakeLists.txt | 36 ++++++++++++++++++- 7 files changed, 114 insertions(+), 7 deletions(-) diff --git a/com_nvidia_gxf/gxf/core/CMakeLists.txt b/com_nvidia_gxf/gxf/core/CMakeLists.txt index dabc8a1..4b69ffb 100644 --- a/com_nvidia_gxf/gxf/core/CMakeLists.txt +++ b/com_nvidia_gxf/gxf/core/CMakeLists.txt @@ -125,8 +125,16 @@ target_link_libraries(core ) add_library(GXF::core ALIAS core) +####################################################################################### +# Pybind11 extensions +####################################################################################### + +pybind11_add_module(core_pybind SHARED "bindings/core.cpp") +target_link_libraries(core_pybind PUBLIC GXF::core) + + install( - TARGETS core_c_api;core_internal;core + TARGETS core_c_api;core_internal;core;core_pybind EXPORT gxfCoreTargets PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gxf/core diff --git a/com_nvidia_gxf/gxf/cuda/CMakeLists.txt b/com_nvidia_gxf/gxf/cuda/CMakeLists.txt index aa03936..a3e193a 100644 --- a/com_nvidia_gxf/gxf/cuda/CMakeLists.txt +++ b/com_nvidia_gxf/gxf/cuda/CMakeLists.txt @@ -42,6 +42,26 @@ gxf_core_add_extension_library( CUDA::cudart ) +####################################################################################### +# Pybind11 extensions +####################################################################################### + +pybind11_add_module(cuda_pybind SHARED "bindings/cuda.cpp") +target_link_libraries(cuda_pybind PUBLIC GXF::common GXF::core GXF::std CUDA::cudart) + + +install( + TARGETS cuda_pybind + EXPORT gxfCoreTargets + PUBLIC_HEADER + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gxf/cuda + ARCHIVE + DESTINATION ${CMAKE_INSTALL_LIBDIR}/gxf/cuda + LIBRARY + DESTINATION ${CMAKE_INSTALL_LIBDIR}/gxf/cuda + COMPONENT Core +) + if(BUILD_TESTING) add_subdirectory(tests) -endif() \ No newline at end of file +endif() diff --git a/com_nvidia_gxf/gxf/cuda/tests/CMakeLists.txt b/com_nvidia_gxf/gxf/cuda/tests/CMakeLists.txt index c8c90fd..57c0eb2 100644 --- a/com_nvidia_gxf/gxf/cuda/tests/CMakeLists.txt +++ b/com_nvidia_gxf/gxf/cuda/tests/CMakeLists.txt @@ -20,9 +20,9 @@ gxf_core_add_extension_library( PUBLIC_HEADERS test_cuda_helper.hpp PUBLIC_DEPENDS CUDA::cublas + GXF::cuda GXF::common GXF::core - GXF::cuda GXF::std GTest::gtest_main NO_INSTALL @@ -35,9 +35,9 @@ gxf_add_gtests( test_cuda_stream_dotproduct.yaml test_cuda_unit.yaml DEPENDS + GXF::cuda GXF::common GXF::core - GXF::cuda GXF::std GTest::gtest_main ) diff --git a/com_nvidia_gxf/gxf/multimedia/CMakeLists.txt b/com_nvidia_gxf/gxf/multimedia/CMakeLists.txt index f9e9cfa..e2b6b3f 100644 --- a/com_nvidia_gxf/gxf/multimedia/CMakeLists.txt +++ b/com_nvidia_gxf/gxf/multimedia/CMakeLists.txt @@ -28,6 +28,29 @@ gxf_core_add_extension_library( GXF::std ) + +####################################################################################### +# Pybind11 extensions +####################################################################################### + +pybind11_add_module(video_pybind SHARED "bindings/video.cpp") +target_link_libraries(video_pybind PUBLIC GXF::core GXF::std) + +pybind11_add_module(camera_pybind SHARED "bindings/camera.cpp") +target_link_libraries(camera_pybind PUBLIC GXF::core GXF::std) + +install( + TARGETS video_pybind;camera_pybind + EXPORT gxfCoreTargets + PUBLIC_HEADER + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gxf/multimedia + ARCHIVE + DESTINATION ${CMAKE_INSTALL_LIBDIR}/gxf/multimedia + LIBRARY + DESTINATION ${CMAKE_INSTALL_LIBDIR}/gxf/multimedia + COMPONENT Core +) + if(BUILD_TESTING) add_subdirectory(tests) endif() diff --git a/com_nvidia_gxf/gxf/python_codelet/CMakeLists.txt b/com_nvidia_gxf/gxf/python_codelet/CMakeLists.txt index 4c65187..e92109e 100644 --- a/com_nvidia_gxf/gxf/python_codelet/CMakeLists.txt +++ b/com_nvidia_gxf/gxf/python_codelet/CMakeLists.txt @@ -18,8 +18,8 @@ gxf_core_add_extension_library( SOURCES py_codelet.cpp python_codelet.cpp - pydata.hpp PUBLIC_HEADERS + pydata.hpp py_codelet.hpp PUBLIC_DEPENDS GXF::core @@ -27,3 +27,25 @@ gxf_core_add_extension_library( pybind11::pybind11 Python3::Python ) + +####################################################################################### +# Pybind11 extensions +####################################################################################### + +pybind11_add_module(pycodelet SHARED "bindings/pycodelet.cpp") +target_link_libraries(pycodelet PUBLIC GXF::core GXF::std GXF::python_codelet) + +pybind11_add_module(pydata_pybind SHARED "bindings/pydata.cpp") +target_link_libraries(pydata_pybind PUBLIC GXF::core GXF::std) + +install( + TARGETS pycodelet;pydata_pybind + EXPORT gxfCoreTargets + PUBLIC_HEADER + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gxf/multimedia + ARCHIVE + DESTINATION ${CMAKE_INSTALL_LIBDIR}/gxf/multimedia + LIBRARY + DESTINATION ${CMAKE_INSTALL_LIBDIR}/gxf/multimedia + COMPONENT Core +) diff --git a/com_nvidia_gxf/gxf/python_codelet/py_codelet.hpp b/com_nvidia_gxf/gxf/python_codelet/py_codelet.hpp index 6cda7fa..2606072 100644 --- a/com_nvidia_gxf/gxf/python_codelet/py_codelet.hpp +++ b/com_nvidia_gxf/gxf/python_codelet/py_codelet.hpp @@ -36,7 +36,7 @@ namespace gxf { /// C++ side bridge of python codelet. This is the type which all python codelets register. /// Mandatory params - codelet_name_, codelet_filepath_ -class __attribute__((visibility("hidden"))) PyCodeletV0 : public Codelet { +class PyCodeletV0 : public Codelet { public: gxf_result_t registerInterface(Registrar* registrar) override; gxf_result_t start() override; diff --git a/com_nvidia_gxf/gxf/std/CMakeLists.txt b/com_nvidia_gxf/gxf/std/CMakeLists.txt index ebefa14..740407e 100644 --- a/com_nvidia_gxf/gxf/std/CMakeLists.txt +++ b/com_nvidia_gxf/gxf/std/CMakeLists.txt @@ -224,8 +224,42 @@ target_link_libraries(std add_library(GXF::std ALIAS std) set(GXF_EXTENSION_LIBRARY_TARGETS "std;${GXF_EXTENSION_LIBRARY_TARGETS}" PARENT_SCOPE) +####################################################################################### +# Pybind11 extensions +####################################################################################### + +pybind11_add_module(vault_pybind SHARED "bindings/vault.cpp") +target_link_libraries(vault_pybind PUBLIC GXF::core GXF::std) + +pybind11_add_module(allocator_pybind SHARED "bindings/allocator.cpp") +target_link_libraries(allocator_pybind PUBLIC GXF::core GXF::std) + +pybind11_add_module(clock_pybind SHARED "bindings/clock.cpp") +target_link_libraries(clock_pybind PUBLIC GXF::core GXF::std) + +pybind11_add_module(receiver_pybind SHARED "bindings/receiver.cpp") +target_link_libraries(receiver_pybind PUBLIC GXF::core GXF::std) + +pybind11_add_module(tensor_pybind SHARED "bindings/tensor.cpp") +target_link_libraries(tensor_pybind PUBLIC GXF::core GXF::std) + +pybind11_add_module(scheduling_terms_pybind SHARED "bindings/scheduling_terms.cpp") +target_link_libraries(scheduling_terms_pybind PUBLIC GXF::core GXF::std) + +pybind11_add_module(timestamp_pybind SHARED "bindings/timestamp.cpp") +target_link_libraries(timestamp_pybind PUBLIC GXF::core GXF::std) + +pybind11_add_module(eos_pybind SHARED "bindings/eos.cpp") +target_link_libraries(eos_pybind PUBLIC GXF::core GXF::std) + +pybind11_add_module(transmitter_pybind SHARED "bindings/transmitter.cpp") +target_link_libraries(transmitter_pybind PUBLIC GXF::core GXF::std) + +pybind11_add_module(scheduling_condition_pybind SHARED "bindings/scheduling_condition.cpp") +target_link_libraries(scheduling_condition_pybind PUBLIC GXF::core GXF::std) + install( - TARGETS std_internal;std + 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 EXPORT gxfCoreTargets PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gxf/std