forked from google/or-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
79 lines (62 loc) · 2.32 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
CMAKE_MINIMUM_REQUIRED(VERSION 3.8)
PROJECT(or_tools LANGUAGES CXX)
SET(CMAKE_CXX_STANDARD 17)
INCLUDE(FindPkgConfig)
IF(UNIX)
IF(NOT APPLE)
INCLUDE(GNUInstallDirs)
ENDIF()
ENDIF()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fwrapv -DNDEBUG")
IF(BUILD_PYTHON)
SET(BUILD_CXX ON)
FIND_PACKAGE(PythonInterp)
FIND_PACKAGE(PythonLibs)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
IF(PYTHON_VERSION_MAJOR GREATER_EQUAL 3)
SET(CMAKE_SWIG_FLAGS "${CMAKE_SWIG_FLAGS};-py3;-DPY3")
ENDIF()
FIND_PACKAGE(SWIG REQUIRED)
INCLUDE(cmake/UseSWIG.cmake)
ENDIF(BUILD_PYTHON)
IF(BUILD_CXX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_GLOP -DUSE_BOP")
FIND_PACKAGE(Protobuf REQUIRED)
FIND_PACKAGE(Gflags REQUIRED)
PKG_CHECK_MODULES(CBC cbc)
IF(CBC_FOUND)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CBC_CFLAGS} -DUSE_CBC")
ENDIF(CBC_FOUND)
PKG_CHECK_MODULES(CLP clp)
IF(CLP_FOUND)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CLP_CFLAGS} -DUSE_CLP")
ENDIF(CLP_FOUND)
SET(PROTOBUF_IMPORT_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE_DIRECTORIES(.)
INCLUDE_DIRECTORIES(examples)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
SET(SUBTARGETS "")
FOREACH(SUBPROJECT base util lp_data glop graph algorithms sat bop linear_solver constraint_solver)
ADD_SUBDIRECTORY(ortools/${SUBPROJECT})
LIST(APPEND SUBTARGETS "$<TARGET_OBJECTS:${PROJECT_NAME}_${SUBPROJECT}>")
ENDFOREACH()
ADD_LIBRARY(${PROJECT_NAME} SHARED ${SUBTARGETS})
INSTALL(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}_Exports
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
ADD_SUBDIRECTORY(examples/cpp)
ENDIF(BUILD_CXX)
IF(BUILD_PYTHON)
FOREACH(SUBPROJECT constraint_solver algorithms graph linear_solver)
ADD_SUBDIRECTORY(ortools/${SUBPROJECT}/python)
ENDFOREACH(SUBPROJECT constraint_solver algorithms)
ENDIF(BUILD_PYTHON)
INSTALL(DIRECTORY ortools
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h")
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ortools
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.pb.h"
PATTERN CMakeFiles EXCLUDE)