cmake: cleanup

This commit is contained in:
Corentin Le Molgat
2025-03-26 10:53:14 +01:00
parent 6258871db6
commit 98d2b003ff
8 changed files with 208 additions and 159 deletions

View File

@@ -195,27 +195,27 @@ cmake -S. -Bbuild -LH
| `BUILD_GLOP` | OFF\* | Build the standalone Glop library<br>**Forced** to OFF if `BUILD_CXX=ON`, otherwise default to ON |
| | | |
| `BUILD_DEPS` | OFF* | Default to ON if `BUILD_JAVA=ON` or `BUILD_PYTHON=ON` or `BUILD_DOTNET=ON` |
| `BUILD_ZLIB` | OFF* | Static build the zlib library<br>**Forced** to ON if `BUILD_DEPS=ON` |
| `BUILD_absl` | OFF* | Static build the abseil-cpp libraries<br>**Forced** to ON if `BUILD_DEPS=ON` |
| `BUILD_Protobuf` | OFF* | Static build the protobuf libraries<br>**Forced** to ON if `BUILD_DEPS=ON` |
| `BUILD_re2` | OFF* | Static build the re2 libraries<br>**Forced** to ON if `BUILD_DEPS=ON` |
| `BUILD_Eigen3` | OFF* | Static build the Eigen3 libraries<br>**Forced** to ON if `BUILD_DEPS=ON` |
| `BUILD_ZLIB` | OFF* | Build the zlib dynamic library<br>**Forced** to ON if `BUILD_DEPS=ON` |
| `BUILD_absl` | OFF* | Build the abseil-cpp dynamic libraries<br>**Forced** to ON if `BUILD_DEPS=ON` |
| `BUILD_Protobuf` | OFF* | Build the protobuf dynamic libraries<br>**Forced** to ON if `BUILD_DEPS=ON` |
| `BUILD_re2` | OFF* | Build the re2 dynamic libraries<br>**Forced** to ON if `BUILD_DEPS=ON` |
| `BUILD_Eigen3` | OFF* | Build the Eigen3 libraries<br>**Forced** to ON if `BUILD_DEPS=ON` |
| | | |
| `USE_COINOR` | ON\* | Enable Coin-OR support<br>**Forced** to OFF if `BUILD_CXX=OFF` |
| `BUILD_CoinUtils` | OFF\* | Static build the CoinUtils library<br>**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON` |
| `BUILD_Osi` | OFF\* | Static build the Osi library<br>**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON` |
| `BUILD_Clp` | OFF\* | Static build the Clp library<br>**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON` |
| `BUILD_Cgl` | OFF\* | Static build the Cgl library<br>**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON` |
| `BUILD_Cbc` | OFF\* | Static build the Cbc library<br>**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON` |
| `BUILD_CoinUtils` | OFF\* | Build the CoinUtils dynamic library<br>**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON` |
| `BUILD_Osi` | OFF\* | Build the Osi dynamic library<br>**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON` |
| `BUILD_Clp` | OFF\* | Build the Clp dynamic library<br>**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON` |
| `BUILD_Cgl` | OFF\* | Build the Cgl dynamic library<br>**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON` |
| `BUILD_Cbc` | OFF\* | Build the Cbc dynamic library<br>**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON` |
| | | |
| `USE_GLPK` | OFF\* | Enable GLPK support<br>**Forced** to OFF if `BUILD_CXX=OFF` |
| `BUILD_GLPK` | OFF\* | Static build the GLPK libraries<br>**Forced** to ON if `USE_GLPK=ON` **and** `BUILD_DEPS=ON` |
| `BUILD_GLPK` | OFF\* | Build the GLPK dynamic libraries<br>**Forced** to ON if `USE_GLPK=ON` **and** `BUILD_DEPS=ON` |
| | | |
| `USE_HIGHS` | ON\* | Enable HIGHS support<br>**Forced** to OFF if `BUILD_CXX=OFF` |
| `BUILD_HIGHS` | OFF\* | Static build the HiGHS libraries<br>**Forced** to ON if `USE_HIGHS=ON` **and** `BUILD_DEPS=ON` |
| `BUILD_HIGHS` | OFF\* | Build the HiGHS dynamic libraries<br>**Forced** to ON if `USE_HIGHS=ON` **and** `BUILD_DEPS=ON` |
| | | |
| `USE_SCIP` | ON\* | Enable SCIP support<br>**Forced** to OFF if `BUILD_CXX=OFF` |
| `BUILD_SCIP` | OFF\* | Static build the SCIP libraries<br>**Forced** to ON if `USE_SCIP=ON` **and** `BUILD_DEPS=ON` |
| `BUILD_SCIP` | OFF\* | Build the SCIP dynamic libraries<br>**Forced** to ON if `USE_SCIP=ON` **and** `BUILD_DEPS=ON` |
| | | |
| `USE_CPLEX` | OFF | Enable CPLEX support |
| | | |
@@ -255,6 +255,7 @@ cmake -S. -Bbuild -LH
| `BUILD_FAT_JAR` | OFF | Build a `ortools-java` .jar that includes all of its own Maven dependencies, including the native package<br>Only available if `BUILD_JAVA=ON` |
| | | |
| `BUILD_pybind11` | `BUILD_DEPS` | Static build the pybind11 libraries<br>**Forced** to ON if `BUILD_DEPS=ON`<br>Only available if `BUILD_PYTHON=ON` |
| `BUILD_pybind11_abseil` | `BUILD_DEPS` | Static build the pybind11_abseil libraries<br>**Forced** to ON if `BUILD_DEPS=ON`<br>Only available if `BUILD_PYTHON=ON` |
| `BUILD_pybind11_protobuf` | `BUILD_DEPS` | Static build the pybind11_protobuf libraries<br>**Forced** to ON if `BUILD_DEPS=ON`<br>Only available if `BUILD_PYTHON=ON` |
| `GENERATE_PYTHON_STUB` | ON | Generate python stub files<br>Only available if `BUILD_PYTHON=ON` |
| `BUILD_VENV` | `BUILD_TESTING` | Create python venv in `BINARY_DIR/python/venv`<br>**Forced** to ON if `BUILD_TESTING=ON`<br>Only available if `BUILD_PYTHON=ON` |

View File

@@ -62,12 +62,10 @@ if(NOT TARGET Eigen3::Eigen)
message(FATAL_ERROR "Target Eigen3::Eigen not available.")
endif()
if(BUILD_LP_PARSER OR BUILD_TESTING)
if(NOT TARGET re2::re2)
message(FATAL_ERROR "Target re2::re2 not available.")
endif()
set(RE2_DEPS re2::re2)
if(NOT TARGET re2::re2)
message(FATAL_ERROR "Target re2::re2 not available.")
endif()
set(RE2_DEPS re2::re2)
if(USE_COINOR)
if(NOT TARGET Coin::CbcSolver)
@@ -111,11 +109,6 @@ if(USE_SCIP)
set(SCIP_DEPS SCIP::libscip)
endif()
# Check optional Dependencies
if(USE_CPLEX AND NOT TARGET CPLEX::CPLEX)
message(FATAL_ERROR "Target CPLEX::CPLEX not available.")
endif()
# CXX Test
if(BUILD_TESTING)
if(NOT TARGET GTest::gtest_main)

View File

@@ -170,57 +170,56 @@ endif()
if(BUILD_PYTHON)
# Find Python 3
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
endif()
if(BUILD_PYTHON AND BUILD_pybind11)
message(CHECK_START "Fetching pybind11")
list(APPEND CMAKE_MESSAGE_INDENT " ")
set(PYBIND11_FINDPYTHON ON)
set(PYBIND11_INSTALL ON)
set(PYBIND11_TEST OFF)
FetchContent_Declare(
pybind11
GIT_REPOSITORY "https://github.com/pybind/pybind11.git"
GIT_TAG "v2.13.6"
GIT_SHALLOW TRUE
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/pybind11.patch"
)
FetchContent_MakeAvailable(pybind11)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()
if(BUILD_pybind11)
message(CHECK_START "Fetching pybind11")
list(APPEND CMAKE_MESSAGE_INDENT " ")
set(PYBIND11_FINDPYTHON ON)
set(PYBIND11_INSTALL ON)
set(PYBIND11_TEST OFF)
FetchContent_Declare(
pybind11
GIT_REPOSITORY "https://github.com/pybind/pybind11.git"
GIT_TAG "v2.13.6"
GIT_SHALLOW TRUE
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/pybind11.patch"
)
FetchContent_MakeAvailable(pybind11)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()
if(BUILD_PYTHON AND BUILD_pybind11_abseil)
message(CHECK_START "Fetching pybind11_abseil")
list(APPEND CMAKE_MESSAGE_INDENT " ")
FetchContent_Declare(
pybind11_abseil
GIT_REPOSITORY "https://github.com/pybind/pybind11_abseil.git" # 2024/01/11
GIT_TAG "v202402.0"
GIT_SHALLOW TRUE
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/pybind11_abseil.patch"
)
FetchContent_MakeAvailable(pybind11_abseil)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()
if(BUILD_pybind11_abseil)
message(CHECK_START "Fetching pybind11_abseil")
list(APPEND CMAKE_MESSAGE_INDENT " ")
FetchContent_Declare(
pybind11_abseil
GIT_REPOSITORY "https://github.com/pybind/pybind11_abseil.git" # 2024/01/11
GIT_TAG "v202402.0"
GIT_SHALLOW TRUE
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/pybind11_abseil.patch"
)
FetchContent_MakeAvailable(pybind11_abseil)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()
if(BUILD_PYTHON AND BUILD_pybind11_protobuf)
message(CHECK_START "Fetching pybind11_protobuf")
list(APPEND CMAKE_MESSAGE_INDENT " ")
FetchContent_Declare(
pybind11_protobuf
GIT_REPOSITORY "https://github.com/pybind/pybind11_protobuf.git"
GIT_TAG "84653a591aea5df482dc2bde42c19efafbd53a57" # 2024/06/28
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/pybind11_protobuf.patch"
#GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(pybind11_protobuf)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
if(BUILD_pybind11_protobuf)
message(CHECK_START "Fetching pybind11_protobuf")
list(APPEND CMAKE_MESSAGE_INDENT " ")
FetchContent_Declare(
pybind11_protobuf
GIT_REPOSITORY "https://github.com/pybind/pybind11_protobuf.git"
GIT_TAG "f02a2b7653bc50eb5119d125842a3870db95d251" # 2025/02/10
#PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/pybind11_protobuf.patch"
#GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(pybind11_protobuf)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()
endif()
# ##############################################################################
# GLPK
# ##############################################################################

View File

@@ -3,19 +3,13 @@ FROM ortools/cmake:opensuse_swig AS env
# .NET install
# see: https://docs.microsoft.com/en-us/dotnet/core/install/linux-opensuse
RUN zypper refresh \
&& zypper install -y wget tar gzip libicu-devel \
&& mkdir -p /usr/share/dotnet \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
&& zypper install -y wget tar awk gzip libicu-devel
## .Net 6.0
# see: https://dotnet.microsoft.com/download/dotnet-core/6.0
RUN dotnet_sdk_version=6.0.100 \
&& wget -qO dotnet.tar.gz \
"https://dotnetcli.azureedge.net/dotnet/Sdk/${dotnet_sdk_version}/dotnet-sdk-${dotnet_sdk_version}-linux-x64.tar.gz" \
&& dotnet_sha512='cb0d174a79d6294c302261b645dba6a479da8f7cf6c1fe15ae6998bc09c5e0baec810822f9e0104e84b0efd51fdc0333306cb2a0a6fcdbaf515a8ad8cf1af25b' \
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \
&& tar -C /usr/share/dotnet -oxzf dotnet.tar.gz \
&& rm dotnet.tar.gz
# see: https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#scripted-install
RUN wget -q "https://dot.net/v1/dotnet-install.sh" \
&& chmod a+x dotnet-install.sh \
&& ./dotnet-install.sh -c 6.0 -i /usr/local/bin
# Trigger first run experience by running arbitrary cmd
RUN dotnet --info

View File

@@ -2,10 +2,10 @@ FROM ortools/cmake:opensuse_swig AS env
ENV PATH=/root/.local/bin:$PATH
RUN zypper refresh \
&& zypper install -y python311 python311-devel \
python311-pip python311-wheel python311-virtualenv python311-setuptools \
&& zypper install -y python3 python3-devel \
python3-pip python3-wheel python3-virtualenv python3-setuptools \
&& zypper clean -a
RUN python3.11 -m pip install --break-system-packages \
RUN python3 -m pip install --break-system-packages \
absl-py mypy mypy-protobuf
FROM env AS devel

View File

@@ -1,7 +1,7 @@
@startdot
digraph CMakeDeps {
//rankdir=BT;
rankdir=TD;
rankdir=BT;
//rankdir=TD;
node [shape=box, style="rounded,filled", color=royalblue, fillcolor=royalblue];
subgraph clusterZLIB {
@@ -40,13 +40,6 @@ digraph CMakeDeps {
label = "libeigen/eigen.git";
}
subgraph clusterPybind11 {
Pybind11 [label="pybind11::pybind11"];
color=royalblue;
label = "pybind/pybind11.git";
}
subgraph clusterCoinOR {
subgraph clusterCoinUtils {
CoinUtils [label="Coin::CoinUtils"];
@@ -83,31 +76,31 @@ digraph CMakeDeps {
label = "Mizux/Cbc.git";
}
CoinUtils -> Osi;
Osi -> CoinUtils;
CoinUtils -> Clp;
Osi -> Clp;
Clp -> CoinUtils;
Clp -> Osi;
CoinUtils -> OsiClp;
Osi -> OsiClp;
Clp -> OsiClp;
OsiClp -> CoinUtils;
OsiClp -> Osi;
OsiClp -> Clp;
Clp -> ClpSolver;
ClpSolver -> Clp;
CoinUtils -> Cgl;
Osi -> Cgl;
OsiClp -> Cgl;
Cgl -> CoinUtils;
Cgl -> Osi;
Cgl -> OsiClp;
CoinUtils -> Cbc;
Osi -> Cbc;
Clp -> Cbc;
Cgl -> Cbc;
Cbc -> CoinUtils;
Cbc -> Osi;
Cbc -> Clp;
Cbc -> Cgl;
CoinUtils -> OsiCbc;
Osi -> OsiCbc;
Cbc -> OsiCbc;
OsiCbc -> CoinUtils;
OsiCbc -> Osi;
OsiCbc -> Cbc;
Cbc -> CbcSolver;
CbcSolver -> Cbc;
color=royalblue;
label = "-DUSE_COINOR=ON AND -DBUILD_DEPS=ON";
}
@@ -147,20 +140,81 @@ digraph CMakeDeps {
color=royalblue;
label = "scipopt/scip.git";
}
SPX -> SCIP;
SCIP -> SPX;
color=royalblue;
label = "-DUSE_SCIP=ON AND -DBUILD_SCIP=ON";
}
// Testing
subgraph clusterTesting {
subgraph clusterGTest {
gtest [label="GTest::gtest"];
color=royalblue;
label = "google/googletest.git";
}
subgraph clusterBenchmark {
bench [label="benchmark::benchmark"];
color=royalblue;
label = "google/benchmark.git";
}
subgraph clusterFuzzTest {
fuzz [label="fuzztest::fuzztest"];
color=royalblue;
label = "google/fuzztest.git";
}
fuzz -> gtest;
bench -> gtest;
color=royalblue;
label = "-DBUILD_TESTING=ON";
}
// Python
subgraph clusterPython {
subgraph clusterPybind11 {
Pybind11 [label="pybind11::pybind11"];
color=gold;
label = "pybind/pybind11.git";
}
subgraph clusterPybind11Absl {
Pybind11Absl [label="pybind11::pybind11_abseil"];
color=gold;
label = "pybind/pybind11_abseil.git";
}
subgraph clusterPybind11Protobuf {
Pybind11Protobuf [label="pybind11::pybind11_protobuf"];
color=gold;
label = "pybind/pybind11_protobuf.git";
}
Pybind11Absl -> Pybind11;
Pybind11Protobuf -> Pybind11;
color=gold;
label = "-DBUILD_PYTHON=ON";
}
// inter deps
ZLIB -> Protobuf;
ZLIB -> Cbc;
ZLIB -> SPX;
ZLIB -> SCIP;
Absl -> Re2;
Absl -> Protobuf;
Re2 -> Protobuf;
Protobuf -> ZLIB;
Cbc -> ZLIB;
SPX -> ZLIB;
SCIP -> ZLIB;
Re2 -> Absl;
Protobuf -> Absl;
gtest -> Absl;
fuzz -> Absl;
Pybind11Absl -> Absl;
fuzz -> Protobuf;
Pybind11Protobuf -> Protobuf;
Protobuf -> Re2;
gtest -> Re2;
fuzz -> Re2;
}
@enddot
# vim tw:0

View File

@@ -633,8 +633,6 @@ add_custom_command(
$<TARGET_FILE:init_pybind11> ${PYTHON_PROJECT}/init/python
COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:knapsack_solver_pybind11> ${PYTHON_PROJECT}/algorithms/python
COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:set_cover_pybind11> ${PYTHON_PROJECT}/algorithms/python
COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:linear_sum_assignment_pybind11> ${PYTHON_PROJECT}/graph/python
COMMAND ${CMAKE_COMMAND} -E copy

View File

@@ -22,91 +22,101 @@ find_package(Threads REQUIRED)
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
# libprotobuf force us to depends on ZLIB::ZLIB target
if(NOT BUILD_ZLIB)
if(NOT BUILD_ZLIB AND NOT TARGET ZLIB::ZLIB)
find_package(ZLIB REQUIRED)
endif()
if(NOT BUILD_absl)
if(NOT BUILD_absl AND NOT TARGET absl::base)
find_package(absl REQUIRED)
endif()
if(NOT BUILD_Protobuf)
if(NOT BUILD_Protobuf AND NOT TARGET protobuf::libprotobuf)
find_package(Protobuf REQUIRED)
endif()
if(NOT BUILD_Eigen3)
if(NOT BUILD_Eigen3 AND NOT TARGET Eigen3::Eigen)
find_package(Eigen3 REQUIRED)
endif()
if(BUILD_LP_PARSER OR BUILD_TESTING)
if(NOT BUILD_re2)
find_package(re2 REQUIRED)
endif()
if(NOT BUILD_re2 AND NOT TARGET re2::re2)
find_package(re2 REQUIRED)
endif()
# Third Party Solvers
if(USE_COINOR)
if(NOT BUILD_CoinUtils)
if(NOT BUILD_CoinUtils AND NOT TARGET Coin::CoinUtils)
find_package(CoinUtils REQUIRED)
endif()
if(NOT BUILD_Osi)
if(NOT BUILD_Osi AND NOT TARGET Coin::Osi)
find_package(Osi REQUIRED)
endif()
if(NOT BUILD_Clp)
if(NOT BUILD_Clp AND NOT TARGET Coin::ClpSolver)
find_package(Clp REQUIRED)
endif()
if(NOT BUILD_Cgl)
if(NOT BUILD_Cgl AND NOT TARGET Coin::Cgl)
find_package(Cgl REQUIRED)
endif()
if(NOT BUILD_Cbc)
if(NOT BUILD_Cbc AND NOT TARGET Coin::CbcSolver)
find_package(Cbc REQUIRED)
endif()
endif()
if(USE_GLPK AND NOT BUILD_GLPK)
find_package(GLPK REQUIRED)
endif()
if(USE_HIGHS AND NOT BUILD_HIGHS)
find_package(HIGHS REQUIRED)
endif()
if(USE_PDLP AND NOT BUILD_PDLP)
find_package(PDLP REQUIRED)
endif()
if(USE_SCIP AND NOT BUILD_SCIP)
find_package(SCIP REQUIRED)
endif()
# Check optional Dependencies
if(USE_CPLEX)
find_package(CPLEX REQUIRED)
if(NOT TARGET CPLEX::CPLEX)
find_package(CPLEX REQUIRED)
endif()
endif()
if(USE_GLPK)
if(NOT BUILD_GLPK AND NOT TARGET GLPK::GLPK)
find_package(GLPK REQUIRED)
endif()
endif()
if(USE_HIGHS)
if(NOT BUILD_HIGHS AND NOT TARGET highs::highs)
find_package(HIGHS REQUIRED)
endif()
endif()
if(USE_PDLP)
if(NOT BUILD_PDLP)
find_package(PDLP REQUIRED)
endif()
endif()
if(USE_SCIP)
if(NOT BUILD_SCIP AND NOT TARGET SCIP::libscip)
find_package(SCIP REQUIRED)
endif()
endif()
# CXX Test
if(BUILD_TESTING AND NOT BUILD_googletest)
find_package(GTest REQUIRED)
endif()
if(BUILD_TESTING)
if(NOT BUILD_googletest AND NOT TARGET GTest::gtest_main)
find_package(GTest REQUIRED)
endif()
if(BUILD_TESTING AND NOT BUILD_benchmark)
find_package(benchmark REQUIRED)
if(NOT BUILD_benchmark AND NOT TARGET benchmark::benchmark)
find_package(benchmark REQUIRED)
endif()
endif()
# Check language Dependencies
if(BUILD_PYTHON)
if(NOT BUILD_pybind11)
if(NOT BUILD_pybind11 AND NOT TARGET pybind11::pybind11_headers)
find_package(pybind11 REQUIRED)
endif()
if(NOT BUILD_pybind11_abseil)
if(NOT BUILD_pybind11_abseil AND NOT TARGET pybind11_abseil::absl_casters)
find_package(pybind11_abseil REQUIRED)
endif()
if(NOT BUILD_pybind11_protobuf)
if(NOT BUILD_pybind11_protobuf AND NOT TARGET pybind11_native_proto_caster)
find_package(pybind11_protobuf REQUIRED)
endif()
endif()