From 658343f13195eef2870cf29554056872a2f19ca2 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Mon, 22 Sep 2025 18:18:19 +0200 Subject: [PATCH 1/4] [CMake] Set the minimum required version to 3.23 This version of CMake was released in March 2022 https://github.com/Kitware/CMake/releases/tag/v3.23.0 This version is required to use FILE_SETs, which could help towards https://github.com/root-project/root/issues/16327 and https://github.com/root-project/root/pull/18419. Since cmake_minimum_required updates the cmake_policy from 3.20 to 3.23, we need to take care of a change that happened from 3.20 to 3.21 that leads to an error in the CheckCompiler CMake module, so set the proper policy flag to old to avoid that error on some platforms. --- CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e37676441ac97..b0bea9f733784 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ # For the licensing terms see $ROOTSYS/LICENSE. # For the list of contributors see $ROOTSYS/README/CREDITS. -cmake_minimum_required(VERSION 3.20 FATAL_ERROR) +cmake_minimum_required(VERSION 3.23 FATAL_ERROR) if(WIN32) # Set CMP0091 (MSVC runtime library flags are selected by an abstraction) to OLD @@ -44,6 +44,13 @@ foreach(policy ${policy_new}) endif() endforeach() +set(policy_old CMP0126) +foreach(policy ${policy_old}) + if(POLICY ${policy}) + cmake_policy(SET ${policy} OLD) + endif() +endforeach() + include(cmake/modules/CaptureCommandLine.cmake) project(ROOT) From bc163c731fa4c2de523f2aba1275073ba9502a18 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Fri, 20 Mar 2026 11:33:27 +0100 Subject: [PATCH 2/4] [core] rm workaround for cmake 3.23 --- core/base/CMakeLists.txt | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/core/base/CMakeLists.txt b/core/base/CMakeLists.txt index f6b8a0be390cd..a5794491db30b 100644 --- a/core/base/CMakeLists.txt +++ b/core/base/CMakeLists.txt @@ -207,18 +207,16 @@ set_property(TARGET Core APPEND PROPERTY DICT_HEADERS ${BASE_HEADERS}) target_sources(Core PRIVATE ${BASE_SOURCES}) -if(NOT CMAKE_VERSION VERSION_LESS "3.23.0") # https://discourse.cmake.org/t/file-set-xyz-is-listed-in-interface-file-sets-of-w-but-has-not-been-exported/9131/3 - target_sources( - Core - PRIVATE - FILE_SET private_header_files - TYPE HEADERS - BASE_DIRS inc/ src/ - FILES - ${RELATIVE_BASE_INC_HEADERS} - src/TListOfTypes.h - ) -endif() +target_sources( + Core + PRIVATE + FILE_SET private_header_files + TYPE HEADERS + BASE_DIRS inc/ src/ + FILES + ${RELATIVE_BASE_INC_HEADERS} + src/TListOfTypes.h +) target_include_directories(Core PUBLIC $ From 16c321c3c1fddb239c90e289d03ce79f8ba2d724 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Sun, 12 Apr 2026 11:14:16 +0200 Subject: [PATCH 3/4] [cmake] rm gtest target workaround for cmake < 3.23 --- cmake/modules/SearchInstalledSoftware.cmake | 7 ------- 1 file changed, 7 deletions(-) diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake index 67aa8431fcaf4..ff3f59cf146d7 100644 --- a/cmake/modules/SearchInstalledSoftware.cmake +++ b/cmake/modules/SearchInstalledSoftware.cmake @@ -1115,13 +1115,6 @@ if (testing OR testsupport) message(SEND_ERROR "Missing installation of GTest subcomponent ${LIBNAME}") endif() endforeach() - # Starting from cmake 3.23, the GTest targets will have stable names. - # ROOT was updated to use those, but for older CMake versions, we have to declare the aliases: - foreach(LIBNAME gtest_main gmock_main gtest gmock) - if(NOT TARGET GTest::${LIBNAME} AND TARGET ${LIBNAME}) - add_library(GTest::${LIBNAME} ALIAS ${LIBNAME}) - endif() - endforeach() endif() #------------------------------------------------------------------------------------ From c788683a22cc5dceec929040f8975fbc6100d0ab Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Fri, 7 Aug 2026 08:27:17 +0200 Subject: [PATCH 4/4] [RF] rm workaround for cmake 3.23 --- roofit/batchcompute/CMakeLists.txt | 58 ++++++++++----------- roofit/codegen/CMakeLists.txt | 22 ++++---- roofit/histfactory/CMakeLists.txt | 24 ++++----- roofit/hs3/CMakeLists.txt | 28 +++++----- roofit/roofit/CMakeLists.txt | 24 ++++----- roofit/roofitcore/CMakeLists.txt | 83 +++++++++++++++--------------- roofit/roostats/CMakeLists.txt | 6 +-- roofit/xroofit/CMakeLists.txt | 30 +++++------ 8 files changed, 129 insertions(+), 146 deletions(-) diff --git a/roofit/batchcompute/CMakeLists.txt b/roofit/batchcompute/CMakeLists.txt index ab87f98686df5..74b3a9f0dae3a 100644 --- a/roofit/batchcompute/CMakeLists.txt +++ b/roofit/batchcompute/CMakeLists.txt @@ -117,30 +117,28 @@ set(shared_object_sources src/RooBatchCompute.cxx src/ComputeFunctions.cxx) ROOT_LINKER_LIBRARY(RooBatchCompute_GENERIC ${shared_object_sources} TYPE SHARED DEPENDENCIES RooBatchCompute) target_compile_options(RooBatchCompute_GENERIC PRIVATE ${common-flags} -DRF_ARCH=GENERIC) -if(NOT CMAKE_VERSION VERSION_LESS "3.23.0") - target_sources( - RooBatchCompute +target_sources( + RooBatchCompute + PRIVATE + FILE_SET private_header_files + TYPE HEADERS + BASE_DIRS res/ + FILES + res/RooBatchCompute.h +) +target_sources( + RooBatchCompute_GENERIC PRIVATE FILE_SET private_header_files TYPE HEADERS - BASE_DIRS res/ + BASE_DIRS src/ res/ FILES - res/RooBatchCompute.h - ) - target_sources( - RooBatchCompute_GENERIC - PRIVATE - FILE_SET private_header_files - TYPE HEADERS - BASE_DIRS src/ res/ - FILES - res/RooBatchComputeTypes.h - res/RooHeterogeneousMath.h - res/RooNaNPacker.h - src/Batches.h - src/RooVDTHeaders.h - ) -endif() + res/RooBatchComputeTypes.h + res/RooHeterogeneousMath.h + res/RooNaNPacker.h + src/Batches.h + src/RooVDTHeaders.h +) # Windows platform and ICC compiler need special code and testing, thus the feature has not been implemented yet for these. if (ROOT_PLATFORM MATCHES "linux|macosx" AND CMAKE_SYSTEM_PROCESSOR MATCHES x86_64 AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") @@ -190,17 +188,15 @@ if (cuda) endif() target_compile_options(RooBatchCompute_CUDA PRIVATE -lineinfo --expt-relaxed-constexpr) - if(NOT CMAKE_VERSION VERSION_LESS "3.23.0") - target_sources( - RooBatchCompute_CUDA - PRIVATE - FILE_SET private_header_files - TYPE HEADERS - BASE_DIRS src/ - FILES - src/CudaInterface.h - ) - endif() + target_sources( + RooBatchCompute_CUDA + PRIVATE + FILE_SET private_header_files + TYPE HEADERS + BASE_DIRS src/ + FILES + src/CudaInterface.h + ) endif() if(vdt OR builtin_vdt) diff --git a/roofit/codegen/CMakeLists.txt b/roofit/codegen/CMakeLists.txt index e1fecef63dac2..e41588ede82cd 100644 --- a/roofit/codegen/CMakeLists.txt +++ b/roofit/codegen/CMakeLists.txt @@ -22,17 +22,15 @@ ROOT_STANDARD_LIBRARY_PACKAGE(RooFitCodegen HistFactory ) -if(NOT CMAKE_VERSION VERSION_LESS "3.23.0") - target_sources( - RooFitCodegen - PRIVATE - FILE_SET private_header_files - TYPE HEADERS - BASE_DIRS inc/ - FILES - # LinkDef.h # empty, not being used by ROOT_STANDARD_LIBRARY_PACKAGE call - inc/RooFit/CodegenImpl.h - ) -endif() +target_sources( + RooFitCodegen + PRIVATE + FILE_SET private_header_files + TYPE HEADERS + BASE_DIRS inc/ + FILES + # LinkDef.h # empty, not being used by ROOT_STANDARD_LIBRARY_PACKAGE call + inc/RooFit/CodegenImpl.h +) ROOT_ADD_TEST_SUBDIRECTORY(test) diff --git a/roofit/histfactory/CMakeLists.txt b/roofit/histfactory/CMakeLists.txt index 61df7a0c65660..12794897e76ed 100644 --- a/roofit/histfactory/CMakeLists.txt +++ b/roofit/histfactory/CMakeLists.txt @@ -99,18 +99,16 @@ install(FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${prepareHistFactory_script} set(RELATIVE_INC_HEADERS ${HISTFACTORY_HEADERS} ${HISTFACTORY_XML_HEADERS}) list(TRANSFORM RELATIVE_INC_HEADERS PREPEND inc/) -if(NOT CMAKE_VERSION VERSION_LESS "3.23.0") - target_sources( - HistFactory - PRIVATE - FILE_SET private_header_files - TYPE HEADERS - BASE_DIRS inc/ - FILES - ${RELATIVE_INC_HEADERS} - inc/LinkDef.h # seemingly not being used by ROOT_STANDARD_LIBRARY_PACKAGE call - inc/HFMsgService.h # not part of list above - ) -endif() +target_sources( + HistFactory + PRIVATE + FILE_SET private_header_files + TYPE HEADERS + BASE_DIRS inc/ + FILES + ${RELATIVE_INC_HEADERS} + inc/LinkDef.h # seemingly not being used by ROOT_STANDARD_LIBRARY_PACKAGE call + inc/HFMsgService.h # not part of list above +) ROOT_ADD_TEST_SUBDIRECTORY(test) diff --git a/roofit/hs3/CMakeLists.txt b/roofit/hs3/CMakeLists.txt index 169c904d544ea..ffeea5e753c31 100644 --- a/roofit/hs3/CMakeLists.txt +++ b/roofit/hs3/CMakeLists.txt @@ -39,20 +39,18 @@ target_link_libraries(RooFitHS3 PRIVATE nlohmann_json::nlohmann_json) set(RELATIVE_INC_HEADERS ${ROOFITHS3_HEADERS}) list(TRANSFORM RELATIVE_INC_HEADERS PREPEND inc/) -if(NOT CMAKE_VERSION VERSION_LESS "3.23.0") - target_sources( - RooFitHS3 - PRIVATE - FILE_SET private_header_files - TYPE HEADERS - BASE_DIRS inc/ src/ - FILES - ${RELATIVE_INC_HEADERS} - # LinkDef.h # seemingly not being used by ROOT_STANDARD_LIBRARY_PACKAGE call - src/Domains.h - src/JSONIOUtils.h - src/static_execute.h - ) -endif() +target_sources( + RooFitHS3 + PRIVATE + FILE_SET private_header_files + TYPE HEADERS + BASE_DIRS inc/ src/ + FILES + ${RELATIVE_INC_HEADERS} + # LinkDef.h # seemingly not being used by ROOT_STANDARD_LIBRARY_PACKAGE call + src/Domains.h + src/JSONIOUtils.h + src/static_execute.h +) ROOT_ADD_TEST_SUBDIRECTORY(test) diff --git a/roofit/roofit/CMakeLists.txt b/roofit/roofit/CMakeLists.txt index 9df36a28f25aa..1e5836dadc73e 100644 --- a/roofit/roofit/CMakeLists.txt +++ b/roofit/roofit/CMakeLists.txt @@ -174,18 +174,16 @@ endif() set(RELATIVE_INC_HEADERS ${ROOFIT_HEADERS}) list(TRANSFORM RELATIVE_INC_HEADERS PREPEND inc/) -if(NOT CMAKE_VERSION VERSION_LESS "3.23.0") - target_sources( - RooFit - PRIVATE - FILE_SET private_header_files - TYPE HEADERS - BASE_DIRS inc/ src/ - FILES - ${RELATIVE_INC_HEADERS} - inc/LinkDef1.h - src/RooFit/Detail/Algorithms.h - ) -endif() +target_sources( + RooFit + PRIVATE + FILE_SET private_header_files + TYPE HEADERS + BASE_DIRS inc/ src/ + FILES + ${RELATIVE_INC_HEADERS} + inc/LinkDef1.h + src/RooFit/Detail/Algorithms.h +) ROOT_ADD_TEST_SUBDIRECTORY(test) diff --git a/roofit/roofitcore/CMakeLists.txt b/roofit/roofitcore/CMakeLists.txt index d8143917c8073..f656256d33488 100644 --- a/roofit/roofitcore/CMakeLists.txt +++ b/roofit/roofitcore/CMakeLists.txt @@ -526,47 +526,46 @@ endif() set(RELATIVE_INC_HEADERS ${ROOFITCORE_HEADERS}) list(TRANSFORM RELATIVE_INC_HEADERS PREPEND inc/) -if(NOT CMAKE_VERSION VERSION_LESS "3.23.0") - target_sources( - RooFitCore - PRIVATE - FILE_SET private_header_files - TYPE HEADERS - BASE_DIRS inc/ res/ src/ - FILES - ${RELATIVE_INC_HEADERS} - inc/LinkDef.h - inc/RooFit/UniqueId.h # Was not being included in ROOT_STL_PACKAGE call - src/RooConvIntegrandBinding.h - src/RooFormulaUtils.h - src/RooFormulaEvaluator.h - src/RooTFormulaEvaluator.h - src/RooFitLegacy/RooAbsCategoryLegacyIterator.h - src/RooMCIntegrator.h - src/RooFoamGenerator.h - src/RooAbsMinimizerFcn.h - src/RooSentinel.h - src/RooAcceptReject.h - src/TreeReadBuffer.h - src/ConstraintHelpers.h - src/RooRombergIntegrator.h - src/RooBinIntegrator.h - ${RooFitMPTestStatisticsHeaders} - ${LegacyEvalBackendHeaders} - src/RooFit/BatchModeDataHelpers.h - src/RooMinimizerFcn.h - src/RooAbsNumGenerator.h - src/FitHelpers.h - src/RooGenProdProj.h - src/RooNumGenFactory.h - src/RooGrid.h - src/RooAddHelpers.h - src/RooAdaptiveIntegratorND.h - src/ValueChecking.h - src/RooImproperIntegrator1D.h - res/RooFitImplHelpers.h - res/RooUnitTest.h - ) -endif() + +target_sources( + RooFitCore + PRIVATE + FILE_SET private_header_files + TYPE HEADERS + BASE_DIRS inc/ res/ src/ + FILES + ${RELATIVE_INC_HEADERS} + inc/LinkDef.h + inc/RooFit/UniqueId.h # Was not being included in ROOT_STL_PACKAGE call + src/RooConvIntegrandBinding.h + src/RooFormulaUtils.h + src/RooFormulaEvaluator.h + src/RooTFormulaEvaluator.h + src/RooFitLegacy/RooAbsCategoryLegacyIterator.h + src/RooMCIntegrator.h + src/RooFoamGenerator.h + src/RooAbsMinimizerFcn.h + src/RooSentinel.h + src/RooAcceptReject.h + src/TreeReadBuffer.h + src/ConstraintHelpers.h + src/RooRombergIntegrator.h + src/RooBinIntegrator.h + ${RooFitMPTestStatisticsHeaders} + ${LegacyEvalBackendHeaders} + src/RooFit/BatchModeDataHelpers.h + src/RooMinimizerFcn.h + src/RooAbsNumGenerator.h + src/FitHelpers.h + src/RooGenProdProj.h + src/RooNumGenFactory.h + src/RooGrid.h + src/RooAddHelpers.h + src/RooAdaptiveIntegratorND.h + src/ValueChecking.h + src/RooImproperIntegrator1D.h + res/RooFitImplHelpers.h + res/RooUnitTest.h +) ROOT_ADD_TEST_SUBDIRECTORY(test) diff --git a/roofit/roostats/CMakeLists.txt b/roofit/roostats/CMakeLists.txt index ce3a46f93f5f8..ed445dfb4b7ab 100644 --- a/roofit/roostats/CMakeLists.txt +++ b/roofit/roostats/CMakeLists.txt @@ -140,8 +140,7 @@ ROOT_STANDARD_LIBRARY_PACKAGE(RooStats set(RELATIVE_INC_HEADERS ${ROOSTATS_HEADERS}) list(TRANSFORM RELATIVE_INC_HEADERS PREPEND inc/) -if(NOT CMAKE_VERSION VERSION_LESS "3.23.0") - target_sources( +target_sources( RooStats PRIVATE FILE_SET private_header_files @@ -150,7 +149,6 @@ if(NOT CMAKE_VERSION VERSION_LESS "3.23.0") FILES ${RELATIVE_INC_HEADERS} inc/LinkDef.h # seemingly this is not being used in ROOT_STANDARD_LIBRARY_PACKAGE call - ) -endif() +) ROOT_ADD_TEST_SUBDIRECTORY(test) diff --git a/roofit/xroofit/CMakeLists.txt b/roofit/xroofit/CMakeLists.txt index f23690d89d805..375a2cf0f4744 100644 --- a/roofit/xroofit/CMakeLists.txt +++ b/roofit/xroofit/CMakeLists.txt @@ -40,21 +40,19 @@ target_include_directories(RooFitXRooFit PRIVATE inc/RooFit) set(RELATIVE_INC_HEADERS ${XROOFIT_HEADERS}) list(TRANSFORM RELATIVE_INC_HEADERS PREPEND inc/) -if(NOT CMAKE_VERSION VERSION_LESS "3.23.0") - target_sources( - RooFitXRooFit - PRIVATE - FILE_SET private_header_files - TYPE HEADERS - BASE_DIRS inc/ src/ - FILES - ${RELATIVE_INC_HEADERS} - inc/LinkDef.h - inc/RooFit/xRooFit/Config.h # was not part of XROOFIT_HEADERS - src/PythonInterface.h - src/coutCapture.h - src/xRooFitVersion.h - ) -endif() +target_sources( + RooFitXRooFit + PRIVATE + FILE_SET private_header_files + TYPE HEADERS + BASE_DIRS inc/ src/ + FILES + ${RELATIVE_INC_HEADERS} + inc/LinkDef.h + inc/RooFit/xRooFit/Config.h # was not part of XROOFIT_HEADERS + src/PythonInterface.h + src/coutCapture.h + src/xRooFitVersion.h +) ROOT_ADD_TEST_SUBDIRECTORY(test)