forked from google/or-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
37 lines (34 loc) · 1.54 KB
/
CMakeLists.txt
File metadata and controls
37 lines (34 loc) · 1.54 KB
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
37
set_property(SOURCE routing.i PROPERTY CPLUSPLUS ON)
set_property(SOURCE routing.i PROPERTY SWIG_MODULE_NAME pywrapcp)
set_property(SOURCE routing.i PROPERTY COMPILE_DEFINITIONS
${OR_TOOLS_COMPILE_DEFINITIONS} ABSL_MUST_USE_RESULT)
set_property(SOURCE routing.i PROPERTY COMPILE_OPTIONS -nofastunpack)
swig_add_library(pywrapcp
TYPE SHARED
LANGUAGE python
OUTPUT_DIR ${PROJECT_BINARY_DIR}/python/${PROJECT_NAME}/constraint_solver
SOURCES routing.i)
target_include_directories(pywrapcp PRIVATE ${PYTHON_INCLUDE_DIRS})
set_property(TARGET pywrapcp PROPERTY SWIG_USE_TARGET_INCLUDE_DIRECTORIES ON)
if(${PYTHON_VERSION_STRING} VERSION_GREATER_EQUAL 3)
target_compile_definitions(pywrapcp PUBLIC "PY3")
endif()
# note: macOS is APPLE and also UNIX !
if(APPLE)
set_target_properties(pywrapcp PROPERTIES
SUFFIX ".so"
INSTALL_RPATH "@loader_path;@loader_path/../../${PROJECT_NAME}/.libs")
set_property(TARGET pywrapcp APPEND PROPERTY
LINK_FLAGS "-flat_namespace -undefined suppress")
elseif(UNIX)
set_target_properties(pywrapcp PROPERTIES
INSTALL_RPATH "$ORIGIN:$ORIGIN/../../${PROJECT_NAME}/.libs")
endif()
target_link_libraries(pywrapcp 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(pywrapcp PRIVATE ${PYTHON_LIBRARIES})
endif()