From 4f592abf8af7eda10cef5385d2995c9ebda31e33 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Tue, 15 Apr 2025 11:29:21 +0200 Subject: [PATCH 1/7] [cmake] feature=OFF has hierarchical priority over builtin_feature=ON Fixes https://its.cern.ch/jira/browse/ROOT-10743 feature=ON can force-enable builtin_feature=OFF, but not the other way round, a warning is issued in that case now instead of silently enabling. This prevents automatic enablings of features that the user can not disable unless he writes feature=OFF builtin_feature=OFF. --- cmake/modules/SearchInstalledSoftware.cmake | 331 +++++++++++--------- 1 file changed, 179 insertions(+), 152 deletions(-) diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake index 7c410dfbd3347..bd35f74d11e9e 100644 --- a/cmake/modules/SearchInstalledSoftware.cmake +++ b/cmake/modules/SearchInstalledSoftware.cmake @@ -643,7 +643,9 @@ if(mathmore OR builtin_gsl OR (tmva-cpu AND use_gsl_cblas)) # FIXME: one need to find better way to extract path with GSL include files set(GSL_INCLUDE_DIR ${CMAKE_BINARY_DIR}/GSL-prefix/src/GSL-build) set(GSL_FOUND ON) - set(mathmore ON CACHE BOOL "Enabled because builtin_gsl requested (${mathmore_description})" FORCE) + if(NOT mathmore) + message(WARNING "builtin_gls was enabled but mathmore wasn't") + endif() endif() endif() @@ -925,24 +927,27 @@ if(fftw3) endif() endif() if(builtin_fftw3) - set(FFTW_VERSION 3.3.8) - message(STATUS "Downloading and building FFTW version ${FFTW_VERSION}") - set(FFTW_LIBRARIES ${CMAKE_BINARY_DIR}/lib/libfftw3.a) - ExternalProject_Add( - FFTW3 - URL ${lcgpackages}/fftw-${FFTW_VERSION}.tar.gz - URL_HASH SHA256=6113262f6e92c5bd474f2875fa1b01054c4ad5040f6b0da7c03c98821d9ae303 - INSTALL_DIR ${CMAKE_BINARY_DIR} - CONFIGURE_COMMAND ./configure --prefix= - BUILD_COMMAND make CFLAGS=-fPIC - LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1 - BUILD_IN_SOURCE 1 - BUILD_BYPRODUCTS ${FFTW_LIBRARIES} - TIMEOUT 600 - ) - set(FFTW_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include) - set(FFTW3_TARGET FFTW3) - set(fftw3 ON CACHE BOOL "Enabled because builtin_fftw3 requested (${fftw3_description})" FORCE) + if(NOT fftw3) + message(WARNING "fftw3 is OFF, hence ignoring the activated setting 'builtin_fftw3'") + else() + set(FFTW_VERSION 3.3.8) + message(STATUS "Downloading and building FFTW version ${FFTW_VERSION}") + set(FFTW_LIBRARIES ${CMAKE_BINARY_DIR}/lib/libfftw3.a) + ExternalProject_Add( + FFTW3 + URL ${lcgpackages}/fftw-${FFTW_VERSION}.tar.gz + URL_HASH SHA256=6113262f6e92c5bd474f2875fa1b01054c4ad5040f6b0da7c03c98821d9ae303 + INSTALL_DIR ${CMAKE_BINARY_DIR} + CONFIGURE_COMMAND ./configure --prefix= + BUILD_COMMAND make CFLAGS=-fPIC + LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1 + BUILD_IN_SOURCE 1 + BUILD_BYPRODUCTS ${FFTW_LIBRARIES} + TIMEOUT 600 + ) + set(FFTW_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include) + set(FFTW3_TARGET FFTW3) + endif() endif() #---Check for fitsio------------------------------------------------------------------- @@ -951,9 +956,12 @@ if(fitsio OR builtin_cfitsio) ROOT_CHECK_CONNECTION_AND_DISABLE_OPTION("builtin_cfitsio") endif() if(builtin_cfitsio) - add_library(CFITSIO::CFITSIO STATIC IMPORTED GLOBAL) - add_subdirectory(builtins/cfitsio) - set(fitsio ON CACHE BOOL "Enabled because builtin_cfitsio requested (${fitsio_description})" FORCE) + if(NOT cfitsio) + message(WARNING "cfitsio is OFF, hence ignoring the activated setting 'builtin_cfitsio'") + else() + add_library(CFITSIO::CFITSIO STATIC IMPORTED GLOBAL) + add_subdirectory(builtins/cfitsio) + endif() else() message(STATUS "Looking for CFITSIO") if(fail-on-missing) @@ -985,7 +993,7 @@ foreach(suffix FOUND INCLUDE_DIR INCLUDE_DIRS LIBRARY LIBRARIES) unset(XROOTD_${suffix} CACHE) endforeach() -if(xrootd OR builtin_xrootd) +if(xrootd) # This is the target that ROOT will use, irrespective of whether XRootD is a builtin or in the system. # All targets should only link to ROOT::XRootD. Refrain from using XRootD variables. add_library(XRootD INTERFACE IMPORTED GLOBAL) @@ -1014,19 +1022,22 @@ if(xrootd AND NOT builtin_xrootd) 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") + if(NOT xrootd) + message(WARNING "xrootd is OFF, hence ignoring the activated setting 'builtin_xrootd'") + else() + 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") + endif() + list(APPEND ROOT_BUILTINS BUILTIN_XROOTD) + # The builtin XRootD requires OpenSSL. + # We have to find it here, such that OpenSSL is available in this scope to + # finalize the XRootD target configuration. + # See also: https://github.com/root-project/root/issues/16374 + find_package(OpenSSL REQUIRED) + add_subdirectory(builtins/xrootd) endif() - list(APPEND ROOT_BUILTINS BUILTIN_XROOTD) - # The builtin XRootD requires OpenSSL. - # We have to find it here, such that OpenSSL is available in this scope to - # finalize the XRootD target configuration. - # See also: https://github.com/root-project/root/issues/16374 - find_package(OpenSSL REQUIRED) - add_subdirectory(builtins/xrootd) - set(xrootd ON CACHE BOOL "Enabled because builtin_xrootd requested (${xrootd_description})" FORCE) endif() # Finalise the XRootD target configuration @@ -1185,15 +1196,18 @@ if(davix AND NOT builtin_davix) endif() if(builtin_davix) - ROOT_CHECK_CONNECTION("builtin_davix=OFF") - if(NO_CONNECTION) - message(STATUS "No internet connection, disabling the 'davix' and 'builtin_davix' options") - set(builtin_davix OFF CACHE BOOL "Disabled because there is no internet connection" FORCE) - set(davix OFF CACHE BOOL "Disabled because there is no internet connection" FORCE) + if(NOT davix) + message(WARNING "davix is OFF, hence ignoring the activated setting 'builtin_davix'") else() - list(APPEND ROOT_BUILTINS Davix) - add_subdirectory(builtins/davix) - set(davix ON CACHE BOOL "Enabled because builtin_davix is enabled)" FORCE) + ROOT_CHECK_CONNECTION("builtin_davix=OFF") + if(NO_CONNECTION) + message(STATUS "No internet connection, disabling the 'davix' and 'builtin_davix' options") + set(builtin_davix OFF CACHE BOOL "Disabled because there is no internet connection" FORCE) + set(davix OFF CACHE BOOL "Disabled because there is no internet connection" FORCE) + else() + list(APPEND ROOT_BUILTINS Davix) + add_subdirectory(builtins/davix) + endif() endif() endif() @@ -1287,15 +1301,19 @@ int main() { return 0; }" tbb_exception_result) endif() if(builtin_tbb) - ROOT_CHECK_CONNECTION("builtin_tbb=OFF") - if(NO_CONNECTION) - message(STATUS "No internet connection, disabling 'builtin_tbb' and 'imt' options") - set(builtin_tbb OFF CACHE BOOL "Disabled because there is no internet connection" FORCE) - set(imt OFF CACHE BOOL "Disabled because 'builtin_tbb' was set but there is no internet connection" FORCE) + if(NOT imt) + message(WARNING "imt is OFF, hence ignoring the activated setting 'builtin_tbb'") + else() + ROOT_CHECK_CONNECTION("builtin_tbb=OFF") + if(NO_CONNECTION) + message(STATUS "No internet connection, disabling 'builtin_tbb' and 'imt' options") + set(builtin_tbb OFF CACHE BOOL "Disabled because there is no internet connection" FORCE) + set(imt OFF CACHE BOOL "Disabled because 'builtin_tbb' was set but there is no internet connection" FORCE) + endif() endif() endif() -if(builtin_tbb) +if(builtin_tbb AND imt) set(tbb_url ${lcgpackages}/oneTBB-2021.9.0.tar.gz) set(tbb_sha256 1ce48f34dada7837f510735ff1172f6e2c261b09460e3bf773b49791d247d24e) @@ -1368,9 +1386,12 @@ endif() #---Check for Vc--------------------------------------------------------------------- if(builtin_vc) - unset(Vc_FOUND) - unset(Vc_FOUND CACHE) - set(vc ON CACHE BOOL "Enabled because builtin_vc requested (${vc_description})" FORCE) + if(NOT vc) + message(WARNING "vc is OFF, hence ignoring the activated setting 'builtin_vc'") + else() + unset(Vc_FOUND) + unset(Vc_FOUND CACHE) + endif() elseif(vc) if(fail-on-missing) find_package(Vc 1.4.4 CONFIG QUIET REQUIRED) @@ -1460,7 +1481,6 @@ endif() if(builtin_veccore) unset(VecCore_FOUND) unset(VecCore_FOUND CACHE) - set(veccore ON CACHE BOOL "Enabled because builtin_veccore requested (${veccore_description})" FORCE) elseif(veccore) if(vc) set(VecCore_COMPONENTS Vc) @@ -1485,72 +1505,76 @@ elseif(veccore) endif() endif() -if(builtin_veccore) +if(builtin_veccore AND veccore) ROOT_CHECK_CONNECTION_AND_DISABLE_OPTION("builtin_veccore") endif() if(builtin_veccore) - set(VecCore_VERSION "0.8.2") - set(VecCore_PROJECT "VecCore-${VecCore_VERSION}") - set(VecCore_SRC_URI "${lcgpackages}/${VecCore_PROJECT}.tar.gz") - set(VecCore_DESTDIR "${CMAKE_BINARY_DIR}/externals") - set(VecCore_ROOTDIR "${VecCore_DESTDIR}/${CMAKE_INSTALL_PREFIX}") - - ExternalProject_Add(VECCORE - URL ${VecCore_SRC_URI} - URL_HASH SHA256=1268bca92acf00acd9775f1e79a2da7b1d902733d17e283e0dd5e02c41ac9666 - BUILD_IN_SOURCE 0 - LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1 - CMAKE_ARGS -G ${CMAKE_GENERATOR} - -DBUILD_TESTING=OFF - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} - -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} - -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - -DCMAKE_CXX_FLAGS=${ROOT_EXTERNAL_CXX_FLAGS} - -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} - INSTALL_COMMAND env DESTDIR=${VecCore_DESTDIR} ${CMAKE_COMMAND} --build . --target install - TIMEOUT 600 - ) - - set(VECCORE_TARGET VecCore) - set(VecCore_LIBRARIES VecCore) - list(APPEND VecCore_INCLUDE_DIRS ${VecCore_ROOTDIR}/include) - - add_library(VecCore INTERFACE) - target_include_directories(VecCore SYSTEM INTERFACE $) - add_dependencies(VecCore VECCORE) - - if (Vc_FOUND) - set(VecCore_Vc_FOUND True) - set(VecCore_Vc_DEFINITIONS -DVECCORE_ENABLE_VC) - set(VecCore_Vc_INCLUDE_DIR ${Vc_INCLUDE_DIR}) - set(VecCore_Vc_LIBRARIES ${Vc_LIBRARIES}) - - set(VecCore_DEFINITIONS ${VecCore_Vc_DEFINITIONS}) - list(APPEND VecCore_INCLUDE_DIRS ${VecCore_Vc_INCLUDE_DIR}) - set(VecCore_LIBRARIES ${VecCore_LIBRARIES} ${Vc_LIBRARIES}) - target_link_libraries(VecCore INTERFACE ${Vc_LIBRARIES}) - endif() - - find_package_handle_standard_args(VecCore - FOUND_VAR VecCore_FOUND - REQUIRED_VARS VecCore_INCLUDE_DIRS VecCore_LIBRARIES - VERSION_VAR VecCore_VERSION) + if(NOT veccore) + message(WARNING "veccore is OFF, hence ignoring the activated setting 'builtin_veccore'") + else() + set(VecCore_VERSION "0.8.2") + set(VecCore_PROJECT "VecCore-${VecCore_VERSION}") + set(VecCore_SRC_URI "${lcgpackages}/${VecCore_PROJECT}.tar.gz") + set(VecCore_DESTDIR "${CMAKE_BINARY_DIR}/externals") + set(VecCore_ROOTDIR "${VecCore_DESTDIR}/${CMAKE_INSTALL_PREFIX}") + + ExternalProject_Add(VECCORE + URL ${VecCore_SRC_URI} + URL_HASH SHA256=1268bca92acf00acd9775f1e79a2da7b1d902733d17e283e0dd5e02c41ac9666 + BUILD_IN_SOURCE 0 + LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1 + CMAKE_ARGS -G ${CMAKE_GENERATOR} + -DBUILD_TESTING=OFF + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_CXX_FLAGS=${ROOT_EXTERNAL_CXX_FLAGS} + -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} + INSTALL_COMMAND env DESTDIR=${VecCore_DESTDIR} ${CMAKE_COMMAND} --build . --target install + TIMEOUT 600 + ) - # FIXME: This is a workaround to let ROOT find the headers at runtime if - # they are in the build directory. This is necessary until we decide how to - # treat externals with headers used by ROOT - if(NOT EXISTS ${CMAKE_BINARY_DIR}/include/VecCore) - if (NOT EXISTS ${CMAKE_BINARY_DIR}/include) - execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/include) + set(VECCORE_TARGET VecCore) + set(VecCore_LIBRARIES VecCore) + list(APPEND VecCore_INCLUDE_DIRS ${VecCore_ROOTDIR}/include) + + add_library(VecCore INTERFACE) + target_include_directories(VecCore SYSTEM INTERFACE $) + add_dependencies(VecCore VECCORE) + + if (Vc_FOUND) + set(VecCore_Vc_FOUND True) + set(VecCore_Vc_DEFINITIONS -DVECCORE_ENABLE_VC) + set(VecCore_Vc_INCLUDE_DIR ${Vc_INCLUDE_DIR}) + set(VecCore_Vc_LIBRARIES ${Vc_LIBRARIES}) + + set(VecCore_DEFINITIONS ${VecCore_Vc_DEFINITIONS}) + list(APPEND VecCore_INCLUDE_DIRS ${VecCore_Vc_INCLUDE_DIR}) + set(VecCore_LIBRARIES ${VecCore_LIBRARIES} ${Vc_LIBRARIES}) + target_link_libraries(VecCore INTERFACE ${Vc_LIBRARIES}) + endif() + + find_package_handle_standard_args(VecCore + FOUND_VAR VecCore_FOUND + REQUIRED_VARS VecCore_INCLUDE_DIRS VecCore_LIBRARIES + VERSION_VAR VecCore_VERSION) + + # FIXME: This is a workaround to let ROOT find the headers at runtime if + # they are in the build directory. This is necessary until we decide how to + # treat externals with headers used by ROOT + if(NOT EXISTS ${CMAKE_BINARY_DIR}/include/VecCore) + if (NOT EXISTS ${CMAKE_BINARY_DIR}/include) + execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/include) + endif() + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink + ${VecCore_ROOTDIR}/include/VecCore ${CMAKE_BINARY_DIR}/include/VecCore) endif() - execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink - ${VecCore_ROOTDIR}/include/VecCore ${CMAKE_BINARY_DIR}/include/VecCore) - endif() - # end of workaround + # end of workaround - install(DIRECTORY ${VecCore_ROOTDIR}/ DESTINATION ".") + install(DIRECTORY ${VecCore_ROOTDIR}/ DESTINATION ".") + endif() endif() if(builtin_vdt) @@ -1578,46 +1602,49 @@ if(vdt OR builtin_vdt) endif() endif() if(builtin_vdt) - set(vdt_version 0.4.6) - set(VDT_FOUND True) - set(VDT_LIBRARIES ${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}vdt${CMAKE_SHARED_LIBRARY_SUFFIX}) - ExternalProject_Add( - VDT - URL ${lcgpackages}/vdt-${vdt_version}.tar.gz - URL_HASH SHA256=1820feae446780763ec8bbb60a0dbcf3ae1ee548bdd01415b1fb905fd4f90c54 - INSTALL_DIR ${CMAKE_BINARY_DIR} - CMAKE_ARGS - -DCMAKE_POLICY_VERSION_MINIMUM=3.5 - -DSSE=OFF # breaks on ARM without this - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} - -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} - -DCMAKE_CXX_FLAGS=${ROOT_EXTERNAL_CXX_FLAGS} - -DCMAKE_INSTALL_PREFIX= - LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1 - BUILD_BYPRODUCTS ${VDT_LIBRARIES} - TIMEOUT 600 - ) - ExternalProject_Add_Step( - VDT copy2externals - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/include/vdt ${CMAKE_BINARY_DIR}/ginclude/vdt - DEPENDEES install - ) - set(VDT_INCLUDE_DIR ${CMAKE_BINARY_DIR}/ginclude) - set(VDT_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/ginclude) - install(FILES ${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}vdt${CMAKE_SHARED_LIBRARY_SUFFIX} - DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) - install(DIRECTORY ${CMAKE_BINARY_DIR}/include/vdt - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT extra-headers) - set(vdt ON CACHE BOOL "Enabled because builtin_vdt enabled (${vdt_description})" FORCE) - set_property(GLOBAL APPEND PROPERTY ROOT_BUILTIN_TARGETS VDT) - add_library(VDT::VDT STATIC IMPORTED GLOBAL) - set_target_properties(VDT::VDT - PROPERTIES - IMPORTED_LOCATION "${VDT_LIBRARIES}" - INTERFACE_INCLUDE_DIRECTORIES "${VDT_INCLUDE_DIRS}" - ) + if(NOT vdt) + message(WARNING "vdt is OFF, hence ignoring the activated setting 'builtin_vdt'") + else() + set(vdt_version 0.4.6) + set(VDT_FOUND True) + set(VDT_LIBRARIES ${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}vdt${CMAKE_SHARED_LIBRARY_SUFFIX}) + ExternalProject_Add( + VDT + URL ${lcgpackages}/vdt-${vdt_version}.tar.gz + URL_HASH SHA256=1820feae446780763ec8bbb60a0dbcf3ae1ee548bdd01415b1fb905fd4f90c54 + INSTALL_DIR ${CMAKE_BINARY_DIR} + CMAKE_ARGS + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 + -DSSE=OFF # breaks on ARM without this + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} + -DCMAKE_CXX_FLAGS=${ROOT_EXTERNAL_CXX_FLAGS} + -DCMAKE_INSTALL_PREFIX= + LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1 + BUILD_BYPRODUCTS ${VDT_LIBRARIES} + TIMEOUT 600 + ) + ExternalProject_Add_Step( + VDT copy2externals + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/include/vdt ${CMAKE_BINARY_DIR}/ginclude/vdt + DEPENDEES install + ) + set(VDT_INCLUDE_DIR ${CMAKE_BINARY_DIR}/ginclude) + set(VDT_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/ginclude) + install(FILES ${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}vdt${CMAKE_SHARED_LIBRARY_SUFFIX} + DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) + install(DIRECTORY ${CMAKE_BINARY_DIR}/include/vdt + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT extra-headers) + set_property(GLOBAL APPEND PROPERTY ROOT_BUILTIN_TARGETS VDT) + add_library(VDT::VDT STATIC IMPORTED GLOBAL) + set_target_properties(VDT::VDT + PROPERTIES + IMPORTED_LOCATION "${VDT_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${VDT_INCLUDE_DIRS}" + ) + endif() endif() endif() From 9b9d3ebdecf77be2ee6cbcc2422051c0838c49b7 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Tue, 15 Apr 2025 11:44:18 +0200 Subject: [PATCH 2/7] [cmake] fix typo in fitsio --- cmake/modules/SearchInstalledSoftware.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake index bd35f74d11e9e..8a1b9e4ab4777 100644 --- a/cmake/modules/SearchInstalledSoftware.cmake +++ b/cmake/modules/SearchInstalledSoftware.cmake @@ -956,8 +956,8 @@ if(fitsio OR builtin_cfitsio) ROOT_CHECK_CONNECTION_AND_DISABLE_OPTION("builtin_cfitsio") endif() if(builtin_cfitsio) - if(NOT cfitsio) - message(WARNING "cfitsio is OFF, hence ignoring the activated setting 'builtin_cfitsio'") + if(NOT fitsio) + message(WARNING "fitsio is OFF, hence ignoring the activated setting 'builtin_cfitsio'") else() add_library(CFITSIO::CFITSIO STATIC IMPORTED GLOBAL) add_subdirectory(builtins/cfitsio) From 153c706481c209d29432df34f66b9982eeac4e19 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Tue, 22 Apr 2025 09:08:01 +0200 Subject: [PATCH 3/7] [cmake] fftw3 ON is allowed to turn on builtin_fftw3 as in the rest of features --- cmake/modules/SearchInstalledSoftware.cmake | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake index 8a1b9e4ab4777..91ee191756d91 100644 --- a/cmake/modules/SearchInstalledSoftware.cmake +++ b/cmake/modules/SearchInstalledSoftware.cmake @@ -915,13 +915,17 @@ if(fftw3) message(STATUS "Looking for FFTW3") find_package(FFTW) if(NOT FFTW_FOUND) - if(fail-on-missing) - message(SEND_ERROR "FFTW3 libraries not found and they are required (fftw3 option enabled)") - 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) + set(builtin_fftw3 ON CACHE BOOL "Enabled because FFTW3 not found (${fftw3_description})" FORCE) + ROOT_CHECK_CONNECTION_AND_DISABLE_OPTION("builtin_fftw3") + if(NOT builtin_fftw3) + if(fail-on-missing) + message(SEND_ERROR "FFTW3 libraries not found and they are required (fftw3 option enabled)") + else() + message(STATUS "FFTW3 not found. Set [environment] variable FFTW_DIR to point to your FFTW3 installation") + message(STATUS " Alternatively, you can also enable your Internet connection so that the autoset option 'builtin_fftw3' can 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 unavailable (${fftw3_description})" FORCE) + endif() endif() endif() endif() From 7b85c0d47fa81457bb2d97ff8f3993349e2121ad Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Tue, 22 Apr 2025 19:48:08 +0200 Subject: [PATCH 4/7] [cmake] convert warnings into errors if a conflict is found --- cmake/modules/SearchInstalledSoftware.cmake | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake index 91ee191756d91..e505ab8038680 100644 --- a/cmake/modules/SearchInstalledSoftware.cmake +++ b/cmake/modules/SearchInstalledSoftware.cmake @@ -644,7 +644,7 @@ if(mathmore OR builtin_gsl OR (tmva-cpu AND use_gsl_cblas)) set(GSL_INCLUDE_DIR ${CMAKE_BINARY_DIR}/GSL-prefix/src/GSL-build) set(GSL_FOUND ON) if(NOT mathmore) - message(WARNING "builtin_gls was enabled but mathmore wasn't") + message(FATAL_ERROR "builtin_gls was enabled, conflict with mathmore=OFF") endif() endif() endif() @@ -932,7 +932,7 @@ if(fftw3) endif() if(builtin_fftw3) if(NOT fftw3) - message(WARNING "fftw3 is OFF, hence ignoring the activated setting 'builtin_fftw3'") + message(FATAL_ERROR "fftw3 is OFF, conflict with the activated setting 'builtin_fftw3'") else() set(FFTW_VERSION 3.3.8) message(STATUS "Downloading and building FFTW version ${FFTW_VERSION}") @@ -961,7 +961,7 @@ if(fitsio OR builtin_cfitsio) endif() if(builtin_cfitsio) if(NOT fitsio) - message(WARNING "fitsio is OFF, hence ignoring the activated setting 'builtin_cfitsio'") + message(FATAL_ERROR "fitsio is OFF, conflict with the activated setting 'builtin_cfitsio'") else() add_library(CFITSIO::CFITSIO STATIC IMPORTED GLOBAL) add_subdirectory(builtins/cfitsio) @@ -1027,7 +1027,7 @@ endif() if(builtin_xrootd) if(NOT xrootd) - message(WARNING "xrootd is OFF, hence ignoring the activated setting 'builtin_xrootd'") + message(FATAL_ERROR "xrootd is OFF, conflict with the activated setting 'builtin_xrootd'") else() ROOT_CHECK_CONNECTION("builtin_xrootd=OFF") if(NO_CONNECTION) @@ -1201,7 +1201,7 @@ endif() if(builtin_davix) if(NOT davix) - message(WARNING "davix is OFF, hence ignoring the activated setting 'builtin_davix'") + message(FATAL_ERROR "davix is OFF, conflict with the activated setting 'builtin_davix'") else() ROOT_CHECK_CONNECTION("builtin_davix=OFF") if(NO_CONNECTION) @@ -1306,7 +1306,7 @@ endif() if(builtin_tbb) if(NOT imt) - message(WARNING "imt is OFF, hence ignoring the activated setting 'builtin_tbb'") + message(FATAL_ERROR "imt is OFF, conflict with the activated setting 'builtin_tbb'") else() ROOT_CHECK_CONNECTION("builtin_tbb=OFF") if(NO_CONNECTION) @@ -1391,7 +1391,7 @@ endif() #---Check for Vc--------------------------------------------------------------------- if(builtin_vc) if(NOT vc) - message(WARNING "vc is OFF, hence ignoring the activated setting 'builtin_vc'") + message(FATAL_ERROR "vc is OFF, conflict with the activated setting 'builtin_vc'") else() unset(Vc_FOUND) unset(Vc_FOUND CACHE) @@ -1515,7 +1515,7 @@ endif() if(builtin_veccore) if(NOT veccore) - message(WARNING "veccore is OFF, hence ignoring the activated setting 'builtin_veccore'") + message(FATAL_ERROR "veccore is OFF, conflict with the activated setting 'builtin_veccore'") else() set(VecCore_VERSION "0.8.2") set(VecCore_PROJECT "VecCore-${VecCore_VERSION}") @@ -1607,7 +1607,7 @@ if(vdt OR builtin_vdt) endif() if(builtin_vdt) if(NOT vdt) - message(WARNING "vdt is OFF, hence ignoring the activated setting 'builtin_vdt'") + message(FATAL_ERROR "vdt is OFF, conflict with the activated setting 'builtin_vdt'") else() set(vdt_version 0.4.6) set(VDT_FOUND True) From 1578e4383422e8862fd91ef6f71ad072da293fb0 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Tue, 22 Apr 2025 20:13:36 +0200 Subject: [PATCH 5/7] restore to original behavior as suggested by pcanal --- cmake/modules/SearchInstalledSoftware.cmake | 326 ++++++++++---------- 1 file changed, 159 insertions(+), 167 deletions(-) diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake index e505ab8038680..cc54fbb17c944 100644 --- a/cmake/modules/SearchInstalledSoftware.cmake +++ b/cmake/modules/SearchInstalledSoftware.cmake @@ -644,7 +644,7 @@ if(mathmore OR builtin_gsl OR (tmva-cpu AND use_gsl_cblas)) set(GSL_INCLUDE_DIR ${CMAKE_BINARY_DIR}/GSL-prefix/src/GSL-build) set(GSL_FOUND ON) if(NOT mathmore) - message(FATAL_ERROR "builtin_gls was enabled, conflict with mathmore=OFF") + set(mathmore ON CACHE BOOL "Enabled because builtin_gls requested (${mathmore_description})" FORCE) endif() endif() endif() @@ -717,7 +717,7 @@ if((opengl OR cocoa) AND NOT builtin_glew) # Bug in CMake on Mac OS X until 3.25: # https://gitlab.kitware.com/cmake/cmake/-/issues/19662 # https://github.com/microsoft/vcpkg/pull/7967 - message(FATAL_ERROR "Please enable builtin Glew due a bug in CMake's FindGlew < v3.25 (use cmake option -Dbuiltin_glew=ON).") + message(FATAL_ERROR "Please enable builtin Glew due to a bug in CMake's FindGlew < v3.25 (use cmake option -Dbuiltin_glew=ON).") unset(GLEW_FOUND) elseif(GLEW_FOUND AND NOT TARGET GLEW::GLEW) add_library(GLEW::GLEW UNKNOWN IMPORTED) @@ -932,26 +932,25 @@ if(fftw3) endif() if(builtin_fftw3) if(NOT fftw3) - message(FATAL_ERROR "fftw3 is OFF, conflict with the activated setting 'builtin_fftw3'") - else() - set(FFTW_VERSION 3.3.8) - message(STATUS "Downloading and building FFTW version ${FFTW_VERSION}") - set(FFTW_LIBRARIES ${CMAKE_BINARY_DIR}/lib/libfftw3.a) - ExternalProject_Add( - FFTW3 - URL ${lcgpackages}/fftw-${FFTW_VERSION}.tar.gz - URL_HASH SHA256=6113262f6e92c5bd474f2875fa1b01054c4ad5040f6b0da7c03c98821d9ae303 - INSTALL_DIR ${CMAKE_BINARY_DIR} - CONFIGURE_COMMAND ./configure --prefix= - BUILD_COMMAND make CFLAGS=-fPIC - LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1 - BUILD_IN_SOURCE 1 - BUILD_BYPRODUCTS ${FFTW_LIBRARIES} - TIMEOUT 600 - ) - set(FFTW_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include) - set(FFTW3_TARGET FFTW3) + set(fftw3 ON CACHE BOOL "Enabled because builtin_fftw3 requested (${fftw3_description})" FORCE) endif() + set(FFTW_VERSION 3.3.8) + message(STATUS "Downloading and building FFTW version ${FFTW_VERSION}") + set(FFTW_LIBRARIES ${CMAKE_BINARY_DIR}/lib/libfftw3.a) + ExternalProject_Add( + FFTW3 + URL ${lcgpackages}/fftw-${FFTW_VERSION}.tar.gz + URL_HASH SHA256=6113262f6e92c5bd474f2875fa1b01054c4ad5040f6b0da7c03c98821d9ae303 + INSTALL_DIR ${CMAKE_BINARY_DIR} + CONFIGURE_COMMAND ./configure --prefix= + BUILD_COMMAND make CFLAGS=-fPIC + LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1 + BUILD_IN_SOURCE 1 + BUILD_BYPRODUCTS ${FFTW_LIBRARIES} + TIMEOUT 600 + ) + set(FFTW_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include) + set(FFTW3_TARGET FFTW3) endif() #---Check for fitsio------------------------------------------------------------------- @@ -961,11 +960,10 @@ if(fitsio OR builtin_cfitsio) endif() if(builtin_cfitsio) if(NOT fitsio) - message(FATAL_ERROR "fitsio is OFF, conflict with the activated setting 'builtin_cfitsio'") - else() - add_library(CFITSIO::CFITSIO STATIC IMPORTED GLOBAL) - add_subdirectory(builtins/cfitsio) + set(fitsio ON CACHE BOOL "Enabled because builtin_cfitsio requested (${fitsio_description})" FORCE) endif() + add_library(CFITSIO::CFITSIO STATIC IMPORTED GLOBAL) + add_subdirectory(builtins/cfitsio) else() message(STATUS "Looking for CFITSIO") if(fail-on-missing) @@ -997,7 +995,7 @@ foreach(suffix FOUND INCLUDE_DIR INCLUDE_DIRS LIBRARY LIBRARIES) unset(XROOTD_${suffix} CACHE) endforeach() -if(xrootd) +if(xrootd OR builtin_xrootd) # This is the target that ROOT will use, irrespective of whether XRootD is a builtin or in the system. # All targets should only link to ROOT::XRootD. Refrain from using XRootD variables. add_library(XRootD INTERFACE IMPORTED GLOBAL) @@ -1027,21 +1025,20 @@ endif() if(builtin_xrootd) if(NOT xrootd) - message(FATAL_ERROR "xrootd is OFF, conflict with the activated setting 'builtin_xrootd'") - else() - 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") - endif() - list(APPEND ROOT_BUILTINS BUILTIN_XROOTD) - # The builtin XRootD requires OpenSSL. - # We have to find it here, such that OpenSSL is available in this scope to - # finalize the XRootD target configuration. - # See also: https://github.com/root-project/root/issues/16374 - find_package(OpenSSL REQUIRED) - add_subdirectory(builtins/xrootd) + set(xrootd ON CACHE BOOL "Enabled because builtin_xrootd requested (${xrootd_description})" FORCE) endif() + 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") + endif() + list(APPEND ROOT_BUILTINS BUILTIN_XROOTD) + # The builtin XRootD requires OpenSSL. + # We have to find it here, such that OpenSSL is available in this scope to + # finalize the XRootD target configuration. + # See also: https://github.com/root-project/root/issues/16374 + find_package(OpenSSL REQUIRED) + add_subdirectory(builtins/xrootd) endif() # Finalise the XRootD target configuration @@ -1201,17 +1198,16 @@ endif() if(builtin_davix) if(NOT davix) - message(FATAL_ERROR "davix is OFF, conflict with the activated setting 'builtin_davix'") + set(davix ON CACHE BOOL "Enabled because builtin_davix is enabled (${davix_description})" FORCE) + endif() + ROOT_CHECK_CONNECTION("builtin_davix=OFF") + if(NO_CONNECTION) + message(STATUS "No internet connection, disabling the 'davix' and 'builtin_davix' options") + set(builtin_davix OFF CACHE BOOL "Disabled because there is no internet connection" FORCE) + set(davix OFF CACHE BOOL "Disabled because there is no internet connection" FORCE) else() - ROOT_CHECK_CONNECTION("builtin_davix=OFF") - if(NO_CONNECTION) - message(STATUS "No internet connection, disabling the 'davix' and 'builtin_davix' options") - set(builtin_davix OFF CACHE BOOL "Disabled because there is no internet connection" FORCE) - set(davix OFF CACHE BOOL "Disabled because there is no internet connection" FORCE) - else() - list(APPEND ROOT_BUILTINS Davix) - add_subdirectory(builtins/davix) - endif() + list(APPEND ROOT_BUILTINS Davix) + add_subdirectory(builtins/davix) endif() endif() @@ -1306,18 +1302,17 @@ endif() if(builtin_tbb) if(NOT imt) - message(FATAL_ERROR "imt is OFF, conflict with the activated setting 'builtin_tbb'") - else() - ROOT_CHECK_CONNECTION("builtin_tbb=OFF") - if(NO_CONNECTION) - message(STATUS "No internet connection, disabling 'builtin_tbb' and 'imt' options") - set(builtin_tbb OFF CACHE BOOL "Disabled because there is no internet connection" FORCE) - set(imt OFF CACHE BOOL "Disabled because 'builtin_tbb' was set but there is no internet connection" FORCE) - endif() + set(imt ON CACHE BOOL "Enabled because builtin_tbb is enabled (${imt_description})" FORCE) + endif() + ROOT_CHECK_CONNECTION("builtin_tbb=OFF") + if(NO_CONNECTION) + message(STATUS "No internet connection, disabling 'builtin_tbb' and 'imt' options") + set(builtin_tbb OFF CACHE BOOL "Disabled because there is no internet connection" FORCE) + set(imt OFF CACHE BOOL "Disabled because 'builtin_tbb' was set but there is no internet connection" FORCE) endif() endif() -if(builtin_tbb AND imt) +if(builtin_tbb) set(tbb_url ${lcgpackages}/oneTBB-2021.9.0.tar.gz) set(tbb_sha256 1ce48f34dada7837f510735ff1172f6e2c261b09460e3bf773b49791d247d24e) @@ -1390,11 +1385,10 @@ endif() #---Check for Vc--------------------------------------------------------------------- if(builtin_vc) + unset(Vc_FOUND) + unset(Vc_FOUND CACHE) if(NOT vc) - message(FATAL_ERROR "vc is OFF, conflict with the activated setting 'builtin_vc'") - else() - unset(Vc_FOUND) - unset(Vc_FOUND CACHE) + set(vc ON CACHE BOOL "Enabled because builtin_vc requested (${vc_description})" FORCE) endif() elseif(vc) if(fail-on-missing) @@ -1485,6 +1479,9 @@ endif() if(builtin_veccore) unset(VecCore_FOUND) unset(VecCore_FOUND CACHE) + if(NOT vc) + set(veccore ON CACHE BOOL "Enabled because builtin_veccore requested (${veccore_description})" FORCE) + endif() elseif(veccore) if(vc) set(VecCore_COMPONENTS Vc) @@ -1509,76 +1506,72 @@ elseif(veccore) endif() endif() -if(builtin_veccore AND veccore) +if(builtin_veccore) ROOT_CHECK_CONNECTION_AND_DISABLE_OPTION("builtin_veccore") endif() if(builtin_veccore) - if(NOT veccore) - message(FATAL_ERROR "veccore is OFF, conflict with the activated setting 'builtin_veccore'") - else() - set(VecCore_VERSION "0.8.2") - set(VecCore_PROJECT "VecCore-${VecCore_VERSION}") - set(VecCore_SRC_URI "${lcgpackages}/${VecCore_PROJECT}.tar.gz") - set(VecCore_DESTDIR "${CMAKE_BINARY_DIR}/externals") - set(VecCore_ROOTDIR "${VecCore_DESTDIR}/${CMAKE_INSTALL_PREFIX}") - - ExternalProject_Add(VECCORE - URL ${VecCore_SRC_URI} - URL_HASH SHA256=1268bca92acf00acd9775f1e79a2da7b1d902733d17e283e0dd5e02c41ac9666 - BUILD_IN_SOURCE 0 - LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1 - CMAKE_ARGS -G ${CMAKE_GENERATOR} - -DBUILD_TESTING=OFF - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} - -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} - -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - -DCMAKE_CXX_FLAGS=${ROOT_EXTERNAL_CXX_FLAGS} - -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} - INSTALL_COMMAND env DESTDIR=${VecCore_DESTDIR} ${CMAKE_COMMAND} --build . --target install - TIMEOUT 600 - ) + set(VecCore_VERSION "0.8.2") + set(VecCore_PROJECT "VecCore-${VecCore_VERSION}") + set(VecCore_SRC_URI "${lcgpackages}/${VecCore_PROJECT}.tar.gz") + set(VecCore_DESTDIR "${CMAKE_BINARY_DIR}/externals") + set(VecCore_ROOTDIR "${VecCore_DESTDIR}/${CMAKE_INSTALL_PREFIX}") + + ExternalProject_Add(VECCORE + URL ${VecCore_SRC_URI} + URL_HASH SHA256=1268bca92acf00acd9775f1e79a2da7b1d902733d17e283e0dd5e02c41ac9666 + BUILD_IN_SOURCE 0 + LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1 + CMAKE_ARGS -G ${CMAKE_GENERATOR} + -DBUILD_TESTING=OFF + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_CXX_FLAGS=${ROOT_EXTERNAL_CXX_FLAGS} + -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} + INSTALL_COMMAND env DESTDIR=${VecCore_DESTDIR} ${CMAKE_COMMAND} --build . --target install + TIMEOUT 600 + ) - set(VECCORE_TARGET VecCore) - set(VecCore_LIBRARIES VecCore) - list(APPEND VecCore_INCLUDE_DIRS ${VecCore_ROOTDIR}/include) - - add_library(VecCore INTERFACE) - target_include_directories(VecCore SYSTEM INTERFACE $) - add_dependencies(VecCore VECCORE) - - if (Vc_FOUND) - set(VecCore_Vc_FOUND True) - set(VecCore_Vc_DEFINITIONS -DVECCORE_ENABLE_VC) - set(VecCore_Vc_INCLUDE_DIR ${Vc_INCLUDE_DIR}) - set(VecCore_Vc_LIBRARIES ${Vc_LIBRARIES}) - - set(VecCore_DEFINITIONS ${VecCore_Vc_DEFINITIONS}) - list(APPEND VecCore_INCLUDE_DIRS ${VecCore_Vc_INCLUDE_DIR}) - set(VecCore_LIBRARIES ${VecCore_LIBRARIES} ${Vc_LIBRARIES}) - target_link_libraries(VecCore INTERFACE ${Vc_LIBRARIES}) - endif() - - find_package_handle_standard_args(VecCore - FOUND_VAR VecCore_FOUND - REQUIRED_VARS VecCore_INCLUDE_DIRS VecCore_LIBRARIES - VERSION_VAR VecCore_VERSION) - - # FIXME: This is a workaround to let ROOT find the headers at runtime if - # they are in the build directory. This is necessary until we decide how to - # treat externals with headers used by ROOT - if(NOT EXISTS ${CMAKE_BINARY_DIR}/include/VecCore) - if (NOT EXISTS ${CMAKE_BINARY_DIR}/include) - execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/include) - endif() - execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink - ${VecCore_ROOTDIR}/include/VecCore ${CMAKE_BINARY_DIR}/include/VecCore) - endif() - # end of workaround + set(VECCORE_TARGET VecCore) + set(VecCore_LIBRARIES VecCore) + list(APPEND VecCore_INCLUDE_DIRS ${VecCore_ROOTDIR}/include) + + add_library(VecCore INTERFACE) + target_include_directories(VecCore SYSTEM INTERFACE $) + add_dependencies(VecCore VECCORE) - install(DIRECTORY ${VecCore_ROOTDIR}/ DESTINATION ".") + if (Vc_FOUND) + set(VecCore_Vc_FOUND True) + set(VecCore_Vc_DEFINITIONS -DVECCORE_ENABLE_VC) + set(VecCore_Vc_INCLUDE_DIR ${Vc_INCLUDE_DIR}) + set(VecCore_Vc_LIBRARIES ${Vc_LIBRARIES}) + + set(VecCore_DEFINITIONS ${VecCore_Vc_DEFINITIONS}) + list(APPEND VecCore_INCLUDE_DIRS ${VecCore_Vc_INCLUDE_DIR}) + set(VecCore_LIBRARIES ${VecCore_LIBRARIES} ${Vc_LIBRARIES}) + target_link_libraries(VecCore INTERFACE ${Vc_LIBRARIES}) endif() + + find_package_handle_standard_args(VecCore + FOUND_VAR VecCore_FOUND + REQUIRED_VARS VecCore_INCLUDE_DIRS VecCore_LIBRARIES + VERSION_VAR VecCore_VERSION) + + # FIXME: This is a workaround to let ROOT find the headers at runtime if + # they are in the build directory. This is necessary until we decide how to + # treat externals with headers used by ROOT + if(NOT EXISTS ${CMAKE_BINARY_DIR}/include/VecCore) + if (NOT EXISTS ${CMAKE_BINARY_DIR}/include) + execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/include) + endif() + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink + ${VecCore_ROOTDIR}/include/VecCore ${CMAKE_BINARY_DIR}/include/VecCore) + endif() + # end of workaround + + install(DIRECTORY ${VecCore_ROOTDIR}/ DESTINATION ".") endif() if(builtin_vdt) @@ -1607,48 +1600,47 @@ if(vdt OR builtin_vdt) endif() if(builtin_vdt) if(NOT vdt) - message(FATAL_ERROR "vdt is OFF, conflict with the activated setting 'builtin_vdt'") - else() - set(vdt_version 0.4.6) - set(VDT_FOUND True) - set(VDT_LIBRARIES ${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}vdt${CMAKE_SHARED_LIBRARY_SUFFIX}) - ExternalProject_Add( - VDT - URL ${lcgpackages}/vdt-${vdt_version}.tar.gz - URL_HASH SHA256=1820feae446780763ec8bbb60a0dbcf3ae1ee548bdd01415b1fb905fd4f90c54 - INSTALL_DIR ${CMAKE_BINARY_DIR} - CMAKE_ARGS - -DCMAKE_POLICY_VERSION_MINIMUM=3.5 - -DSSE=OFF # breaks on ARM without this - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} - -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} - -DCMAKE_CXX_FLAGS=${ROOT_EXTERNAL_CXX_FLAGS} - -DCMAKE_INSTALL_PREFIX= - LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1 - BUILD_BYPRODUCTS ${VDT_LIBRARIES} - TIMEOUT 600 - ) - ExternalProject_Add_Step( - VDT copy2externals - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/include/vdt ${CMAKE_BINARY_DIR}/ginclude/vdt - DEPENDEES install - ) - set(VDT_INCLUDE_DIR ${CMAKE_BINARY_DIR}/ginclude) - set(VDT_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/ginclude) - install(FILES ${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}vdt${CMAKE_SHARED_LIBRARY_SUFFIX} - DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) - install(DIRECTORY ${CMAKE_BINARY_DIR}/include/vdt - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT extra-headers) - set_property(GLOBAL APPEND PROPERTY ROOT_BUILTIN_TARGETS VDT) - add_library(VDT::VDT STATIC IMPORTED GLOBAL) - set_target_properties(VDT::VDT - PROPERTIES - IMPORTED_LOCATION "${VDT_LIBRARIES}" - INTERFACE_INCLUDE_DIRECTORIES "${VDT_INCLUDE_DIRS}" - ) + set(vdt ON CACHE BOOL "Enabled because builtin_vdt enabled (${vdt_description})" FORCE) endif() + set(vdt_version 0.4.6) + set(VDT_FOUND True) + set(VDT_LIBRARIES ${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}vdt${CMAKE_SHARED_LIBRARY_SUFFIX}) + ExternalProject_Add( + VDT + URL ${lcgpackages}/vdt-${vdt_version}.tar.gz + URL_HASH SHA256=1820feae446780763ec8bbb60a0dbcf3ae1ee548bdd01415b1fb905fd4f90c54 + INSTALL_DIR ${CMAKE_BINARY_DIR} + CMAKE_ARGS + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 + -DSSE=OFF # breaks on ARM without this + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} + -DCMAKE_CXX_FLAGS=${ROOT_EXTERNAL_CXX_FLAGS} + -DCMAKE_INSTALL_PREFIX= + LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1 + BUILD_BYPRODUCTS ${VDT_LIBRARIES} + TIMEOUT 600 + ) + ExternalProject_Add_Step( + VDT copy2externals + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/include/vdt ${CMAKE_BINARY_DIR}/ginclude/vdt + DEPENDEES install + ) + set(VDT_INCLUDE_DIR ${CMAKE_BINARY_DIR}/ginclude) + set(VDT_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/ginclude) + install(FILES ${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}vdt${CMAKE_SHARED_LIBRARY_SUFFIX} + DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) + install(DIRECTORY ${CMAKE_BINARY_DIR}/include/vdt + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT extra-headers) + set_property(GLOBAL APPEND PROPERTY ROOT_BUILTIN_TARGETS VDT) + add_library(VDT::VDT STATIC IMPORTED GLOBAL) + set_target_properties(VDT::VDT + PROPERTIES + IMPORTED_LOCATION "${VDT_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${VDT_INCLUDE_DIRS}" + ) endif() endif() From d4aeb014b42ec29974f5407d46c865a7a3b02c63 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Wed, 23 Apr 2025 11:02:33 +0200 Subject: [PATCH 6/7] [cmake] do not force-enable if user set feature explicitly to OFF --- cmake/modules/SearchInstalledSoftware.cmake | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake index cc54fbb17c944..feec708bc0f8b 100644 --- a/cmake/modules/SearchInstalledSoftware.cmake +++ b/cmake/modules/SearchInstalledSoftware.cmake @@ -644,7 +644,7 @@ if(mathmore OR builtin_gsl OR (tmva-cpu AND use_gsl_cblas)) set(GSL_INCLUDE_DIR ${CMAKE_BINARY_DIR}/GSL-prefix/src/GSL-build) set(GSL_FOUND ON) if(NOT mathmore) - set(mathmore ON CACHE BOOL "Enabled because builtin_gls requested (${mathmore_description})" FORCE) + set(mathmore ON CACHE BOOL "Enabled because builtin_gls requested (${mathmore_description})") endif() endif() endif() @@ -694,7 +694,7 @@ endif() if(NOT WIN32 AND NOT APPLE) if(opengl AND NOT x11) message(STATUS "OpenGL was disabled, since it is requires x11 on Linux") - set(opengl OFF CACHE BOOL "OpenGL requires x11" FORCE) + set(opengl OFF CACHE BOOL "Disabled because OpenGL requires x11" FORCE) endif() endif() # The opengl flag enables the graf3d features that depend on OpenGL, and these @@ -932,7 +932,7 @@ if(fftw3) endif() if(builtin_fftw3) if(NOT fftw3) - set(fftw3 ON CACHE BOOL "Enabled because builtin_fftw3 requested (${fftw3_description})" FORCE) + set(fftw3 ON CACHE BOOL "Enabled because builtin_fftw3 requested (${fftw3_description})") endif() set(FFTW_VERSION 3.3.8) message(STATUS "Downloading and building FFTW version ${FFTW_VERSION}") @@ -960,7 +960,7 @@ if(fitsio OR builtin_cfitsio) endif() if(builtin_cfitsio) if(NOT fitsio) - set(fitsio ON CACHE BOOL "Enabled because builtin_cfitsio requested (${fitsio_description})" FORCE) + set(fitsio ON CACHE BOOL "Enabled because builtin_cfitsio requested (${fitsio_description})") endif() add_library(CFITSIO::CFITSIO STATIC IMPORTED GLOBAL) add_subdirectory(builtins/cfitsio) @@ -1025,7 +1025,7 @@ endif() if(builtin_xrootd) if(NOT xrootd) - set(xrootd ON CACHE BOOL "Enabled because builtin_xrootd requested (${xrootd_description})" FORCE) + set(xrootd ON CACHE BOOL "Enabled because builtin_xrootd requested (${xrootd_description})") endif() ROOT_CHECK_CONNECTION("builtin_xrootd=OFF") if(NO_CONNECTION) @@ -1198,7 +1198,7 @@ endif() if(builtin_davix) if(NOT davix) - set(davix ON CACHE BOOL "Enabled because builtin_davix is enabled (${davix_description})" FORCE) + set(davix ON CACHE BOOL "Enabled because builtin_davix is enabled (${davix_description})") endif() ROOT_CHECK_CONNECTION("builtin_davix=OFF") if(NO_CONNECTION) @@ -1302,7 +1302,7 @@ endif() if(builtin_tbb) if(NOT imt) - set(imt ON CACHE BOOL "Enabled because builtin_tbb is enabled (${imt_description})" FORCE) + set(imt ON CACHE BOOL "Enabled because builtin_tbb is enabled (${imt_description})") endif() ROOT_CHECK_CONNECTION("builtin_tbb=OFF") if(NO_CONNECTION) @@ -1388,7 +1388,7 @@ if(builtin_vc) unset(Vc_FOUND) unset(Vc_FOUND CACHE) if(NOT vc) - set(vc ON CACHE BOOL "Enabled because builtin_vc requested (${vc_description})" FORCE) + set(vc ON CACHE BOOL "Enabled because builtin_vc requested (${vc_description})") endif() elseif(vc) if(fail-on-missing) @@ -1480,7 +1480,7 @@ if(builtin_veccore) unset(VecCore_FOUND) unset(VecCore_FOUND CACHE) if(NOT vc) - set(veccore ON CACHE BOOL "Enabled because builtin_veccore requested (${veccore_description})" FORCE) + set(veccore ON CACHE BOOL "Enabled because builtin_veccore requested (${veccore_description})") endif() elseif(veccore) if(vc) @@ -1600,7 +1600,7 @@ if(vdt OR builtin_vdt) endif() if(builtin_vdt) if(NOT vdt) - set(vdt ON CACHE BOOL "Enabled because builtin_vdt enabled (${vdt_description})" FORCE) + set(vdt ON CACHE BOOL "Enabled because builtin_vdt enabled (${vdt_description})") endif() set(vdt_version 0.4.6) set(VDT_FOUND True) From 4a847a9fff621e860fb8392aaef97b0a9e1c9ba0 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Fri, 2 May 2025 21:48:14 +0200 Subject: [PATCH 7/7] fix typo --- cmake/modules/SearchInstalledSoftware.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake index feec708bc0f8b..44f02f7e8b86d 100644 --- a/cmake/modules/SearchInstalledSoftware.cmake +++ b/cmake/modules/SearchInstalledSoftware.cmake @@ -644,7 +644,7 @@ if(mathmore OR builtin_gsl OR (tmva-cpu AND use_gsl_cblas)) set(GSL_INCLUDE_DIR ${CMAKE_BINARY_DIR}/GSL-prefix/src/GSL-build) set(GSL_FOUND ON) if(NOT mathmore) - set(mathmore ON CACHE BOOL "Enabled because builtin_gls requested (${mathmore_description})") + set(mathmore ON CACHE BOOL "Enabled because builtin_gsl requested (${mathmore_description})") endif() endif() endif()