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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user