Skip to content

Commit

Permalink
Update CMakeLists.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
Gonzalo-Mier committed Jun 19, 2024
1 parent 9465455 commit ba79afc
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ option(BUILD_DOC "Build Documentation" OFF)
option(BUILD_SHARED_LIBS "Build shared library(.so)" ON)
option(USE_ORTOOLS_RELEASE "Get or-tools from release tarball" OFF)
option(USE_ORTOOLS_FETCH_SRC "Get or-tools from source" OFF)
option(USE_ORTOOLS_VENDOR "Get or-tools from ortools_vendor" ON)
option(USE_ORTOOLS_VENDOR "Get or-tools from ortools_vendor" OFF)

if (BUILD_PYTHON)
cmake_minimum_required(VERSION 3.12.4)
Expand Down Expand Up @@ -107,7 +107,35 @@ find_package(Eigen3 REQUIRED)
find_library(MATH_LIBRARY m)

set(ORTOOLS_TARGET "")
if(USE_ORTOOLS_RELEASE)

if(USE_ORTOOLS_FETCH_SRC)
message(STATUS "or-tools -- Downloading and building from source")
set(BUILD_DEPS ON)
set(BUILD_SAMPLES OFF)
set(BUILD_EXAMPLES OFF)

FetchContent_Declare(ortools FETCHCONTENT_UPDATES_DISCONNECTED
GIT_REPOSITORY https://github.com/google/or-tools.git
GIT_TAG v9.9
CMAKE_ARGS
"-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}"
-DBUILD_DEPS:BOOL=ON
-DBUILD_SAMPLES:BOOL=OFF
-DBUILD_EXAMPLES:BOOL=OFF
)
FetchContent_MakeAvailable(ortools)

set_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED 1)
include(CTest)
set(ORTOOLS_TARGET "ortools")
elseif(USE_ORTOOLS_VENDOR)
find_package(ortools_vendor REQUIRED)
elseif(NOT USE_ORTOOLS_RELEASE)
find_package(ortools_vendor QUIET)
find_package(ortools CONFIG QUIET)
endif()

if(USE_ORTOOLS_RELEASE OR (NOT ortools_FOUND))
message(STATUS "or-tools -- Downloading and installing from release tarball")
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
message(STATUS "Target architecture is AMD64")
Expand Down Expand Up @@ -144,31 +172,7 @@ if(USE_ORTOOLS_RELEASE)
DIRECTORY "${ortools_SOURCE_DIR}/"
DESTINATION opt/f2c_ortools/
)
elseif(USE_ORTOOLS_FETCH_SRC)
message(STATUS "or-tools -- Downloading and building from source")
set(BUILD_DEPS ON)
set(BUILD_SAMPLES OFF)
set(BUILD_EXAMPLES OFF)

FetchContent_Declare(ortools FETCHCONTENT_UPDATES_DISCONNECTED
GIT_REPOSITORY https://github.com/google/or-tools.git
GIT_TAG v9.9
CMAKE_ARGS
"-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}"
-DBUILD_DEPS:BOOL=ON
-DBUILD_SAMPLES:BOOL=OFF
-DBUILD_EXAMPLES:BOOL=OFF
)
FetchContent_MakeAvailable(ortools)

set_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED 1)
include(CTest)
set(ORTOOLS_TARGET "ortools")
elseif(USE_ORTOOLS_VENDOR)
find_package(ortools_vendor REQUIRED)
else()
find_package(ortools CONFIG REQUIRED)
endif()
endif(USE_ORTOOLS_RELEASE OR (NOT ortools_FOUND))

set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)

Expand Down

0 comments on commit ba79afc

Please sign in to comment.