diff --git a/aidge_core/aidge_export_aidge/static/CMakeLists.txt b/aidge_core/aidge_export_aidge/static/CMakeLists.txt index b95ce43658be4ea8cc659f0278de634b2bc27fb9..4220bb9d502474301cf748252930ff8bdd5c97e3 100644 --- a/aidge_core/aidge_export_aidge/static/CMakeLists.txt +++ b/aidge_core/aidge_export_aidge/static/CMakeLists.txt @@ -53,7 +53,7 @@ add_library(${module_name} ${src_files} ${inc_files}) target_link_libraries(${module_name} PUBLIC _aidge_core # _ is added because we link the exported target and not the project - _aidge_backend_cpu # example if you want to add aidge_backend_cpu as dependency to your export + # _aidge_backend_cpu # example if you want to add aidge_backend_cpu as dependency to your export ) #Set target properties @@ -69,7 +69,7 @@ if (PYBIND) PUBLIC pybind11::pybind11 PRIVATE - Python::Module + Python::Python ) endif() diff --git a/aidge_core/aidge_export_aidge/static/cmake/PybindModuleCreation.cmake b/aidge_core/aidge_export_aidge/static/cmake/PybindModuleCreation.cmake index 13ba3671be3cec7619257a4606a301fa7e1bb45e..193f3332231ac384daab2e5bf75c1a5de0d2bf1d 100644 --- a/aidge_core/aidge_export_aidge/static/cmake/PybindModuleCreation.cmake +++ b/aidge_core/aidge_export_aidge/static/cmake/PybindModuleCreation.cmake @@ -1,28 +1,25 @@ -function(generate_python_binding pybind_module_name target_to_bind) - add_definitions(-DPYBIND) - Include(FetchContent) +function(generate_python_binding name target_to_bind) - set(PYBIND_VERSION v2.10.4) - set(PYBIND11_FINDPYTHON ON) - message(STATUS "Retrieving pybind ${PYBIND_VERSION} from git") + find_package(Python COMPONENTS Interpreter Development) + add_definitions(-DPYBIND) + Include(FetchContent) FetchContent_Declare( - PyBind11 - GIT_REPOSITORY https://github.com/pybind/pybind11.git - GIT_TAG ${PYBIND_VERSION} # or a later release + PyBind11 + GIT_REPOSITORY https://github.com/pybind/pybind11.git + GIT_TAG v2.10.4 # or a later release ) - - # Use the New FindPython mode, recommanded. Requires CMake 3.15+ - find_package(Python COMPONENTS Interpreter Development.Module) FetchContent_MakeAvailable(PyBind11) - message(STATUS "Creating binding for module ${pybind_module_name}") + message(STATUS "Creating binding for module ${name}") file(GLOB_RECURSE pybind_src_files "python_binding/*.cpp") - pybind11_add_module(${pybind_module_name} MODULE ${pybind_src_files} "NO_EXTRAS") # NO EXTRA recquired for pip install - target_include_directories(${pybind_module_name} PUBLIC "python_binding") - target_link_libraries(${pybind_module_name} PUBLIC - ${target_to_bind} - Python::Module + pybind11_add_module(${name} MODULE ${pybind_src_files} "NO_EXTRAS") # NO EXTRA recquired for pip install + target_include_directories(${name} PUBLIC "python_binding") + + # Handles Python + pybind11 headers dependencies + target_link_libraries(${name} + PUBLIC + ${target_to_bind} ) endfunction()