cmake: move set cmd after FetchContent_Declare

note: they will be use by FetchContent_MakeAvailable
This commit is contained in:
Corentin Le Molgat
2025-10-16 10:07:03 +02:00
parent 0814f8f29f
commit 2adf929a73
2 changed files with 41 additions and 42 deletions

View File

@@ -63,7 +63,6 @@ set(CMAKE_Fortran_COMPILER OFF)
if(BUILD_ZLIB)
message(CHECK_START "Fetching ZLIB")
list(APPEND CMAKE_MESSAGE_INDENT " ")
set(ZLIB_BUILD_EXAMPLES OFF)
FetchContent_Declare(
ZLIB
GIT_REPOSITORY "https://github.com/madler/ZLIB.git"
@@ -73,6 +72,7 @@ if(BUILD_ZLIB)
PATCH_COMMAND git apply --ignore-whitespace
"${CMAKE_CURRENT_LIST_DIR}/../../patches/ZLIB-v1.3.1.patch"
)
set(ZLIB_BUILD_EXAMPLES OFF)
FetchContent_MakeAvailable(ZLIB)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
@@ -84,8 +84,6 @@ endif()
if(BUILD_BZip2)
message(CHECK_START "Fetching BZip2")
list(APPEND CMAKE_MESSAGE_INDENT " ")
set(ENABLE_LIB_ONLY ON)
set(ENABLE_TESTS OFF)
FetchContent_Declare(
BZip2
GIT_REPOSITORY "https://gitlab.com/bzip2/bzip2.git"
@@ -96,6 +94,8 @@ if(BUILD_BZip2)
PATCH_COMMAND git apply --ignore-whitespace
"${CMAKE_CURRENT_LIST_DIR}/../../patches/bzip2.patch"
)
set(ENABLE_LIB_ONLY ON)
set(ENABLE_TESTS OFF)
FetchContent_MakeAvailable(BZip2)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
@@ -107,16 +107,6 @@ endif()
if(BUILD_absl)
message(CHECK_START "Fetching Abseil-cpp")
list(APPEND CMAKE_MESSAGE_INDENT " ")
set(ABSL_USE_SYSTEM_INCLUDES ON)
# We want Abseil to declare what C++ standard it was compiled with.
set(ABSL_PROPAGATE_CXX_STD ON)
set(ABSL_BUILD_TEST_HELPERS ON)
set(ABSL_USE_EXTERNAL_GOOGLETEST ON)
set(ABSL_FIND_GOOGLETEST OFF)
# We want Abseil to keep the INSTALL rules enabled, even though it is a
# subproject. Otherwise the install rules in this project break.
set(ABSL_ENABLE_INSTALL ON)
set(ABSL_BUILD_TESTING OFF)
FetchContent_Declare(
absl
GIT_REPOSITORY "https://github.com/abseil/abseil-cpp.git"
@@ -127,6 +117,16 @@ if(BUILD_absl)
"${CMAKE_CURRENT_LIST_DIR}/../../patches/abseil-cpp-20250814.1.patch"
OVERRIDE_FIND_PACKAGE
)
set(ABSL_USE_SYSTEM_INCLUDES ON)
# We want Abseil to declare what C++ standard it was compiled with.
set(ABSL_PROPAGATE_CXX_STD ON)
set(ABSL_BUILD_TEST_HELPERS ON)
set(ABSL_USE_EXTERNAL_GOOGLETEST ON)
set(ABSL_FIND_GOOGLETEST OFF)
# We want Abseil to keep the INSTALL rules enabled, even though it is a
# subproject. Otherwise the install rules in this project break.
set(ABSL_ENABLE_INSTALL ON)
set(ABSL_BUILD_TESTING OFF)
FetchContent_MakeAvailable(absl)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
@@ -138,11 +138,6 @@ endif()
if(BUILD_Protobuf)
message(CHECK_START "Fetching Protobuf")
list(APPEND CMAKE_MESSAGE_INDENT " ")
set(protobuf_BUILD_TESTS OFF)
set(protobuf_BUILD_SHARED_LIBS ON)
set(protobuf_BUILD_EXPORT OFF)
set(protobuf_MSVC_STATIC_RUNTIME OFF)
#set(protobuf_BUILD_LIBUPB ON)
FetchContent_Declare(
Protobuf
GIT_REPOSITORY "https://github.com/protocolbuffers/protobuf.git"
@@ -154,6 +149,11 @@ if(BUILD_Protobuf)
"${CMAKE_CURRENT_LIST_DIR}/../../patches/protobuf-v32.0.patch"
OVERRIDE_FIND_PACKAGE # Make package visible for "protobuf-matchers" below
)
set(protobuf_BUILD_TESTS OFF)
set(protobuf_BUILD_SHARED_LIBS ON)
set(protobuf_BUILD_EXPORT OFF)
set(protobuf_MSVC_STATIC_RUNTIME OFF)
#set(protobuf_BUILD_LIBUPB ON)
FetchContent_MakeAvailable(Protobuf)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
@@ -165,7 +165,6 @@ endif()
if(BUILD_re2)
message(CHECK_START "Fetching re2")
list(APPEND CMAKE_MESSAGE_INDENT " ")
set(RE2_BUILD_TESTING OFF)
FetchContent_Declare(
re2
GIT_REPOSITORY "https://github.com/google/re2.git"
@@ -175,6 +174,7 @@ if(BUILD_re2)
PATCH_COMMAND git apply --ignore-whitespace
"${CMAKE_CURRENT_LIST_DIR}/../../patches/re2-2024-07-02.patch"
)
set(RE2_BUILD_TESTING OFF)
FetchContent_MakeAvailable(re2)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
@@ -186,10 +186,6 @@ endif()
if(BUILD_Eigen3)
message(CHECK_START "Fetching Eigen3")
list(APPEND CMAKE_MESSAGE_INDENT " ")
set(EIGEN_MPL2_ONLY ON)
set(EIGEN_BUILD_PKGCONFIG OFF)
set(EIGEN_BUILD_DOC OFF)
set(EIGEN_BUILD_TESTING OFF)
FetchContent_Declare(
eigen3
GIT_REPOSITORY "https://gitlab.com/libeigen/eigen.git"
@@ -199,6 +195,10 @@ if(BUILD_Eigen3)
PATCH_COMMAND git apply --ignore-whitespace
"${CMAKE_CURRENT_LIST_DIR}/../../patches/eigen3-3.4.0.patch"
)
set(EIGEN_MPL2_ONLY ON)
set(EIGEN_BUILD_PKGCONFIG OFF)
set(EIGEN_BUILD_DOC OFF)
set(EIGEN_BUILD_TESTING OFF)
FetchContent_MakeAvailable(eigen3)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
@@ -215,9 +215,6 @@ if(BUILD_PYTHON)
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"
@@ -233,6 +230,9 @@ if(BUILD_PYTHON)
PATCH_COMMAND git apply --ignore-whitespace
"${CMAKE_CURRENT_LIST_DIR}/../../patches/pybind11-v2.13.6.patch"
)
set(PYBIND11_FINDPYTHON ON)
set(PYBIND11_INSTALL ON)
set(PYBIND11_TEST OFF)
FetchContent_MakeAvailable(pybind11)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
@@ -279,17 +279,16 @@ endif()
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.1"
GIT_SHALLOW TRUE
)
set(BUILD_EXAMPLES OFF)
set(WITH_GMP OFF)
set(WITH_ODBC OFF)
set(WITH_MYSQL OFF)
FetchContent_MakeAvailable(glpk)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
@@ -301,8 +300,6 @@ endif()
if(BUILD_HIGHS)
message(CHECK_START "Fetching HiGHS")
list(APPEND CMAKE_MESSAGE_INDENT " ")
set(CI OFF) # disable CI tests
set(BUILD_EXAMPLES OFF)
FetchContent_Declare(
highs
GIT_REPOSITORY "https://github.com/ERGO-Code/HiGHS.git"
@@ -312,6 +309,8 @@ if(BUILD_HIGHS)
PATCH_COMMAND git apply --ignore-whitespace
"${CMAKE_CURRENT_LIST_DIR}/../../patches/highs-v1.11.0.patch"
)
set(CI OFF) # disable CI tests
set(BUILD_EXAMPLES OFF)
FetchContent_MakeAvailable(highs)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")

View File

@@ -99,10 +99,6 @@ set(BUILD_TESTING OFF)
message(CHECK_START "Fetching Abseil-cpp")
list(APPEND CMAKE_MESSAGE_INDENT " ")
set(ABSL_ENABLE_INSTALL ON)
set(ABSL_USE_SYSTEM_INCLUDES ON)
set(ABSL_PROPAGATE_CXX_STD ON)
set(ABSL_BUILD_TESTING OFF)
FetchContent_Declare(
absl
GIT_REPOSITORY "https://github.com/abseil/abseil-cpp.git"
@@ -111,17 +107,16 @@ FetchContent_Declare(
PATCH_COMMAND git apply --ignore-whitespace
"${CMAKE_CURRENT_LIST_DIR}/@PATCHES_PATH@/abseil-cpp-20250814.1.patch"
)
set(ABSL_USE_SYSTEM_INCLUDES ON)
set(ABSL_PROPAGATE_CXX_STD ON)
set(ABSL_ENABLE_INSTALL ON)
set(ABSL_BUILD_TESTING OFF)
FetchContent_MakeAvailable(absl)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
message(CHECK_START "Fetching Protobuf")
list(APPEND CMAKE_MESSAGE_INDENT " ")
set(protobuf_BUILD_TESTS OFF)
set(protobuf_BUILD_SHARED_LIBS ON)
set(protobuf_BUILD_EXPORT OFF)
set(protobuf_MSVC_STATIC_RUNTIME OFF)
set(protobuf_WITH_ZLIB OFF)
FetchContent_Declare(
protobuf
GIT_REPOSITORY "https://github.com/protocolbuffers/protobuf.git"
@@ -131,6 +126,11 @@ FetchContent_Declare(
PATCH_COMMAND git apply --ignore-whitespace
"${CMAKE_CURRENT_LIST_DIR}/@PATCHES_PATH@/protobuf-v32.0.patch"
)
set(protobuf_BUILD_TESTS OFF)
set(protobuf_BUILD_SHARED_LIBS ON)
set(protobuf_BUILD_EXPORT OFF)
set(protobuf_MSVC_STATIC_RUNTIME OFF)
set(protobuf_WITH_ZLIB OFF)
FetchContent_MakeAvailable(protobuf)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")