From ce2bde4073e20f4e38b1b6997824bb68d343143f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gr=C3=A9goire=20Kubler?= <gregoire.kubler@proton.me>
Date: Fri, 10 May 2024 17:35:42 +0200
Subject: [PATCH] fix : better import of python

---
 cmake/PybindModuleCreation.cmake | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/cmake/PybindModuleCreation.cmake b/cmake/PybindModuleCreation.cmake
index 4e03a71ee..eb1bd0342 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()
-- 
GitLab