Skip to content

[cmake] explicit feature=OFF should have hierarchical priority over cached or explicit builtin_feature=ON v2 #18467

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
57 changes: 40 additions & 17 deletions cmake/modules/SearchInstalledSoftware.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,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_gls requested (${mathmore_description})" FORCE)
if(NOT mathmore)
set(mathmore ON CACHE BOOL "Enabled because builtin_gls requested (${mathmore_description})")
endif()
endif()
endif()

Expand Down Expand Up @@ -691,7 +693,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
Expand All @@ -714,7 +716,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)
Expand Down Expand Up @@ -912,18 +914,25 @@ if(fftw3)
message(STATUS "Looking for FFTW3")
find_package(FFTW)
if(NOT FFTW_FOUND)
if(fail-on-missing)
message(FATAL_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(FATAL_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()
endif()
if(builtin_fftw3)
if(NOT fftw3)
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}")
set(FFTW_LIBRARIES ${CMAKE_BINARY_DIR}/lib/libfftw3.a)
Expand All @@ -941,7 +950,6 @@ if(builtin_fftw3)
)
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()

#---Check for fitsio-------------------------------------------------------------------
Expand All @@ -950,9 +958,11 @@ if(fitsio OR builtin_cfitsio)
ROOT_CHECK_CONNECTION_AND_DISABLE_OPTION("builtin_cfitsio")
endif()
if(builtin_cfitsio)
if(NOT fitsio)
set(fitsio ON CACHE BOOL "Enabled because builtin_cfitsio requested (${fitsio_description})")
endif()
add_library(CFITSIO::CFITSIO STATIC IMPORTED GLOBAL)
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)
Expand Down Expand Up @@ -1013,6 +1023,9 @@ if(xrootd AND NOT builtin_xrootd)
endif()

if(builtin_xrootd)
if(NOT xrootd)
set(xrootd ON CACHE BOOL "Enabled because builtin_xrootd requested (${xrootd_description})")
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'"
Expand All @@ -1025,7 +1038,6 @@ if(builtin_xrootd)
# 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
Expand Down Expand Up @@ -1184,6 +1196,9 @@ if(davix AND NOT builtin_davix)
endif()

if(builtin_davix)
if(NOT davix)
set(davix ON CACHE BOOL "Enabled because builtin_davix is enabled (${davix_description})")
endif()
ROOT_CHECK_CONNECTION("builtin_davix=OFF")
if(NO_CONNECTION)
message(STATUS "No internet connection, disabling the 'davix' and 'builtin_davix' options")
Expand All @@ -1192,7 +1207,6 @@ if(builtin_davix)
else()
list(APPEND ROOT_BUILTINS Davix)
add_subdirectory(builtins/davix)
set(davix ON CACHE BOOL "Enabled because builtin_davix is enabled)" FORCE)
endif()
endif()

Expand Down Expand Up @@ -1286,6 +1300,9 @@ int main() { return 0; }" tbb_exception_result)
endif()

if(builtin_tbb)
if(NOT imt)
set(imt ON CACHE BOOL "Enabled because builtin_tbb is enabled (${imt_description})")
endif()
ROOT_CHECK_CONNECTION("builtin_tbb=OFF")
if(NO_CONNECTION)
message(STATUS "No internet connection, disabling 'builtin_tbb' and 'imt' options")
Expand Down Expand Up @@ -1369,7 +1386,9 @@ endif()
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)
set(vc ON CACHE BOOL "Enabled because builtin_vc requested (${vc_description})")
endif()
elseif(vc)
if(fail-on-missing)
find_package(Vc 1.4.4 CONFIG QUIET REQUIRED)
Expand Down Expand Up @@ -1458,7 +1477,9 @@ endif()
if(builtin_veccore)
unset(VecCore_FOUND)
unset(VecCore_FOUND CACHE)
set(veccore ON CACHE BOOL "Enabled because builtin_veccore requested (${veccore_description})" FORCE)
if(NOT vc)
set(veccore ON CACHE BOOL "Enabled because builtin_veccore requested (${veccore_description})")
endif()
elseif(veccore)
if(vc)
set(VecCore_COMPONENTS Vc)
Expand Down Expand Up @@ -1576,6 +1597,9 @@ if(vdt OR builtin_vdt)
endif()
endif()
if(builtin_vdt)
if(NOT vdt)
set(vdt ON CACHE BOOL "Enabled because builtin_vdt enabled (${vdt_description})")
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})
Expand Down Expand Up @@ -1608,7 +1632,6 @@ if(vdt OR builtin_vdt)
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
Expand Down
Loading