forked from google/or-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
83 lines (67 loc) · 2.36 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
80
81
82
83
CMAKE_MINIMUM_REQUIRED(VERSION 3.8)
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
INCLUDE(cmake/utils.cmake)
INCLUDE(GenerateExportHeader)
INCLUDE(ExternalProject)
INCLUDE(CMakePackageConfigHelpers)
SET_VERSION(VERSION)
PROJECT(ortools LANGUAGES CXX VERSION ${VERSION})
SET(CMAKE_CXX_STANDARD 17)
IF(UNIX)
IF(NOT APPLE)
INCLUDE(GNUInstallDirs)
ELSE()
SET(CMAKE_INSTALL_LIBDIR lib)
SET(CMAKE_INSTALL_BINDIR bin)
SET(CMAKE_INSTALL_INCLUDEDIR include)
ENDIF()
ELSE()
SET(CMAKE_INSTALL_LIBDIR lib)
SET(CMAKE_INSTALL_BINDIR bin)
SET(CMAKE_INSTALL_INCLUDEDIR include)
ENDIF()
SET(BUILD_CXX OFF CACHE BOOL "Build C++ library")
SET(BUILD_PY OFF CACHE BOOL "Build Python library")
SET(BUILD_DEPS OFF CACHE BOOL "Force re-build of all dependencies")
SET(DOWNLOAD_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/downloads" CACHE PATH "Location where external projects will be downloaded.")
MARK_AS_ADVANCED(DOWNLOAD_LOCATION)
FILE(READ ${CMAKE_CURRENT_SOURCE_DIR}/Dependencies.txt _Dependency_file)
FOREACH(DEPENDENCY Protobuf gflags glog Cbc CoinUtils Osi Clp Cgl)
STRING(REGEX REPLACE ".*${DEPENDENCY} = ([0-9.]+).*" "\\1" ${DEPENDENCY}_VERSION ${_Dependency_file})
ENDFOREACH()
IF(BUILD_PY)
FIND_PACKAGE(${PROJECT_NAME} QUIET)
IF(NOT ${PROJECT_NAME}_FOUND)
SET(BUILD_CXX ON)
ELSE()
IF(NOT BUILD_CXX)
INCLUDE_DIRECTORIES(${${PROJECT_NAME}_INCLUDE_DIRS})
ENDIF()
ENDIF()
ENDIF()
FIND_PACKAGE(Threads REQUIRED QUIET)
FIND_PACKAGE(Protobuf ${Protobuf_VERSION} QUIET)
IF(BUILD_DEPS)
SET(Protobuf_FOUND False)
ENDIF()
IF(NOT Protobuf_FOUND)
MESSAGE(STATUS "Did not find system protobuf or forced build. Building as an external project")
INCLUDE(cmake/external/protobuf.cmake)
ENDIF()
INCLUDE_DIRECTORIES(${Protobuf_INCLUDE_DIRS})
SET(PROTOBUF_IMPORT_DIRS ${PROJECT_SOURCE_DIR})
SET(PROTOBUF_GENERATE_CPP_APPEND_PATH OFF)
IF(MSVC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj /DNDEBUG /DUSE_GLOP /DUSE_BOP")
ELSE()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fwrapv -DNDEBUG -DUSE_GLOP -DUSE_BOP")
ENDIF()
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
MESSAGE(STATUS "Build cxx library: ${BUILD_CXX}")
MESSAGE(STATUS "Build python library: ${BUILD_PY}")
IF(BUILD_CXX)
INCLUDE(cmake/cpp.cmake)
ENDIF()
IF(BUILD_PY)
INCLUDE(cmake/python.cmake)
ENDIF()