From 93b22ff4ed58421ca053bbf3d5f48a5c6b7d3e0c Mon Sep 17 00:00:00 2001 From: Corentin Le Molgat Date: Mon, 2 May 2022 16:02:54 +0200 Subject: [PATCH] cmake: cleanup --- CMakeLists.txt | 70 +++++++++++++++---------------- cmake/README.md | 19 +++++---- cmake/dependencies/CMakeLists.txt | 42 +++++++++---------- cmake/deps.cmake | 54 ++++++++++++------------ makefiles/Makefile.cpp.mk | 6 ++- 5 files changed, 97 insertions(+), 94 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fde18a20b9..21b9649877 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -160,41 +160,7 @@ if(BUILD_LP_PARSER) endif() # Optional third party solvers (enabled by default) -## PDLP -CMAKE_DEPENDENT_OPTION(USE_PDLP "Use the PDLP solver" ON "BUILD_CXX" OFF) -message(STATUS "PDLP support: ${USE_PDLP}") -if(USE_PDLP) - CMAKE_DEPENDENT_OPTION(BUILD_PDLP "Build the PDLP dependency Library" ON - "NOT BUILD_DEPS" ON) - message(STATUS "Build PDLP: ${BUILD_PDLP}") - if(BUILD_PDLP) - CMAKE_DEPENDENT_OPTION(BUILD_Eigen3 "Build the eigen3 dependency Library" OFF - "NOT BUILD_DEPS" ON) - message(STATUS "Build eigen3: ${BUILD_Eigen3}") - endif() -endif() - -## SCIP -CMAKE_DEPENDENT_OPTION(USE_SCIP "Use the Scip solver" ON "BUILD_CXX" OFF) -message(STATUS "SCIP support: ${USE_SCIP}") -if(USE_SCIP) - CMAKE_DEPENDENT_OPTION(BUILD_SCIP "Build the SCIP dependency Library" OFF - "NOT BUILD_DEPS" ON) - message(STATUS "Build SCIP: ${BUILD_SCIP}") -endif() - -## GLPK -# Disable by default since it is GLPv3, user could enable it and release under GLPv3 -# see: https://www.apache.org/licenses/GPL-compatibility.html -CMAKE_DEPENDENT_OPTION(USE_GLPK "Use the GLPK solver" OFF "BUILD_CXX" OFF) -message(STATUS "GLPK support: ${USE_GLPK}") -if(USE_GLPK) - CMAKE_DEPENDENT_OPTION(BUILD_GLPK "Build the GLPK dependency Library" OFF - "NOT BUILD_DEPS" ON) - message(STATUS "Build GLPK: ${BUILD_GLPK}") -endif() - -## COIN-OR +## COIN-OR Solvers (Cbc, Clp) CMAKE_DEPENDENT_OPTION(USE_COINOR "Use the COIN-OR solver" ON "BUILD_CXX" OFF) message(STATUS "COIN-OR support: ${USE_COINOR}") if(USE_COINOR) @@ -219,6 +185,40 @@ if(USE_COINOR) message(STATUS "Build Cbc: ${BUILD_Cbc}") endif() +## GLPK +# Disable by default since it is GLPv3, user could enable it and release under GLPv3 +# see: https://www.apache.org/licenses/GPL-compatibility.html +CMAKE_DEPENDENT_OPTION(USE_GLPK "Use the GLPK solver" OFF "BUILD_CXX" OFF) +message(STATUS "GLPK support: ${USE_GLPK}") +if(USE_GLPK) + CMAKE_DEPENDENT_OPTION(BUILD_GLPK "Build the GLPK dependency Library" OFF + "NOT BUILD_DEPS" ON) + message(STATUS "Build GLPK: ${BUILD_GLPK}") +endif() + +## PDLP +CMAKE_DEPENDENT_OPTION(USE_PDLP "Use the PDLP solver" ON "BUILD_CXX" OFF) +message(STATUS "PDLP support: ${USE_PDLP}") +if(USE_PDLP) + CMAKE_DEPENDENT_OPTION(BUILD_PDLP "Build the PDLP dependency Library" ON + "NOT BUILD_DEPS" ON) + message(STATUS "Build PDLP: ${BUILD_PDLP}") + if(BUILD_PDLP) + CMAKE_DEPENDENT_OPTION(BUILD_Eigen3 "Build the eigen3 dependency Library" OFF + "NOT BUILD_DEPS" ON) + message(STATUS "Build eigen3: ${BUILD_Eigen3}") + endif() +endif() + +## SCIP +CMAKE_DEPENDENT_OPTION(USE_SCIP "Use the Scip solver" ON "BUILD_CXX" OFF) +message(STATUS "SCIP support: ${USE_SCIP}") +if(USE_SCIP) + CMAKE_DEPENDENT_OPTION(BUILD_SCIP "Build the SCIP dependency Library" OFF + "NOT BUILD_DEPS" ON) + message(STATUS "Build SCIP: ${BUILD_SCIP}") +endif() + # Optional third party solvers (disabled by default) option(USE_CPLEX "Use the CPLEX solver" OFF) message(STATUS "CPLEX support: ${USE_CPLEX}") diff --git a/cmake/README.md b/cmake/README.md index bd6ba0e8e3..13e564e9ec 100644 --- a/cmake/README.md +++ b/cmake/README.md @@ -78,12 +78,12 @@ below). * ZLIB (`BUILD_ZLIB`), * Google Abseil-cpp (`BUILD_absl`), * Google Protobuf (`BUILD_Protobuf`), -* SCIP (`BUILD_SCIP`),
- note: You can disable the support of SCIP solvers - by using `-DUSE_SCIP=OFF` (`ON` by default). * GLPK (`BUILD_GLPK`),
- note: You can disable the support of GLPK solvers + note: You can disable the support of GLPK solver by using `-DUSE_GLPK=OFF` (`ON` by default). +* SCIP (`BUILD_SCIP`),
+ note: You can disable the support of SCIP solver + by using `-DUSE_SCIP=OFF` (`ON` by default). * COIN-OR solvers, @@ -167,16 +167,19 @@ cmake -S. -Bbuild -LH | `BUILD_ZLIB` | OFF* | Static build the zlib library
**Forced** to ON if `BUILD_DEPS=ON` | | `BUILD_absl` | OFF* | Static build the abseil-cpp libraries
**Forced** to ON if `BUILD_DEPS=ON` | | `BUILD_Protobuf` | OFF* | Static build the protobuf libraries
**Forced** to ON if `BUILD_DEPS=ON` | -| `USE_SCIP` | ON\* | Enable SCIP support
**Forced** to OFF if `BUILD_CXX=OFF` | -| `BUILD_SCIP` | OFF\* | Static build the SCIP libraries
**Forced** to ON if `USE_SCIP=ON` **and** `BUILD_DEPS=ON` | -| `USE_GLPK` | ON\* | Enable GLPK support
**Forced** to OFF if `BUILD_CXX=OFF` | -| `BUILD_GLPK` | OFF\* | Static build the GLPK libraries
**Forced** to ON if `USE_GLPK=ON` **and** `BUILD_DEPS=ON` | +| `BUILD_re2` | OFF* | Static build the re2 libraries
**Forced** to ON if `BUILD_DEPS=ON` | +| `BUILD_Eigen3` | OFF* | Static build the Eigen3 libraries
**Forced** to ON if `BUILD_DEPS=ON` | +| | | | | `USE_COINOR` | ON\* | Enable Coin-OR support
**Forced** to OFF if `BUILD_CXX=OFF` | | `BUILD_CoinUtils` | OFF\* | Static build the CoinUtils library
**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON` | | `BUILD_Osi` | OFF\* | Static build the Osi library
**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON` | | `BUILD_Clp` | OFF\* | Static build the Clp library
**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON` | | `BUILD_Cgl` | OFF\* | Static build the Cgl library
**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON` | | `BUILD_Cbc` | OFF\* | Static build the Cbc library
**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON` | +| `USE_GLPK` | ON\* | Enable GLPK support
**Forced** to OFF if `BUILD_CXX=OFF` | +| `BUILD_GLPK` | OFF\* | Static build the GLPK libraries
**Forced** to ON if `USE_GLPK=ON` **and** `BUILD_DEPS=ON` | +| `USE_SCIP` | ON\* | Enable SCIP support
**Forced** to OFF if `BUILD_CXX=OFF` | +| `BUILD_SCIP` | OFF\* | Static build the SCIP libraries
**Forced** to ON if `USE_SCIP=ON` **and** `BUILD_DEPS=ON` | | `USE_CPLEX` | OFF | Enable CPLEX support | | `USE_XPRESS` | OFF | Enable XPRESS support | | | | | diff --git a/cmake/dependencies/CMakeLists.txt b/cmake/dependencies/CMakeLists.txt index 947df7846f..d0f5f9f36b 100644 --- a/cmake/dependencies/CMakeLists.txt +++ b/cmake/dependencies/CMakeLists.txt @@ -166,6 +166,27 @@ if(BUILD_PYTHON AND BUILD_pybind11) message(CHECK_PASS "fetched") endif() +# ############################################################################## +# GLPK +# ############################################################################## +if(BUILD_GLPK) + message(CHECK_START "Fetching GLPK") + list(APPEND CMAKE_MESSAGE_INDENT " ") + set(BUILD_EXAMPLES OFF) + set(WITH_GMP OFF) + set(WITH_ODBC OFF) + set(WITH_MYSQL OFF) + + FetchContent_Declare( + glpk + GIT_REPOSITORY "https://github.com/Mizux/GLPK.git" + GIT_TAG "5.0" + ) + FetchContent_MakeAvailable(glpk) + list(POP_BACK CMAKE_MESSAGE_INDENT) + message(CHECK_PASS "fetched") +endif() + # ############################################################################## # SCIP # ############################################################################## @@ -195,27 +216,6 @@ if(BUILD_SCIP) message(CHECK_PASS "fetched") endif() -# ############################################################################## -# GLPK -# ############################################################################## -if(BUILD_GLPK) - message(CHECK_START "Fetching GLPK") - list(APPEND CMAKE_MESSAGE_INDENT " ") - set(BUILD_EXAMPLES OFF) - set(WITH_GMP OFF) - set(WITH_ODBC OFF) - set(WITH_MYSQL OFF) - - FetchContent_Declare( - glpk - GIT_REPOSITORY "https://github.com/Mizux/GLPK.git" - GIT_TAG "5.0" - ) - FetchContent_MakeAvailable(glpk) - list(POP_BACK CMAKE_MESSAGE_INDENT) - message(CHECK_PASS "fetched") -endif() - # ############################################################################## # Coinutils # ############################################################################## diff --git a/cmake/deps.cmake b/cmake/deps.cmake index 3507928262..28ab3e99aa 100644 --- a/cmake/deps.cmake +++ b/cmake/deps.cmake @@ -58,34 +58,6 @@ if(BUILD_LP_PARSER) set(RE2_DEPS re2::re2) endif() -if(BUILD_PDLP) - if(NOT BUILD_Eigen3) - find_package(Eigen3 REQUIRED) - endif() - if(NOT TARGET Eigen3::Eigen) - message(FATAL_ERROR "Target Eigen3::Eigen not available.") - endif() - set(PDLP_DEPS Eigen3::Eigen) -endif() - -if(USE_PLDP) - if(NOT BUILD_PDLP) - find_package(PDLP REQUIRED) - endif() -endif() - -if(USE_SCIP) - if(NOT BUILD_SCIP) - find_package(SCIP REQUIRED) - endif() -endif() - -if(USE_GLPK) - if(NOT BUILD_GLPK) - find_package(GLPK REQUIRED) - endif() -endif() - if(USE_COINOR) if(NOT BUILD_CoinUtils) find_package(CoinUtils REQUIRED) @@ -110,6 +82,32 @@ if(USE_COINOR) set(COINOR_DEPS Coin::CbcSolver Coin::OsiCbc Coin::ClpSolver Coin::OsiClp) endif() +if(USE_GLPK) + if(NOT BUILD_GLPK) + find_package(GLPK REQUIRED) + endif() +endif() + +if(USE_PLDP) + if(NOT BUILD_PDLP) + find_package(PDLP REQUIRED) + else() + if(NOT BUILD_Eigen3) + find_package(Eigen3 REQUIRED) + endif() + if(NOT TARGET Eigen3::Eigen) + message(FATAL_ERROR "Target Eigen3::Eigen not available.") + endif() + set(PDLP_DEPS Eigen3::Eigen) + endif() +endif() + +if(USE_SCIP) + if(NOT BUILD_SCIP) + find_package(SCIP REQUIRED) + endif() +endif() + # Check optional Dependencies if(USE_CPLEX) find_package(CPLEX REQUIRED) diff --git a/makefiles/Makefile.cpp.mk b/makefiles/Makefile.cpp.mk index f2c8853222..82ba934a57 100644 --- a/makefiles/Makefile.cpp.mk +++ b/makefiles/Makefile.cpp.mk @@ -21,8 +21,9 @@ endif # Checks if the user has overwritten default libraries and binaries. BUILD_TYPE ?= Release USE_COINOR ?= ON -USE_SCIP ?= ON USE_GLPK ?= OFF +USE_PDLP := ON # OFF not supported +USE_SCIP ?= ON USE_CPLEX ?= OFF USE_XPRESS ?= OFF JOBS ?= 4 @@ -47,8 +48,9 @@ third_party: -DBUILD_EXAMPLES=OFF \ -DBUILD_SAMPLES=OFF \ -DUSE_COINOR=$(USE_COINOR) \ - -DUSE_SCIP=$(USE_SCIP) \ -DUSE_GLPK=$(USE_GLPK) \ + -DUSE_PDLP=$(USE_PDLP) \ + -DUSE_SCIP=$(USE_SCIP) \ -DUSE_CPLEX=$(USE_CPLEX) \ -DUSE_XPRESS=$(USE_XPRESS) \ -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \