From 375b1cb4cef3a528b55d7c984b8412c76703589a Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Wed, 5 Aug 2026 10:07:15 +0200 Subject: [PATCH] [cmake] Do not auto-turn OFF feature or auto-turn ON builtin_option for easy-to-install dependencies (via homebrew, apt-get) when dependency is missing in the system. Instead, force user to install it via package manager, or to turn feature purposely OFF. [nfc] improve error messages Co-authored-by: ferdymercury --- README/ReleaseNotes/v642/index.md | 1 + cmake/modules/SearchInstalledSoftware.cmake | 128 +++----------------- 2 files changed, 17 insertions(+), 112 deletions(-) diff --git a/README/ReleaseNotes/v642/index.md b/README/ReleaseNotes/v642/index.md index 2db619e44337a..bf531a7d43f3b 100644 --- a/README/ReleaseNotes/v642/index.md +++ b/README/ReleaseNotes/v642/index.md @@ -43,6 +43,7 @@ The following people have contributed to this new version: * The option `fail-on-missing=OFF` is no longer honored for opt-in (ie OFF by default) build options requiring external dependencies such as `arrow`, `cocoa`, `daos`, `daos_mock`, `dcache`, `experimental_adaptivecpp`, `fcgi`, `fortran`, `gviz`, `mpi`, `pythia8`, `qt6web`, `tmva-cudnn`, `tmva-pymva`, `tmva-sofie`, `uring` or `vecgeom`. If the respective associated package dependency is not installed, ROOT will always raise a configuration error independent of the value of `fail-on-missing`. The user has to take action by either providing the dependency or manually disabling that option via `-Darrow=OFF`. Note that `all=ON` enables several of these options, so building with `-Dall=ON` now requires all of their dependencies to be installed, or the unwanted ones to be disabled explicitly. Build options that are enabled by default, such as `pyroot`, `opengl`, `xml`, `sqlite`, `davix`, `curl`, `tmva-cpu` or `tpython` are not affected: they are still disabled automatically when their dependencies are missing. +* The option `fail-on-missing=OFF` will no longer be honored for CMake ROOT build options that have easy-to-install dependencies (e.g. via homebrew or apt-get), such as those required by options `cfitsio`, `civetweb`, `fftw3`, `imt`, `mathmore`, `nlohmann_json`, `tmva-cpu`, `unuran`, `vdt` or `xrootd`. Before, associated `builtin_option` was automatically turned ON (or the opt-in feature turned to OFF), now, user has to install system package or manually set `builtin_option` to `ON` or opt-in feature to `OFF`. * The method `RooRealVar::removeRange()` and the corresponding method in `RooErrorVar` that were deprecated in ROOT 6.40 are now removed. * The overloads of `RooAbsReal::createChi2()` and `RooAbsReal::chi2FitTo()` that take unbinned **RooDataSet** data objects were deprecated in ROOT 6.40 and are now removed. * The **RooStats::HybridPlot** class and the related **HybridResult::GetPlot** method were deprecated in ROOT 6.40 and are now removed. diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake index f3e0cb65c880a..06e8a909ea86e 100644 --- a/cmake/modules/SearchInstalledSoftware.cmake +++ b/cmake/modules/SearchInstalledSoftware.cmake @@ -181,19 +181,7 @@ endif() #---Check for nlohmann/json.hpp--------------------------------------------------------- if(NOT builtin_nlohmannjson) - message(STATUS "Looking for nlohmann/json.hpp") - if(fail-on-missing) - find_package(nlohmann_json 3.9 REQUIRED) - else() - find_package(nlohmann_json 3.9 QUIET) - if(nlohmann_json_FOUND) - get_target_property(_nlohmann_json_incl nlohmann_json::nlohmann_json INTERFACE_INCLUDE_DIRECTORIES) - message(STATUS "Found nlohmann/json.hpp in ${_nlohmann_json_incl} (found version ${nlohmann_json_VERSION})") - else() - message(STATUS "nlohmann/json.hpp not found. Switching on builtin_nlohmannjson option") - set(builtin_nlohmannjson ON CACHE BOOL "Enabled because nlohmann/json.hpp not found" FORCE) - endif() - endif() + ROOT_FIND_REQUIRED_DEP(nlohmann_json builtin_nlohmannjson 3.9) # ROOTEve wants to know if it comes with json_fwd.hpp: if(TARGET nlohmann_json::nlohmann_json) @@ -212,16 +200,7 @@ endif() #---Check for Unuran ------------------------------------------------------------------ if(unuran AND NOT builtin_unuran) - message(STATUS "Looking for Unuran") - if(fail-on-missing) - find_Package(Unuran REQUIRED) - else() - find_Package(Unuran) - if(NOT UNURAN_FOUND) - message(STATUS "Unuran not found. Switching on builtin_unuran option") - set(builtin_unuran ON CACHE BOOL "Enabled because Unuran not found (${builtin_unuran_description})" FORCE) - endif() - endif() + ROOT_FIND_REQUIRED_DEP(Unuran builtin_unuran) endif() if (builtin_unuran) add_subdirectory(builtins/unuran) @@ -524,17 +503,7 @@ endif() #--- Check for civetweb - (has to go after SSL) --------------------------------------- if(http AND NOT builtin_civetweb) message(STATUS "Looking for civetweb") - # one could also use ROOT_FIND_REQUIRED_DEP but it has less info / deals less with special cases - if(fail-on-missing) - find_package(civetweb 1.15 REQUIRED) - else() - find_package(civetweb 1.15 QUIET) - if(civetweb_FOUND) - message(STATUS "Found civetweb version ${civetweb_VERSION}") - else() - message(SEND_ERROR "civetweb not found or system version too old. Install system civetweb package or set `-Dbuiltin_civetweb=ON` as workaround or switch `-Dhttp=OFF`.") - endif() - endif() + ROOT_FIND_REQUIRED_DEP(civetweb builtin_civetweb 1.15) if(civetweb_FOUND) get_target_property(CIVETWEB_IMPORTED_LOCATION civetweb::civetweb IMPORTED_LOCATION_NONE) # Fall-back solution for some OS such as opensuse16 with different IMPORTED_LOCATION_xxxx config choice @@ -617,20 +586,7 @@ endif() #---Check for FFTW3------------------------------------------------------------------- if(fftw3) - if(NOT builtin_fftw3) - message(STATUS "Looking for FFTW3") - find_package(FFTW) - if(NOT FFTW_FOUND) - if(fail-on-missing) - message(SEND_ERROR "FFTW3 libraries not found while -Dfftw3=ON") - else() - message(STATUS "FFTW3 not found. Set [environment] variable FFTW_DIR to point to your FFTW3 installation") - message(STATUS " Alternatively, you can also enable the option 'builtin_fftw3' to build FFTW3 internally'") - message(STATUS " For the time being switching OFF 'fftw3' option") - set(fftw3 OFF CACHE BOOL "Disabled because FFTW3 not found and builtin_fftw3 disabled (${fftw3_description})" FORCE) - endif() - endif() - endif() + ROOT_FIND_REQUIRED_DEP(FFTW builtin_fftw3) endif() if(builtin_fftw3) add_subdirectory(builtins/fftw3) @@ -647,17 +603,7 @@ if(fitsio OR builtin_cfitsio) add_subdirectory(builtins/cfitsio) set(fitsio ON CACHE BOOL "Enabled because builtin_cfitsio requested (${fitsio_description})" FORCE) else() - message(STATUS "Looking for CFITSIO") - if(fail-on-missing) - find_package(CFITSIO REQUIRED) - else() - find_package(CFITSIO) - if(NOT CFITSIO_FOUND) - message(STATUS "CFITSIO not found. You can enable the option 'builtin_cfitsio' to build the library internally'") - message(STATUS " For the time being switching off 'fitsio' option") - set(fitsio OFF CACHE BOOL "Disabled because CFITSIO not found and builtin_cfitsio disabled (${fitsio_description})" FORCE) - endif() - endif() + ROOT_FIND_REQUIRED_DEP(CFITSIO builtin_cfitsio) endif() endif() @@ -681,26 +627,15 @@ if(xrootd AND NOT builtin_xrootd) message(STATUS "Looking for XROOTD") find_package(XRootD) if(NOT XROOTD_FOUND) - if(fail-on-missing) - message(SEND_ERROR "XROOTD not found. Set environment variable XRDSYS to point to your XROOTD installation, " - "or include the installation of XROOTD in the CMAKE_PREFIX_PATH. " - "Alternatively, you can also enable the option 'builtin_xrootd' to build XROOTD internally") - else() - ROOT_CHECK_CONNECTION("xrootd=OFF") - if(NO_CONNECTION) - message(FATAL_ERROR "No internet connection. Please check your connection, or either disable the 'builtin_xrootd'" - " option or the 'fail-on-missing' to automatically disable options requiring internet access") - else() - message(STATUS "XROOTD not found, enabling 'builtin_xrootd' option") - set(builtin_xrootd ON CACHE BOOL "Enabled because xrootd is enabled, but external xrootd was not found (${xrootd_description})" FORCE) - endif() - endif() + message(SEND_ERROR "XROOTD not found. Set environment variable XRDSYS to point to your XROOTD installation, " + "or include the installation of XROOTD in the CMAKE_PREFIX_PATH. Or turn off xrootd." + "Alternatively, you can also enable the option 'builtin_xrootd' to build XROOTD internally") else() # XROOTD was found. Check now for required components foreach (component CLIENT UTILS) # ROOT requires XrdCl and XrdUtils if("${XROOTD_${component}_LIBRARIES}" STREQUAL "XROOTD_${component}_LIBRARIES-NOTFOUND") message(SEND_ERROR "XROOTD found but missing component ${component}. Install missing package on your system (preferred). " - "Alternatively, you can also enable the option 'builtin_xrootd' to build XROOTD internally") + "Alternatively, you can also enable the option 'builtin_xrootd' to build XROOTD internally; or turn off xrootd.") endif() endforeach() endif() @@ -720,11 +655,11 @@ endif() if(builtin_xrootd) ROOT_CHECK_CONNECTION("builtin_xrootd=OFF") if(NO_CONNECTION) - message(FATAL_ERROR "No internet connection. Please check your connection, or either disable the 'builtin_xrootd'" - " option or the 'fail-on-missing' to automatically disable options requiring internet access") + message(SEND_ERROR "No internet connection. Please check your connection, or disable the 'builtin_xrootd'" + " option") endif() if(NOT ssl AND NOT builtin_openssl) - message(FATAL_ERROR "Building XRootD ('builtin_xrootd'=On) requires ssl support ('ssl' or 'builtin_openssl').") + message(SEND_ERROR "Building XRootD ('builtin_xrootd'=On) requires ssl support.") endif() add_subdirectory(builtins/xrootd) set(xrootd ON CACHE BOOL "Enabled because builtin_xrootd requested (${xrootd_description})" FORCE) @@ -896,11 +831,7 @@ if(imt AND NOT builtin_tbb) #endif int main() { return 0; }" tbb_exception_result) if(NOT tbb_exception_result) - if(fail-on-missing) - message(SEND_ERROR "Found TBB uses tbb::captured_exception, not suitable for ROOT!") - endif() - message(STATUS "Found TBB uses tbb::captured_exception, enabling 'builtin_tbb' option") - set(builtin_tbb ON CACHE BOOL "Enabled because imt is enabled and found TBB is not suitable" FORCE) + message(SEND_ERROR "Found TBB uses tbb::captured_exception, not suitable for ROOT!, enable 'builtin_tbb' option or turn off 'imt'") endif() endif() @@ -932,21 +863,7 @@ endif() if(vdt OR builtin_vdt) if(NOT builtin_vdt) message(STATUS "Looking for VDT") - find_package(Vdt 0.4) - if(NOT VDT_FOUND) - if(fail-on-missing) - message(SEND_ERROR "VDT not found. Ensure that the installation of VDT is in the CMAKE_PREFIX_PATH") - else() - message(STATUS "VDT not found. Ensure that the installation of VDT is in the CMAKE_PREFIX_PATH") - ROOT_CHECK_CONNECTION("vdt=OFF") - if(NO_CONNECTION) - set(vdt OFF CACHE BOOL "Disabled because not found and no internet connection" FORCE) - else() - message(STATUS " Switching ON 'builtin_vdt' option") - set(builtin_vdt ON CACHE BOOL "Enabled because external vdt not found (${vdt_description})" FORCE) - endif() - endif() - endif() + ROOT_FIND_REQUIRED_DEP(Vdt builtin_vdt 0.4) endif() if(builtin_vdt) add_subdirectory(builtins/vdt) @@ -1062,21 +979,8 @@ if(mathmore OR builtin_gsl OR (tmva-cpu AND use_gsl_cblas)) if(NOT builtin_gsl) find_package(GSL 1.10) if(NOT GSL_FOUND) - if(fail-on-missing) - message(SEND_ERROR "GSL package not found and 'mathmore' component is required ('fail-on-missing' enabled). " - "Alternatively, you can enable the option 'builtin_gsl' to build the GSL libraries internally.") - else() - message(STATUS "GSL not found. Set variable GSL_ROOT_DIR to point to your GSL installation") - message(STATUS " Alternatively, you can also enable the option 'builtin_gsl' to build the GSL libraries internally'") - if (mathmore) - message(STATUS " For the time being switching OFF 'mathmore' option") - set(mathmore OFF CACHE BOOL "Disable because builtin_gsl disabled and external GSL not found (${mathmore_description})" FORCE) - endif() - if (tmva-cpu AND use_gsl_cblas) - message(STATUS " For the time being switching OFF 'tmva-cpu' option") - set(tmva-cpu OFF CACHE BOOL "Disable because use_gsl_cblas enabled, builtin_gsl disabled and external GSL not found (${tmva-cpu_description})" FORCE) - endif() - endif() + message(SEND_ERROR "GSL package not found and 'mathmore' component is required. " + "Alternatively, you can enable the option 'builtin_gsl' to build the GSL libraries internally. Or disable 'mathmore' and 'tmva-cpu' and 'use_gsl_cblas'") endif() else() add_subdirectory(builtins/gsl)