2017-12-11 09:20:43 +01:00
|
|
|
# This file is just an orchestration
|
2019-04-03 17:26:27 +02:00
|
|
|
cmake_minimum_required(VERSION 3.5.2)
|
2017-12-11 09:20:43 +01:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
|
|
|
|
|
|
|
|
|
# Apple: Don't modify install_name when touching RPATH.
|
|
|
|
|
if(POLICY CMP0068)
|
2018-10-10 15:16:27 +02:00
|
|
|
cmake_policy(SET CMP0068 NEW)
|
2017-12-11 09:20:43 +01:00
|
|
|
endif()
|
|
|
|
|
|
2020-02-24 17:32:53 +01:00
|
|
|
# Define file(GENERATE) behavior for relative paths.
|
|
|
|
|
if(POLICY CMP0070)
|
|
|
|
|
cmake_policy(SET CMP0070 NEW)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# target_sources: use absolute path for INTERFACE_SOURCES.
|
|
|
|
|
if(POLICY CMP0076)
|
|
|
|
|
cmake_policy(SET CMP0076 NEW)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# SWIG: use standard target name.
|
2019-08-06 18:21:29 +02:00
|
|
|
if(POLICY CMP0078)
|
2020-02-24 17:32:53 +01:00
|
|
|
cmake_policy(SET CMP0078 NEW)
|
2019-08-06 18:21:29 +02:00
|
|
|
endif()
|
|
|
|
|
|
2020-02-24 17:32:53 +01:00
|
|
|
# SWIG: use SWIG_MODULE_NAME property.
|
2019-08-06 18:21:29 +02:00
|
|
|
if(POLICY CMP0086)
|
|
|
|
|
cmake_policy(SET CMP0086 NEW)
|
|
|
|
|
endif()
|
|
|
|
|
|
2019-04-03 17:26:27 +02:00
|
|
|
include(utils)
|
|
|
|
|
set_version(VERSION)
|
|
|
|
|
|
2019-04-11 17:10:11 +02:00
|
|
|
project(ortools VERSION ${VERSION} LANGUAGES CXX)
|
2019-04-03 17:26:27 +02:00
|
|
|
message(STATUS "version: ${PROJECT_VERSION}")
|
2020-02-12 11:29:26 +01:00
|
|
|
message(STATUS "major: ${PROJECT_VERSION_MAJOR}")
|
|
|
|
|
message(STATUS "minor: ${PROJECT_VERSION_MINOR}")
|
|
|
|
|
message(STATUS "patch: ${PROJECT_VERSION_PATCH}")
|
2019-04-03 17:26:27 +02:00
|
|
|
|
|
|
|
|
# Default Build Type to be Release
|
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
|
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
|
|
|
|
|
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel. (default: Release)"
|
|
|
|
|
FORCE)
|
|
|
|
|
endif()
|
2017-12-11 09:20:43 +01:00
|
|
|
|
|
|
|
|
if(UNIX)
|
2018-10-10 15:16:27 +02:00
|
|
|
option(BUILD_SHARED_LIBS "Build shared libraries(.so)." ON)
|
2017-12-11 09:20:43 +01:00
|
|
|
elseif(MSVC)
|
2018-10-10 15:16:27 +02:00
|
|
|
# Windows only support static build.
|
|
|
|
|
set(BUILD_SHARED_LIBS OFF)
|
2017-12-11 09:20:43 +01:00
|
|
|
endif()
|
|
|
|
|
|
2020-01-29 17:32:40 +01:00
|
|
|
# By default only build the C++ library.
|
2019-04-03 17:26:27 +02:00
|
|
|
option(BUILD_CXX "Build C++ library" ON)
|
|
|
|
|
message(STATUS "Build C++ library: ${BUILD_CXX}")
|
2020-01-29 17:32:40 +01:00
|
|
|
|
|
|
|
|
option(BUILD_PYTHON "Build Python Library" OFF)
|
2019-04-03 17:26:27 +02:00
|
|
|
message(STATUS "Build Python: ${BUILD_PYTHON}")
|
2020-01-29 17:32:40 +01:00
|
|
|
option(BUILD_JAVA "Build Java Library" OFF)
|
2019-04-03 17:26:27 +02:00
|
|
|
message(STATUS "Build Java: ${BUILD_JAVA}")
|
2020-01-29 17:32:40 +01:00
|
|
|
option(BUILD_DOTNET "Build .NET Library" OFF)
|
2019-04-03 17:26:27 +02:00
|
|
|
message(STATUS "Build .Net: ${BUILD_DOTNET}")
|
2018-02-13 15:47:15 +01:00
|
|
|
|
2020-03-02 10:02:57 +01:00
|
|
|
option(BUILD_EXAMPLES "Build examples" ON)
|
|
|
|
|
message(STATUS "Build examples: ${BUILD_EXAMPLES}")
|
|
|
|
|
|
2019-04-03 17:26:27 +02:00
|
|
|
#option(BUILD_DOC "Build doxygen" OFF)
|
|
|
|
|
#message(STATUS "Build doxygen: ${BUILD_DOC}")
|
|
|
|
|
|
2020-01-29 17:32:40 +01:00
|
|
|
# By default all dependencies are NOT built (i.e. BUILD_DEPS=OFF),
|
|
|
|
|
# BUT if building any wrappers (Python, Java or .Net) then BUILD_DEPS=ON.
|
|
|
|
|
if(BUILD_PYTHON OR BUILD_JAVA OR BUILD_DOTNET)
|
|
|
|
|
option(BUILD_DEPS "Build all dependencies" ON)
|
|
|
|
|
else()
|
|
|
|
|
option(BUILD_DEPS "Build all dependencies" OFF)
|
|
|
|
|
endif()
|
|
|
|
|
message(STATUS "Build all dependencies: ${BUILD_DEPS}")
|
2020-01-30 13:25:40 +01:00
|
|
|
# Install built dependencies if any,
|
|
|
|
|
option(INSTALL_BUILD_DEPS "Install build all dependencies" ON)
|
2020-01-29 17:32:40 +01:00
|
|
|
|
2019-04-03 17:26:27 +02:00
|
|
|
# IF BUILD_DEPS=ON THEN Force all BUILD_*=ON
|
2017-12-11 09:20:43 +01:00
|
|
|
include(CMakeDependentOption)
|
2019-04-03 17:26:27 +02:00
|
|
|
CMAKE_DEPENDENT_OPTION(BUILD_ZLIB "Build the ZLIB dependency Library" OFF
|
|
|
|
|
"NOT BUILD_DEPS" ON)
|
2020-02-07 08:56:13 +01:00
|
|
|
message(STATUS "Build ZLIB: ${BUILD_ZLIB}")
|
|
|
|
|
|
2019-04-03 17:26:27 +02:00
|
|
|
CMAKE_DEPENDENT_OPTION(BUILD_absl "Build the abseil-cpp dependency Library" OFF
|
|
|
|
|
"NOT BUILD_DEPS" ON)
|
2020-02-07 08:56:13 +01:00
|
|
|
message(STATUS "Build abseil-cpp: ${BUILD_absl}")
|
|
|
|
|
|
2019-04-03 17:26:27 +02:00
|
|
|
CMAKE_DEPENDENT_OPTION(BUILD_gflags "Build the gflags dependency Library" OFF
|
|
|
|
|
"NOT BUILD_DEPS" ON)
|
2020-02-07 08:56:13 +01:00
|
|
|
message(STATUS "Build gflags: ${BUILD_gflags}")
|
|
|
|
|
|
2019-04-03 17:26:27 +02:00
|
|
|
CMAKE_DEPENDENT_OPTION(BUILD_glog "Build the glog dependency Library" OFF
|
|
|
|
|
"NOT BUILD_DEPS" ON)
|
2020-02-07 08:56:13 +01:00
|
|
|
message(STATUS "Build glog: ${BUILD_glog}")
|
2020-02-06 18:32:40 +01:00
|
|
|
|
2019-04-03 17:26:27 +02:00
|
|
|
CMAKE_DEPENDENT_OPTION(BUILD_Protobuf "Build the Protobuf dependency Library" OFF
|
|
|
|
|
"NOT BUILD_DEPS" ON)
|
|
|
|
|
message(STATUS "Build protobuf: ${BUILD_Protobuf}")
|
2020-02-06 18:32:40 +01:00
|
|
|
|
|
|
|
|
# Optional third party solvers (enabled by default)
|
|
|
|
|
option(USE_COINOR "Use the COIN-OR solver" ON)
|
|
|
|
|
message(STATUS "COIN-OR support: ${USE_COINOR}")
|
|
|
|
|
|
|
|
|
|
if(USE_COINOR)
|
|
|
|
|
CMAKE_DEPENDENT_OPTION(BUILD_CoinUtils "Build the CoinUtils dependency Library" OFF
|
|
|
|
|
"NOT BUILD_DEPS" ON)
|
|
|
|
|
message(STATUS "Build CoinUtils: ${BUILD_CoinUtils}")
|
|
|
|
|
|
|
|
|
|
CMAKE_DEPENDENT_OPTION(BUILD_Osi "Build the Osi dependency Library" OFF
|
|
|
|
|
"NOT BUILD_DEPS" ON)
|
|
|
|
|
message(STATUS "Build Osi: ${BUILD_Osi}")
|
|
|
|
|
|
|
|
|
|
CMAKE_DEPENDENT_OPTION(BUILD_Clp "Build the Clp dependency Library" OFF
|
|
|
|
|
"NOT BUILD_DEPS" ON)
|
|
|
|
|
message(STATUS "Build Clp: ${BUILD_Clp}")
|
|
|
|
|
|
|
|
|
|
CMAKE_DEPENDENT_OPTION(BUILD_Cgl "Build the Cgl dependency Library" OFF
|
|
|
|
|
"NOT BUILD_DEPS" ON)
|
|
|
|
|
message(STATUS "Build Cgl: ${BUILD_Cgl}")
|
|
|
|
|
|
|
|
|
|
CMAKE_DEPENDENT_OPTION(BUILD_Cbc "Build the Cbc dependency Library" OFF
|
|
|
|
|
"NOT BUILD_DEPS" ON)
|
|
|
|
|
message(STATUS "Build Cbc: ${BUILD_Cbc}")
|
|
|
|
|
endif()
|
2018-10-10 15:16:27 +02:00
|
|
|
|
2020-01-29 17:32:40 +01:00
|
|
|
# Optional third party solvers (disabled by default)
|
|
|
|
|
option(USE_CPLEX "Use the CPLEX solver" OFF)
|
|
|
|
|
message(STATUS "CPLEX support: ${USE_CPLEX}")
|
2020-02-06 18:32:40 +01:00
|
|
|
|
2020-01-29 17:32:40 +01:00
|
|
|
option(USE_SCIP "Use the SCIP solver" OFF)
|
|
|
|
|
message(STATUS "SCIP support: ${USE_SCIP}")
|
2020-02-06 18:32:40 +01:00
|
|
|
|
2020-01-29 17:32:40 +01:00
|
|
|
option(USE_XPRESS "Use the XPRESS solver" OFF)
|
|
|
|
|
message(STATUS "XPRESS support: ${USE_XPRESS}")
|
2019-08-06 18:21:29 +02:00
|
|
|
|
2019-04-03 17:26:27 +02:00
|
|
|
# Build Needed dependencies
|
|
|
|
|
add_subdirectory(cmake/dependencies dependencies)
|
2020-02-28 14:29:53 +01:00
|
|
|
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_BINARY_DIR}/dependencies/install)
|
2017-12-11 09:20:43 +01:00
|
|
|
|
2019-04-03 17:26:27 +02:00
|
|
|
include(CTest)
|
2018-10-10 15:16:27 +02:00
|
|
|
|
2020-02-12 16:16:23 +01:00
|
|
|
# Basic type
|
|
|
|
|
include(CMakePushCheckState)
|
|
|
|
|
cmake_push_check_state(RESET)
|
|
|
|
|
set(CMAKE_EXTRA_INCLUDE_FILES "cstdint")
|
|
|
|
|
include(CheckTypeSize)
|
|
|
|
|
check_type_size("long" SIZEOF_LONG LANGUAGE CXX)
|
|
|
|
|
message(STATUS "Found long size: ${SIZEOF_LONG}")
|
|
|
|
|
check_type_size("long long" SIZEOF_LONG_LONG LANGUAGE CXX)
|
|
|
|
|
message(STATUS "Found long long size: ${SIZEOF_LONG_LONG}")
|
|
|
|
|
check_type_size("int64_t" SIZEOF_INT64_T LANGUAGE CXX)
|
|
|
|
|
message(STATUS "Found int64_t size: ${SIZEOF_INT64_T}")
|
|
|
|
|
|
|
|
|
|
check_type_size("unsigned long" SIZEOF_ULONG LANGUAGE CXX)
|
|
|
|
|
message(STATUS "Found unsigned long size: ${SIZEOF_ULONG}")
|
|
|
|
|
check_type_size("unsigned long long" SIZEOF_ULONG_LONG LANGUAGE CXX)
|
|
|
|
|
message(STATUS "Found unsigned long long size: ${SIZEOF_ULONG_LONG}")
|
|
|
|
|
check_type_size("uint64_t" SIZEOF_UINT64_T LANGUAGE CXX)
|
|
|
|
|
message(STATUS "Found uint64_t size: ${SIZEOF_UINT64_T}")
|
|
|
|
|
|
|
|
|
|
check_type_size("int *" SIZEOF_INT_P LANGUAGE CXX)
|
|
|
|
|
message(STATUS "Found int * size: ${SIZEOF_INT_P}")
|
|
|
|
|
cmake_pop_check_state()
|
|
|
|
|
|
2019-04-03 17:26:27 +02:00
|
|
|
include(cpp)
|
2018-01-18 15:15:13 +01:00
|
|
|
|
2019-04-03 17:26:27 +02:00
|
|
|
include(python)
|
|
|
|
|
include(java)
|
|
|
|
|
include(dotnet)
|