Skip to content
Snippets Groups Projects
Commit e1f4c961 authored by Cyril Moineau's avatar Cyril Moineau
Browse files
parents 136edfe9 ad03e782
No related branches found
No related tags found
No related merge requests found
cmake_minimum_required(VERSION 3.11) cmake_minimum_required(VERSION 3.15)
file(READ "${CMAKE_SOURCE_DIR}/version.txt" version) file(READ "${CMAKE_SOURCE_DIR}/version.txt" version)
...@@ -52,17 +52,13 @@ target_include_directories(${module_name} ...@@ -52,17 +52,13 @@ target_include_directories(${module_name}
generate_python_binding(${project} ${module_name}) generate_python_binding(${project} ${module_name})
if (PYBIND) if (PYBIND)
message(STATUS "PYTHON INCLUDE DIR : ${PYTHON_INCLUDE_DIRS}") # Handles Python + pybind11 headers dependencies
message(STATUS "PYTHON PYTHON_LIBRARY : ${PYTHON_LIBRARIES}")
target_include_directories(${module_name}
PUBLIC
$<BUILD_INTERFACE:${PYTHON_INCLUDE_DIRS}>
)
target_link_libraries(${module_name} target_link_libraries(${module_name}
PUBLIC
pybind11::pybind11
PRIVATE PRIVATE
${PYTHON_LIBRARIES} Python::Python
) )
endif() endif()
target_compile_features(${module_name} PRIVATE cxx_std_14) target_compile_features(${module_name} PRIVATE cxx_std_14)
......
...@@ -9,12 +9,15 @@ function(generate_python_binding name target_to_bind) ...@@ -9,12 +9,15 @@ function(generate_python_binding name target_to_bind)
GIT_TAG v2.10.4 # or a later release 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)
FetchContent_MakeAvailable(PyBind11) FetchContent_MakeAvailable(PyBind11)
message(STATUS "Creating binding for module ${name}") message(STATUS "Creating binding for module ${name}")
file(GLOB_RECURSE pybind_src_files "python_binding/*.cpp") file(GLOB_RECURSE pybind_src_files "python_binding/*.cpp")
pybind11_add_module(${name} MODULE ${pybind_src_files} "NO_EXTRAS")
target_include_directories(${name} PUBLIC ${pybind11_INCLUDE_DIRS} "python_binding") pybind11_add_module(${name} MODULE ${pybind_src_files} "NO_EXTRAS") # NO EXTRA recquired for pip install
target_link_libraries(${name} PUBLIC ${target_to_bind}) target_include_directories(${name} PUBLIC "python_binding")
target_link_libraries(${name} PUBLIC ${target_to_bind})
endif() endif()
endfunction() endfunction()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment