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