diff --git a/cmake/PybindModuleCreation.cmake b/cmake/PybindModuleCreation.cmake index 4e03a71ee5c605cc902e1b9e568534ca17230b5b..eb1bd0342842cc843415c54b7b59875dce08015a 100644 --- a/cmake/PybindModuleCreation.cmake +++ b/cmake/PybindModuleCreation.cmake @@ -9,15 +9,17 @@ function(generate_python_binding name target_to_bind) ) # Use the New FindPython mode, recommanded. Requires CMake 3.15+ - if ( NOT DEFINED PYTHON_EXECUTABLE OR NOT DEFINED PYTHON_INCLUDE_DIR OR NOT DEFINED PYTHON_LIBRARY ) - find_package(Python 3.7 COMPONENTS Interpreter Development.Module REQUIRED) - endif() + find_package(Python 3.7 + COMPONENTS Interpreter Development.Module + REQUIRED) FetchContent_MakeAvailable(PyBind11) message(STATUS "Creating binding for module ${name}") file(GLOB_RECURSE pybind_src_files "python_binding/*.cpp") pybind11_add_module(${name} MODULE ${pybind_src_files} "NO_EXTRAS") # NO EXTRA recquired for pip install - target_include_directories(${name} PUBLIC "python_binding") + target_include_directories(${name} PUBLIC "python_binding" ) target_link_libraries(${name} PUBLIC ${target_to_bind}) + target_include_directories(${target_to_bind} PRIVATE ${Python_INCLUDE_DIRECTORIES}) + target_link_directories(${target_to_bind} PRIVATE ${Python_LIBRARY_DIRS}) endfunction()