Skip to content

Commit

Permalink
Add pybind11 modules to CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
ndam-hexagon committed Jan 24, 2025
1 parent a6913e3 commit a447086
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 7 deletions.
10 changes: 9 additions & 1 deletion com_nvidia_gxf/gxf/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 21 additions & 1 deletion com_nvidia_gxf/gxf/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
endif()
4 changes: 2 additions & 2 deletions com_nvidia_gxf/gxf/cuda/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)
23 changes: 23 additions & 0 deletions com_nvidia_gxf/gxf/multimedia/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
24 changes: 23 additions & 1 deletion com_nvidia_gxf/gxf/python_codelet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,34 @@ 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
GXF::std
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
)
2 changes: 1 addition & 1 deletion com_nvidia_gxf/gxf/python_codelet/py_codelet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
36 changes: 35 additions & 1 deletion com_nvidia_gxf/gxf/std/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a447086

Please sign in to comment.