cmake: Migrate to Python3 and use Development.Module

note: Development.Module is use to look for python header only
since library is not available on manylinux.
see: https://gitlab.kitware.com/cmake/cmake/-/issues/20425

note2: Development.Module has been introduced in CMake 3.18
ref: https://cmake.org/cmake/help/latest/module/FindPython3.html
This commit is contained in:
Mizux Seiha
2021-09-08 00:02:29 +02:00
parent c8816e911b
commit c7441c346c
9 changed files with 44 additions and 63 deletions

View File

@@ -8,11 +8,9 @@ swig_add_library(pywrapknapsack_solver
OUTPUT_DIR ${PROJECT_BINARY_DIR}/python/${PROJECT_NAME}/algorithms
SOURCES knapsack_solver.i)
target_include_directories(pywrapknapsack_solver PRIVATE ${Python_INCLUDE_DIRS})
target_include_directories(pywrapknapsack_solver PRIVATE ${Python3_INCLUDE_DIRS})
set_property(TARGET pywrapknapsack_solver PROPERTY SWIG_USE_TARGET_INCLUDE_DIRECTORIES ON)
if(Python_VERSION VERSION_GREATER_EQUAL 3)
target_compile_definitions(pywrapknapsack_solver PUBLIC "PY3")
endif()
target_compile_definitions(pywrapknapsack_solver PUBLIC "PY3")
# note: macOS is APPLE and also UNIX !
if(APPLE)
@@ -32,5 +30,5 @@ target_link_libraries(pywrapknapsack_solver PRIVATE ortools::ortools)
# i.e. we can't use: $<$<PLATFORM_ID:Windows>:${PYTHON_LIBRARIES}>
# see: https://cmake.org/cmake/help/git-stage/command/target_link_libraries.html#command:target_link_libraries
if(MSVC)
target_link_libraries(pywrapknapsack_solver PRIVATE ${Python_LIBRARIES})
target_link_libraries(pywrapknapsack_solver PRIVATE ${Python3_LIBRARIES})
endif()