* Add define SWIGWORDSIZE64 on Linux * Add -doxygen option * add ortools/util/python * Move python generated stuff to BINARY_DIR/python * Bump CMake >= 3.14 as requirement * SWIG module rework from 3.9 to 3.14 * Python module rework in 3.12 * Drop Python 2.7 support (like in Makefile) * Fix clean target * OUTPUT/BYPRODUCTS path are relative to CURRENT_BINARY_DIR not WORKING_DIR * Fix ortools package install in virtualenv * Clean target now remove the <build>/venv directory
35 lines
1.4 KiB
CMake
35 lines
1.4 KiB
CMake
set_property(SOURCE graph.i PROPERTY CPLUSPLUS ON)
|
|
set_property(SOURCE graph.i PROPERTY SWIG_MODULE_NAME pywrapgraph)
|
|
swig_add_library(pywrapgraph
|
|
TYPE SHARED
|
|
LANGUAGE python
|
|
OUTPUT_DIR ${PROJECT_BINARY_DIR}/python/${PROJECT_NAME}/graph
|
|
SOURCES graph.i)
|
|
|
|
target_include_directories(pywrapgraph PRIVATE ${PYTHON_INCLUDE_DIRS})
|
|
set_property(TARGET pywrapgraph PROPERTY SWIG_USE_TARGET_INCLUDE_DIRECTORIES ON)
|
|
if(${PYTHON_VERSION_STRING} VERSION_GREATER_EQUAL 3)
|
|
target_compile_definitions(pywrapgraph PUBLIC "PY3")
|
|
endif()
|
|
|
|
# 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 ${PYTHON_LIBRARIES})
|
|
endif()
|