forked from google/or-tools
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
34 lines (31 loc) · 1.39 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
set_property(SOURCE graph.i PROPERTY CPLUSPLUS ON)
set_property(SOURCE graph.i PROPERTY SWIG_MODULE_NAME pywrapgraph)
set_property(SOURCE graph.i PROPERTY COMPILE_DEFINITIONS
${OR_TOOLS_COMPILE_DEFINITIONS} ABSL_MUST_USE_RESULT)
swig_add_library(pywrapgraph
TYPE SHARED
LANGUAGE python
OUTPUT_DIR ${PYTHON_PROJECT_DIR}/graph
SOURCES graph.i)
target_include_directories(pywrapgraph PRIVATE ${Python3_INCLUDE_DIRS})
set_property(TARGET pywrapgraph PROPERTY SWIG_USE_TARGET_INCLUDE_DIRECTORIES ON)
target_compile_definitions(pywrapgraph PUBLIC "PY3")
# note: macOS is APPLE and also UNIX !
if(APPLE)
set_target_properties(pywrapgraph PROPERTIES
SUFFIX ".so"
INSTALL_RPATH "@loader_path;@loader_path/../../${PROJECT_NAME}/.libs")
set_property(TARGET pywrapgraph APPEND PROPERTY
LINK_FLAGS "-flat_namespace -undefined suppress")
elseif(UNIX)
set_target_properties(pywrapgraph PROPERTIES
INSTALL_RPATH "$ORIGIN:$ORIGIN/../../${PROJECT_NAME}/.libs")
endif()
target_link_libraries(pywrapgraph 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(pywrapgraph PRIVATE ${Python3_LIBRARIES})
endif()