forked from google/or-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
36 lines (33 loc) · 1.62 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
set_property(SOURCE knapsack_solver.i PROPERTY CPLUSPLUS ON)
set_property(SOURCE knapsack_solver.i PROPERTY SWIG_MODULE_NAME pywrapknapsack_solver)
set_property(SOURCE knapsack_solver.i PROPERTY COMPILE_DEFINITIONS
${OR_TOOLS_COMPILE_DEFINITIONS} ABSL_MUST_USE_RESULT)
swig_add_library(pywrapknapsack_solver
TYPE SHARED
LANGUAGE python
OUTPUT_DIR ${PROJECT_BINARY_DIR}/python/${PROJECT_NAME}/algorithms
SOURCES knapsack_solver.i)
target_include_directories(pywrapknapsack_solver PRIVATE ${PYTHON_INCLUDE_DIRS})
set_property(TARGET pywrapknapsack_solver PROPERTY SWIG_USE_TARGET_INCLUDE_DIRECTORIES ON)
if(${PYTHON_VERSION_STRING} VERSION_GREATER_EQUAL 3)
target_compile_definitions(pywrapknapsack_solver PUBLIC "PY3")
endif()
# note: macOS is APPLE and also UNIX !
if(APPLE)
set_target_properties(pywrapknapsack_solver PROPERTIES
SUFFIX ".so"
INSTALL_RPATH "@loader_path;@loader_path/../../${PROJECT_NAME}/.libs")
set_property(TARGET pywrapknapsack_solver APPEND PROPERTY
LINK_FLAGS "-flat_namespace -undefined suppress")
elseif(UNIX)
set_target_properties(pywrapknapsack_solver PROPERTIES
INSTALL_RPATH "$ORIGIN:$ORIGIN/../../${PROJECT_NAME}/.libs")
endif()
target_link_libraries(pywrapknapsack_solver PRIVATE ortools::ortools)
# Variable PYTHON_LIBRARIES can contains keyword `optimized`
# which won't be interpreted inside a generator expression.
# 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})
endif()