From 1b258867cb05e1c6bcea4831f3b4984a291d21df Mon Sep 17 00:00:00 2001 From: reneSchm <49305466+reneSchm@users.noreply.github.com> Date: Wed, 8 Apr 2026 01:46:59 +0200 Subject: [PATCH 1/6] replace FetchContent_Populate by FetchContent_MakeAvailable (requiring cmake 3.14+), remove some outdated or unused cmake --- cpp/CMakeLists.txt | 2 +- cpp/benchmarks/CMakeLists.txt | 11 ++-- cpp/tests/cmake/AddGoogleTest.cmake | 65 +++++------------------- cpp/thirdparty/CMakeLists.txt | 61 +++++++--------------- pycode/memilio-simulation/CMakeLists.txt | 10 ++-- 5 files changed, 36 insertions(+), 113 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 9b6715b3fa..d3e131cf88 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.14) project(memilio VERSION 1.0.0) diff --git a/cpp/benchmarks/CMakeLists.txt b/cpp/benchmarks/CMakeLists.txt index 731fe8d566..d5089cd9a8 100755 --- a/cpp/benchmarks/CMakeLists.txt +++ b/cpp/benchmarks/CMakeLists.txt @@ -5,18 +5,13 @@ set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "Don't install benchmark" FORCE) set(BENCHMARK_DOWNLOAD_DEPENDENCIES OFF CACHE BOOL "Don't download dependencies" FORCE) set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "Disable Google Test in benchmark" FORCE) +message(STATUS "Downloading GoogleBenchmark library") include(FetchContent) FetchContent_Declare(benchmark + SOURCE_SUBDIR this_directory_name_does_not_exist GIT_REPOSITORY https://github.com/google/benchmark.git GIT_TAG v1.6.1) -FetchContent_GetProperties(benchmark) - -if(NOT benchmark_POPULATED) - FetchContent_Populate(benchmark) - set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS 1 CACHE BOOL "") - add_subdirectory(${benchmark_SOURCE_DIR} ${benchmark_BINARY_DIR} EXCLUDE_FROM_ALL) - unset(CMAKE_SUPPRESS_DEVELOPER_WARNINGS) -endif() +FetchContent_MakeAvailable(benchmark) set_target_properties(benchmark PROPERTIES FOLDER "Extern") diff --git a/cpp/tests/cmake/AddGoogleTest.cmake b/cpp/tests/cmake/AddGoogleTest.cmake index 3950421c12..f0241df8d2 100644 --- a/cpp/tests/cmake/AddGoogleTest.cmake +++ b/cpp/tests/cmake/AddGoogleTest.cmake @@ -6,35 +6,12 @@ # set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) -if(CMAKE_VERSION VERSION_LESS 3.11) - set(UPDATE_DISCONNECTED_IF_AVAILABLE "UPDATE_DISCONNECTED 1") - - include(DownloadProject) - download_project(PROJ googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG v1.16.0 - UPDATE_DISCONNECTED 1 - QUIET - ) - - # CMake warning suppression will not be needed in version 1.9 - set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS 1 CACHE BOOL "") - add_subdirectory(${googletest_SOURCE_DIR} ${googletest_SOURCE_DIR} EXCLUDE_FROM_ALL) - unset(CMAKE_SUPPRESS_DEVELOPER_WARNINGS) -else() - include(FetchContent) - FetchContent_Declare(googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG v1.16.0) - FetchContent_GetProperties(googletest) - - if(NOT googletest_POPULATED) - FetchContent_Populate(googletest) - set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS 1 CACHE BOOL "") - add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} EXCLUDE_FROM_ALL) - unset(CMAKE_SUPPRESS_DEVELOPER_WARNINGS) - endif() -endif() +message(STATUS "Downloading GoogleTest library") +include(FetchContent) +FetchContent_Declare(googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG v1.16.0) +FetchContent_MakeAvailable(googletest) if(CMAKE_CONFIGURATION_TYPES) add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} @@ -47,34 +24,16 @@ endif() set_target_properties(check PROPERTIES FOLDER "Scripts") -# include_directories(${gtest_SOURCE_DIR}/include) - -# More modern way to do the last line, less messy but needs newish CMake: -# target_include_directories(gtest INTERFACE ${gtest_SOURCE_DIR}/include) -if(GOOGLE_TEST_INDIVIDUAL) - if(NOT CMAKE_VERSION VERSION_LESS 3.9) - include(GoogleTest) - else() - set(GOOGLE_TEST_INDIVIDUAL OFF) - endif() -endif() - # Target must already exist macro(add_gtest TESTNAME) target_link_libraries(${TESTNAME} PUBLIC gtest gmock gtest_main) - if(GOOGLE_TEST_INDIVIDUAL) - if(CMAKE_VERSION VERSION_LESS 3.10) - gtest_add_tests(TARGET ${TESTNAME} - TEST_PREFIX "${TESTNAME}." - TEST_LIST TmpTestList) - set_tests_properties(${TmpTestList} PROPERTIES FOLDER "Tests") - else() - gtest_discover_tests(${TESTNAME} - TEST_PREFIX "${TESTNAME}." - PROPERTIES FOLDER "Tests" - DISCOVERY_TIMEOUT 30) - endif() + if(GOOGLE_TEST_INDIVIDUAL) + include(GoogleTest) + gtest_discover_tests(${TESTNAME} + TEST_PREFIX "${TESTNAME}." + PROPERTIES FOLDER "Tests" + DISCOVERY_TIMEOUT 30) else() add_test(${TESTNAME} ${TESTNAME}) set_target_properties(${TESTNAME} PROPERTIES FOLDER "Tests") diff --git a/cpp/thirdparty/CMakeLists.txt b/cpp/thirdparty/CMakeLists.txt index 2ea8cb8dd2..72abaa1f67 100644 --- a/cpp/thirdparty/CMakeLists.txt +++ b/cpp/thirdparty/CMakeLists.txt @@ -33,13 +33,7 @@ if(MEMILIO_USE_BUNDLED_SPDLOG) GIT_REPOSITORY https://github.com/gabime/spdlog.git GIT_TAG v${MEMILIO_SPDLOG_VERSION} ) - FetchContent_GetProperties(spdlog) - - if(NOT spdlog_POPULATED) - FetchContent_Populate(spdlog) - - add_subdirectory(${spdlog_SOURCE_DIR} ${spdlog_BINARY_DIR} EXCLUDE_FROM_ALL) - endif() + FetchContent_MakeAvailable(spdlog) else() find_package(spdlog REQUIRED) @@ -50,14 +44,14 @@ if(MEMILIO_USE_BUNDLED_EIGEN) message(STATUS "Downloading Eigen library") include(FetchContent) + # Set SOURCE_SUBDIR to prevent MakeAvailable from calling add_subdirectory. We do not want to run Eigen's + # CMakeLists.txt, as it is not set up to be used like that. Instead, we need to manually add a library with the + # source files below (this is sufficient, as Eigen is a header-only library) FetchContent_Declare(eigen + SOURCE_SUBDIR this_directory_name_does_not_exist GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git GIT_TAG ${MEMILIO_EIGEN_VERSION}) - FetchContent_GetProperties(eigen) - - if(NOT eigen_POPULATED) - FetchContent_Populate(eigen) - endif() + FetchContent_MakeAvailable(eigen) add_library(eigen INTERFACE) target_include_directories(eigen SYSTEM INTERFACE ${eigen_SOURCE_DIR}) @@ -86,15 +80,10 @@ if(MEMILIO_USE_BUNDLED_BOOST) include(FetchContent) FetchContent_Declare(boost - # don't use the URL from github, that download isn't complete and requires more setup (subrepositories, bootstrapping) URL https://archives.boost.io/release/${MEMILIO_BOOST_VERSION}/source/boost_${MEMILIO_BOOST_VERSION_UNDERSC}.tar.gz ) - FetchContent_GetProperties(boost) - - if(NOT boost_POPULATED) - FetchContent_Populate(boost) - endif() + FetchContent_MakeAvailable(boost) add_library(boost INTERFACE) add_dependencies(boost boost-bootstrap) @@ -157,31 +146,21 @@ endif() # ## JSONCPP if(MEMILIO_USE_BUNDLED_JSONCPP) - message(STATUS "Downloading jsoncpp library") + message(STATUS "Downloading JsonCpp library") + + # set jsoncpp configurations + set(JSONCPP_WITH_TESTS OFF) + set(JSONCPP_WITH_POST_BUILD_UNITTEST OFF) include(FetchContent) FetchContent_Declare( jsoncpp URL https://github.com/open-source-parsers/jsoncpp/archive/${MEMILIO_JSONCPP_VERSION}.tar.gz ) - FetchContent_GetProperties(jsoncpp) - - if(NOT jsoncpp_POPULATED) - FetchContent_Populate(jsoncpp) + FetchContent_MakeAvailable(jsoncpp) - # set jsoncpp configurations - set(JSONCPP_WITH_TESTS "Compile and (for jsoncpp_check) run JsonCpp test executables" OFF) - set(JSONCPP_WITH_POST_BUILD_UNITTEST "Automatically run unit-tests as a post build step" ON) - - add_subdirectory(${jsoncpp_SOURCE_DIR} ${jsoncpp_BINARY_DIR} EXCLUDE_FROM_ALL) - - # unset global cache variables to avoid clashes with our code - unset(BUILD_OBJECT_LIBS CACHE) - unset(CMAKE_ARCHIVE_OUTPUT_DIRECTORY CACHE) - unset(CMAKE_ARCHIVE_OUTPUT_DIRECTORY CACHE) - unset(CMAKE_PDB_OUTPUT_DIRECTORY CACHE) - unset(CMAKE_RUNTIME_OUTPUT_DIRECTORY CACHE) - endif() + # unset global cache variables to avoid clashes with our code + unset(BUILD_OBJECT_LIBS CACHE) if(BUILD_SHARED_LIBS) add_library(JsonCpp::JsonCpp ALIAS jsoncpp_lib) @@ -222,14 +201,8 @@ message(STATUS "Downloading Random123 library") include(FetchContent) FetchContent_Declare(Random123 GIT_REPOSITORY https://github.com/DEShawResearch/random123 - GIT_TAG ${MEMILIO_RANDOM123_VERSION} - CONFIGURE_COMMAND "" - BUILD_COMMAND "") -FetchContent_GetProperties(Random123) - -if(NOT Random123_POPULATED) - FetchContent_Populate(Random123) -endif() + GIT_TAG ${MEMILIO_RANDOM123_VERSION}) +FetchContent_MakeAvailable(Random123) add_library(Random123 INTERFACE) target_include_directories(Random123 INTERFACE ${random123_SOURCE_DIR}/include) diff --git a/pycode/memilio-simulation/CMakeLists.txt b/pycode/memilio-simulation/CMakeLists.txt index f54390d920..e7bc5a8f20 100644 --- a/pycode/memilio-simulation/CMakeLists.txt +++ b/pycode/memilio-simulation/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.14) project(memilio-python) set(CMAKE_CXX_STANDARD "20") @@ -36,18 +36,14 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) set(SPDLOG_BUILD_SHARED OFF CACHE BOOL "" FORCE) if(MEMILIO_USE_BUNDLED_PYBIND11) + message(STATUS "Downloading pybind11 library") # Fetch pybind11 include(FetchContent) FetchContent_Declare(pybind11 GIT_REPOSITORY https://github.com/pybind/pybind11 GIT_TAG v3.0.0 ) - FetchContent_GetProperties(pybind11) - - if(NOT pybind11_POPULATED) - FetchContent_Populate(pybind11) - add_subdirectory(${pybind11_SOURCE_DIR} ${pybind11_BINARY_DIR}) - endif() + FetchContent_MakeAvailable(pybind11) else() find_package(pybind11 REQUIRED) endif() From 5b2bc8b7e3c8f2360cb5b09c966bbf271bd029f2 Mon Sep 17 00:00:00 2001 From: reneSchm <49305466+reneSchm@users.noreply.github.com> Date: Wed, 8 Apr 2026 01:47:16 +0200 Subject: [PATCH 2/6] remove unused cmake files --- cpp/cmake/DownloadProject.CMakeLists.cmake.in | 17 -- cpp/cmake/DownloadProject.cmake | 164 ------------------ cpp/cmake/FindSphinx.cmake | 11 -- .../cmake/DownloadProject.CMakeLists.cmake.in | 17 -- cpp/tests/cmake/DownloadProject.cmake | 164 ------------------ 5 files changed, 373 deletions(-) delete mode 100644 cpp/cmake/DownloadProject.CMakeLists.cmake.in delete mode 100644 cpp/cmake/DownloadProject.cmake delete mode 100644 cpp/cmake/FindSphinx.cmake delete mode 100644 cpp/tests/cmake/DownloadProject.CMakeLists.cmake.in delete mode 100644 cpp/tests/cmake/DownloadProject.cmake diff --git a/cpp/cmake/DownloadProject.CMakeLists.cmake.in b/cpp/cmake/DownloadProject.CMakeLists.cmake.in deleted file mode 100644 index 49a8887380..0000000000 --- a/cpp/cmake/DownloadProject.CMakeLists.cmake.in +++ /dev/null @@ -1,17 +0,0 @@ -# Distributed under the OSI-approved MIT License. See accompanying -# file LICENSE or https://github.com/Crascit/DownloadProject for details. - -cmake_minimum_required(VERSION 2.8.2) - -project(${DL_ARGS_PROJ}-download NONE) - -include(ExternalProject) -ExternalProject_Add(${DL_ARGS_PROJ}-download - ${DL_ARGS_UNPARSED_ARGUMENTS} - SOURCE_DIR "${DL_ARGS_SOURCE_DIR}" - BINARY_DIR "${DL_ARGS_BINARY_DIR}" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" -) diff --git a/cpp/cmake/DownloadProject.cmake b/cpp/cmake/DownloadProject.cmake deleted file mode 100644 index 76aaa01f67..0000000000 --- a/cpp/cmake/DownloadProject.cmake +++ /dev/null @@ -1,164 +0,0 @@ -# Distributed under the OSI-approved MIT License. See accompanying -# file LICENSE or https://github.com/Crascit/DownloadProject for details. -# -# MODULE: DownloadProject -# -# PROVIDES: -# download_project( PROJ projectName -# [PREFIX prefixDir] -# [DOWNLOAD_DIR downloadDir] -# [SOURCE_DIR srcDir] -# [BINARY_DIR binDir] -# [QUIET] -# ... -# ) -# -# Provides the ability to download and unpack a tarball, zip file, git repository, -# etc. at configure time (i.e. when the cmake command is run). How the downloaded -# and unpacked contents are used is up to the caller, but the motivating case is -# to download source code which can then be included directly in the build with -# add_subdirectory() after the call to download_project(). Source and build -# directories are set up with this in mind. -# -# The PROJ argument is required. The projectName value will be used to construct -# the following variables upon exit (obviously replace projectName with its actual -# value): -# -# projectName_SOURCE_DIR -# projectName_BINARY_DIR -# -# The SOURCE_DIR and BINARY_DIR arguments are optional and would not typically -# need to be provided. They can be specified if you want the downloaded source -# and build directories to be located in a specific place. The contents of -# projectName_SOURCE_DIR and projectName_BINARY_DIR will be populated with the -# locations used whether you provide SOURCE_DIR/BINARY_DIR or not. -# -# The DOWNLOAD_DIR argument does not normally need to be set. It controls the -# location of the temporary CMake build used to perform the download. -# -# The PREFIX argument can be provided to change the base location of the default -# values of DOWNLOAD_DIR, SOURCE_DIR and BINARY_DIR. If all of those three arguments -# are provided, then PREFIX will have no effect. The default value for PREFIX is -# CMAKE_BINARY_DIR. -# -# The QUIET option can be given if you do not want to show the output associated -# with downloading the specified project. -# -# In addition to the above, any other options are passed through unmodified to -# ExternalProject_Add() to perform the actual download, patch and update steps. -# The following ExternalProject_Add() options are explicitly prohibited (they -# are reserved for use by the download_project() command): -# -# CONFIGURE_COMMAND -# BUILD_COMMAND -# INSTALL_COMMAND -# TEST_COMMAND -# -# Only those ExternalProject_Add() arguments which relate to downloading, patching -# and updating of the project sources are intended to be used. Also note that at -# least one set of download-related arguments are required. -# -# If using CMake 3.2 or later, the UPDATE_DISCONNECTED option can be used to -# prevent a check at the remote end for changes every time CMake is run -# after the first successful download. See the documentation of the ExternalProject -# module for more information. It is likely you will want to use this option if it -# is available to you. Note, however, that the ExternalProject implementation contains -# bugs which result in incorrect handling of the UPDATE_DISCONNECTED option when -# using the URL download method or when specifying a SOURCE_DIR with no download -# method. Fixes for these have been created, the last of which is scheduled for -# inclusion in CMake 3.8.0. Details can be found here: -# -# https://gitlab.kitware.com/cmake/cmake/commit/bdca68388bd57f8302d3c1d83d691034b7ffa70c -# https://gitlab.kitware.com/cmake/cmake/issues/16428 -# -# If you experience build errors related to the update step, consider avoiding -# the use of UPDATE_DISCONNECTED. -# -# EXAMPLE USAGE: -# -# include(DownloadProject) -# download_project(PROJ googletest -# GIT_REPOSITORY https://github.com/google/googletest.git -# GIT_TAG master -# UPDATE_DISCONNECTED 1 -# QUIET -# ) -# -# add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) -# -#======================================================================================== - - -set(_DownloadProjectDir "${CMAKE_CURRENT_LIST_DIR}") - -include(CMakeParseArguments) - -function(download_project) - - set(options QUIET) - set(oneValueArgs - PROJ - PREFIX - DOWNLOAD_DIR - SOURCE_DIR - BINARY_DIR - # Prevent the following from being passed through - CONFIGURE_COMMAND - BUILD_COMMAND - INSTALL_COMMAND - TEST_COMMAND - ) - set(multiValueArgs "") - - cmake_parse_arguments(DL_ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - # Hide output if requested - if (DL_ARGS_QUIET) - set(OUTPUT_QUIET "OUTPUT_QUIET") - else() - unset(OUTPUT_QUIET) - message(STATUS "Downloading/updating ${DL_ARGS_PROJ}") - endif() - - # Set up where we will put our temporary CMakeLists.txt file and also - # the base point below which the default source and binary dirs will be - if (NOT DL_ARGS_PREFIX) - set(DL_ARGS_PREFIX "${CMAKE_BINARY_DIR}") - endif() - if (NOT DL_ARGS_DOWNLOAD_DIR) - set(DL_ARGS_DOWNLOAD_DIR "${DL_ARGS_PREFIX}/${DL_ARGS_PROJ}-download") - endif() - - # Ensure the caller can know where to find the source and build directories - if (NOT DL_ARGS_SOURCE_DIR) - set(DL_ARGS_SOURCE_DIR "${DL_ARGS_PREFIX}/${DL_ARGS_PROJ}-src") - endif() - if (NOT DL_ARGS_BINARY_DIR) - set(DL_ARGS_BINARY_DIR "${DL_ARGS_PREFIX}/${DL_ARGS_PROJ}-build") - endif() - set(${DL_ARGS_PROJ}_SOURCE_DIR "${DL_ARGS_SOURCE_DIR}" PARENT_SCOPE) - set(${DL_ARGS_PROJ}_BINARY_DIR "${DL_ARGS_BINARY_DIR}" PARENT_SCOPE) - - # Create and build a separate CMake project to carry out the download. - # If we've already previously done these steps, they will not cause - # anything to be updated, so extra rebuilds of the project won't occur. - configure_file("${_DownloadProjectDir}/DownloadProject.CMakeLists.cmake.in" - "${DL_ARGS_DOWNLOAD_DIR}/CMakeLists.txt") - execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - RESULT_VARIABLE result - ${OUTPUT_QUIET} - WORKING_DIRECTORY "${DL_ARGS_DOWNLOAD_DIR}" - ) - if(result) - message(FATAL_ERROR "CMake step for ${DL_ARGS_PROJ} failed: ${result}") - endif() - execute_process(COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE result - ${OUTPUT_QUIET} - WORKING_DIRECTORY "${DL_ARGS_DOWNLOAD_DIR}" - ) - if(result) - message(FATAL_ERROR "Build step for ${DL_ARGS_PROJ} failed: ${result}") - endif() - -endfunction() diff --git a/cpp/cmake/FindSphinx.cmake b/cpp/cmake/FindSphinx.cmake deleted file mode 100644 index 24e0d072c1..0000000000 --- a/cpp/cmake/FindSphinx.cmake +++ /dev/null @@ -1,11 +0,0 @@ -#Look for an executable called sphinx-build -find_program(SPHINX_EXECUTABLE - NAMES sphinx-build - DOC "Path to sphinx-build executable") - -include(FindPackageHandleStandardArgs) - -#Handle standard arguments to find_package like REQUIRED and QUIET -find_package_handle_standard_args(Sphinx - "Failed to find sphinx-build executable" - SPHINX_EXECUTABLE) diff --git a/cpp/tests/cmake/DownloadProject.CMakeLists.cmake.in b/cpp/tests/cmake/DownloadProject.CMakeLists.cmake.in deleted file mode 100644 index 49a8887380..0000000000 --- a/cpp/tests/cmake/DownloadProject.CMakeLists.cmake.in +++ /dev/null @@ -1,17 +0,0 @@ -# Distributed under the OSI-approved MIT License. See accompanying -# file LICENSE or https://github.com/Crascit/DownloadProject for details. - -cmake_minimum_required(VERSION 2.8.2) - -project(${DL_ARGS_PROJ}-download NONE) - -include(ExternalProject) -ExternalProject_Add(${DL_ARGS_PROJ}-download - ${DL_ARGS_UNPARSED_ARGUMENTS} - SOURCE_DIR "${DL_ARGS_SOURCE_DIR}" - BINARY_DIR "${DL_ARGS_BINARY_DIR}" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" -) diff --git a/cpp/tests/cmake/DownloadProject.cmake b/cpp/tests/cmake/DownloadProject.cmake deleted file mode 100644 index 76aaa01f67..0000000000 --- a/cpp/tests/cmake/DownloadProject.cmake +++ /dev/null @@ -1,164 +0,0 @@ -# Distributed under the OSI-approved MIT License. See accompanying -# file LICENSE or https://github.com/Crascit/DownloadProject for details. -# -# MODULE: DownloadProject -# -# PROVIDES: -# download_project( PROJ projectName -# [PREFIX prefixDir] -# [DOWNLOAD_DIR downloadDir] -# [SOURCE_DIR srcDir] -# [BINARY_DIR binDir] -# [QUIET] -# ... -# ) -# -# Provides the ability to download and unpack a tarball, zip file, git repository, -# etc. at configure time (i.e. when the cmake command is run). How the downloaded -# and unpacked contents are used is up to the caller, but the motivating case is -# to download source code which can then be included directly in the build with -# add_subdirectory() after the call to download_project(). Source and build -# directories are set up with this in mind. -# -# The PROJ argument is required. The projectName value will be used to construct -# the following variables upon exit (obviously replace projectName with its actual -# value): -# -# projectName_SOURCE_DIR -# projectName_BINARY_DIR -# -# The SOURCE_DIR and BINARY_DIR arguments are optional and would not typically -# need to be provided. They can be specified if you want the downloaded source -# and build directories to be located in a specific place. The contents of -# projectName_SOURCE_DIR and projectName_BINARY_DIR will be populated with the -# locations used whether you provide SOURCE_DIR/BINARY_DIR or not. -# -# The DOWNLOAD_DIR argument does not normally need to be set. It controls the -# location of the temporary CMake build used to perform the download. -# -# The PREFIX argument can be provided to change the base location of the default -# values of DOWNLOAD_DIR, SOURCE_DIR and BINARY_DIR. If all of those three arguments -# are provided, then PREFIX will have no effect. The default value for PREFIX is -# CMAKE_BINARY_DIR. -# -# The QUIET option can be given if you do not want to show the output associated -# with downloading the specified project. -# -# In addition to the above, any other options are passed through unmodified to -# ExternalProject_Add() to perform the actual download, patch and update steps. -# The following ExternalProject_Add() options are explicitly prohibited (they -# are reserved for use by the download_project() command): -# -# CONFIGURE_COMMAND -# BUILD_COMMAND -# INSTALL_COMMAND -# TEST_COMMAND -# -# Only those ExternalProject_Add() arguments which relate to downloading, patching -# and updating of the project sources are intended to be used. Also note that at -# least one set of download-related arguments are required. -# -# If using CMake 3.2 or later, the UPDATE_DISCONNECTED option can be used to -# prevent a check at the remote end for changes every time CMake is run -# after the first successful download. See the documentation of the ExternalProject -# module for more information. It is likely you will want to use this option if it -# is available to you. Note, however, that the ExternalProject implementation contains -# bugs which result in incorrect handling of the UPDATE_DISCONNECTED option when -# using the URL download method or when specifying a SOURCE_DIR with no download -# method. Fixes for these have been created, the last of which is scheduled for -# inclusion in CMake 3.8.0. Details can be found here: -# -# https://gitlab.kitware.com/cmake/cmake/commit/bdca68388bd57f8302d3c1d83d691034b7ffa70c -# https://gitlab.kitware.com/cmake/cmake/issues/16428 -# -# If you experience build errors related to the update step, consider avoiding -# the use of UPDATE_DISCONNECTED. -# -# EXAMPLE USAGE: -# -# include(DownloadProject) -# download_project(PROJ googletest -# GIT_REPOSITORY https://github.com/google/googletest.git -# GIT_TAG master -# UPDATE_DISCONNECTED 1 -# QUIET -# ) -# -# add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) -# -#======================================================================================== - - -set(_DownloadProjectDir "${CMAKE_CURRENT_LIST_DIR}") - -include(CMakeParseArguments) - -function(download_project) - - set(options QUIET) - set(oneValueArgs - PROJ - PREFIX - DOWNLOAD_DIR - SOURCE_DIR - BINARY_DIR - # Prevent the following from being passed through - CONFIGURE_COMMAND - BUILD_COMMAND - INSTALL_COMMAND - TEST_COMMAND - ) - set(multiValueArgs "") - - cmake_parse_arguments(DL_ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - # Hide output if requested - if (DL_ARGS_QUIET) - set(OUTPUT_QUIET "OUTPUT_QUIET") - else() - unset(OUTPUT_QUIET) - message(STATUS "Downloading/updating ${DL_ARGS_PROJ}") - endif() - - # Set up where we will put our temporary CMakeLists.txt file and also - # the base point below which the default source and binary dirs will be - if (NOT DL_ARGS_PREFIX) - set(DL_ARGS_PREFIX "${CMAKE_BINARY_DIR}") - endif() - if (NOT DL_ARGS_DOWNLOAD_DIR) - set(DL_ARGS_DOWNLOAD_DIR "${DL_ARGS_PREFIX}/${DL_ARGS_PROJ}-download") - endif() - - # Ensure the caller can know where to find the source and build directories - if (NOT DL_ARGS_SOURCE_DIR) - set(DL_ARGS_SOURCE_DIR "${DL_ARGS_PREFIX}/${DL_ARGS_PROJ}-src") - endif() - if (NOT DL_ARGS_BINARY_DIR) - set(DL_ARGS_BINARY_DIR "${DL_ARGS_PREFIX}/${DL_ARGS_PROJ}-build") - endif() - set(${DL_ARGS_PROJ}_SOURCE_DIR "${DL_ARGS_SOURCE_DIR}" PARENT_SCOPE) - set(${DL_ARGS_PROJ}_BINARY_DIR "${DL_ARGS_BINARY_DIR}" PARENT_SCOPE) - - # Create and build a separate CMake project to carry out the download. - # If we've already previously done these steps, they will not cause - # anything to be updated, so extra rebuilds of the project won't occur. - configure_file("${_DownloadProjectDir}/DownloadProject.CMakeLists.cmake.in" - "${DL_ARGS_DOWNLOAD_DIR}/CMakeLists.txt") - execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - RESULT_VARIABLE result - ${OUTPUT_QUIET} - WORKING_DIRECTORY "${DL_ARGS_DOWNLOAD_DIR}" - ) - if(result) - message(FATAL_ERROR "CMake step for ${DL_ARGS_PROJ} failed: ${result}") - endif() - execute_process(COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE result - ${OUTPUT_QUIET} - WORKING_DIRECTORY "${DL_ARGS_DOWNLOAD_DIR}" - ) - if(result) - message(FATAL_ERROR "Build step for ${DL_ARGS_PROJ} failed: ${result}") - endif() - -endfunction() From 4465767074ebd39bc5f1a9e739b0313a34c7c7a8 Mon Sep 17 00:00:00 2001 From: reneSchm <49305466+reneSchm@users.noreply.github.com> Date: Wed, 8 Apr 2026 01:54:27 +0200 Subject: [PATCH 3/6] bump main cmake_minimum version due to use of SOURCE_SUBDIR --- cpp/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index d3e131cf88..4fcfd61922 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.18) project(memilio VERSION 1.0.0) From 3f062e58a705bcd11c2be0b52243ee565ebcb75c Mon Sep 17 00:00:00 2001 From: reneSchm <49305466+reneSchm@users.noreply.github.com> Date: Wed, 8 Apr 2026 02:12:03 +0200 Subject: [PATCH 4/6] Avoid a cmake version deprecation warning --- cpp/CMakeLists.txt | 3 ++- cpp/memilio/ad/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 4fcfd61922..79a0485eca 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -1,4 +1,5 @@ -cmake_minimum_required(VERSION 3.18) +set(MEMILIO_CMAKE_MINIMUM_VERSION "3.18.0") +cmake_minimum_required(VERSION ${MEMILIO_CMAKE_MINIMUM_VERSION}) project(memilio VERSION 1.0.0) diff --git a/cpp/memilio/ad/CMakeLists.txt b/cpp/memilio/ad/CMakeLists.txt index e260bdcc7f..8689bf3cb7 100644 --- a/cpp/memilio/ad/CMakeLists.txt +++ b/cpp/memilio/ad/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.5...${MEMILIO_CMAKE_MINIMUM_VERSION}) project(AD CXX) add_library(AD INTERFACE) From a0d01619bcadb8a3f668d675def80cd2d2a4dfa3 Mon Sep 17 00:00:00 2001 From: reneSchm <49305466+reneSchm@users.noreply.github.com> Date: Fri, 10 Apr 2026 15:50:00 +0200 Subject: [PATCH 5/6] remove dev artifact --- cpp/benchmarks/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/cpp/benchmarks/CMakeLists.txt b/cpp/benchmarks/CMakeLists.txt index d5089cd9a8..fa2d29957a 100755 --- a/cpp/benchmarks/CMakeLists.txt +++ b/cpp/benchmarks/CMakeLists.txt @@ -8,7 +8,6 @@ set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "Disable Google Test in benchmar message(STATUS "Downloading GoogleBenchmark library") include(FetchContent) FetchContent_Declare(benchmark - SOURCE_SUBDIR this_directory_name_does_not_exist GIT_REPOSITORY https://github.com/google/benchmark.git GIT_TAG v1.6.1) FetchContent_MakeAvailable(benchmark) From 520060f2c63a57f00cab04df2e7ed54334f981a0 Mon Sep 17 00:00:00 2001 From: reneSchm <49305466+reneSchm@users.noreply.github.com> Date: Fri, 10 Apr 2026 15:50:24 +0200 Subject: [PATCH 6/6] make benchmark config paths more resilient --- cpp/benchmarks/flow_simulation_ode_secirvvs.cpp | 3 ++- cpp/benchmarks/flow_simulation_ode_seir.cpp | 8 ++++---- cpp/benchmarks/graph_simulation.cpp | 7 ++++--- cpp/benchmarks/integrator_step.cpp | 4 +++- cpp/benchmarks/simulation.cpp | 3 ++- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/cpp/benchmarks/flow_simulation_ode_secirvvs.cpp b/cpp/benchmarks/flow_simulation_ode_secirvvs.cpp index 377b3e211b..e6bbeefd6d 100644 --- a/cpp/benchmarks/flow_simulation_ode_secirvvs.cpp +++ b/cpp/benchmarks/flow_simulation_ode_secirvvs.cpp @@ -21,10 +21,11 @@ #include "benchmarks/flow_simulation_ode_secirvvs.h" #include "memilio/compartments/flow_simulation.h" #include "memilio/compartments/simulation.h" +#include "memilio/utils/base_dir.h" #include "ode_secirvvs/model.h" #include -const std::string config_path = "../../benchmarks/simulation.config"; +const std::string config_path = mio::base_dir() + "cpp/benchmarks/simulation.config"; // simulation without flows (not in Model definition and not calculated by Simulation) void flowless_sim(::benchmark::State& state) diff --git a/cpp/benchmarks/flow_simulation_ode_seir.cpp b/cpp/benchmarks/flow_simulation_ode_seir.cpp index 3db65e1df8..d50b16f0f8 100644 --- a/cpp/benchmarks/flow_simulation_ode_seir.cpp +++ b/cpp/benchmarks/flow_simulation_ode_seir.cpp @@ -19,13 +19,13 @@ */ #include "benchmarks/simulation.h" #include "memilio/compartments/flow_simulation.h" +#include "memilio/compartments/simulation.h" +#include "memilio/utils/base_dir.h" #include "ode_seir/model.h" -#include -const std::string config_path = "../../benchmarks/simulation.config"; +#include -#include "memilio/compartments/simulation.h" -#include "models/ode_seir/model.h" +const std::string config_path = mio::base_dir() + "cpp/benchmarks/simulation.config"; namespace mio { diff --git a/cpp/benchmarks/graph_simulation.cpp b/cpp/benchmarks/graph_simulation.cpp index 87da0c4224..1b19b4eb40 100644 --- a/cpp/benchmarks/graph_simulation.cpp +++ b/cpp/benchmarks/graph_simulation.cpp @@ -17,15 +17,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "benchmark/benchmark.h" #include "benchmarks/graph_simulation.h" #include "memilio/compartments/simulation.h" +#include "memilio/math/adapt_rk.h" #include "memilio/mobility/metapopulation_mobility_instant.h" -#include "benchmark/benchmark.h" +#include "memilio/utils/base_dir.h" #include "ode_secirvvs/model.h" -#include "memilio/math/adapt_rk.h" #include -const std::string config_path = "../../benchmarks/graph_simulation.config"; +const std::string config_path = mio::base_dir() + "cpp/benchmarks/graph_simulation.config"; mio::osecirvvs::Model create_model(size_t num_agegroups, const ScalarType tmax) { diff --git a/cpp/benchmarks/integrator_step.cpp b/cpp/benchmarks/integrator_step.cpp index 71f22a3d6f..c179476f70 100644 --- a/cpp/benchmarks/integrator_step.cpp +++ b/cpp/benchmarks/integrator_step.cpp @@ -22,6 +22,7 @@ #include "memilio/math/adapt_rk.h" #include "memilio/math/stepper_wrapper.h" +#include "memilio/utils/base_dir.h" template void integrator_step(::benchmark::State& state) @@ -32,7 +33,8 @@ void integrator_step(::benchmark::State& state) // with "num_agegroups" agegroups, and taking "yt" as the state of the simulation at "t_init" // NOTE: yt must have #agegroups * #compartments entries // benchmark setup - auto cfg = mio::benchmark::IntegratorStepConfig::initialize("benchmarks/integrator_step.config"); + auto cfg = + mio::benchmark::IntegratorStepConfig::initialize(mio::base_dir() + "cpp/benchmarks/integrator_step.config"); //auto cfg = mio::benchmark::IntegratorStepConfig::initialize(); auto model = mio::benchmark::model::SecirAgeres(cfg.num_agegroups); // set deriv function and integrator diff --git a/cpp/benchmarks/simulation.cpp b/cpp/benchmarks/simulation.cpp index a6f652a860..5205e6d2d9 100644 --- a/cpp/benchmarks/simulation.cpp +++ b/cpp/benchmarks/simulation.cpp @@ -22,6 +22,7 @@ #include "memilio/math/adapt_rk.h" #include "memilio/math/stepper_wrapper.h" +#include "memilio/utils/base_dir.h" template void simulation(::benchmark::State& state) @@ -29,7 +30,7 @@ void simulation(::benchmark::State& state) // suppress non-critical messages mio::set_log_level(mio::LogLevel::critical); // setup benchmark parameters - auto cfg = mio::benchmark::SimulationConfig::initialize("benchmarks/simulation.config"); + auto cfg = mio::benchmark::SimulationConfig::initialize(mio::base_dir() + "cpp/benchmarks/simulation.config"); //auto cfg = mio::benchmark::SimulationConfig::initialize(10); auto model = mio::benchmark::model::SecirAgeres(cfg.num_agegroups);