diff --git a/CMakeLists.txt b/CMakeLists.txt index 03954e1c574f1..2d5b49fcbeeb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,48 +76,58 @@ include(cmake/modules/SetROOTVersion.cmake) message(STATUS "Building ROOT version ${ROOT_FULL_VERSION}") -#---Try to download a file to check internet connection----------------------------------------- -message(STATUS "Checking internet connectivity") -file(DOWNLOAD https://root.cern/files/cmake_connectivity_test.txt ${CMAKE_CURRENT_BINARY_DIR}/cmake_connectivity_test.txt - TIMEOUT 10 STATUS DOWNLOAD_STATUS -) -# Get the status code from the download status -list(GET DOWNLOAD_STATUS 0 STATUS_CODE) -# Check if download was successful. -if(${STATUS_CODE} EQUAL 0) - # Succcess - message(STATUS "Checking internet connectivity - found") - # Now let's delete the file - file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/cmake_connectivity_test.txt) - set(NO_CONNECTION FALSE) -else() - # Error - message(STATUS "Checking internet connectivity - failed: will not automatically download external dependencies") - set(NO_CONNECTION TRUE) -endif() - -if(NO_CONNECTION) - if(clad AND fail-on-missing) - message(FATAL_ERROR "No internet connection. Please check your connection, or either disable the 'clad' option or the 'fail-on-missing' to automatically disable options requiring internet access") - elseif(clad) - message(STATUS "No internet connection, disabling the 'clad' option") - endif() - set(clad OFF CACHE BOOL "Disabled because there is no internet connection" FORCE) -endif() - #---Where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked------------- set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) #---Enable Folders in IDE like Visual Studio---------------------------------------------------- set_property(GLOBAL PROPERTY USE_FOLDERS ON) -#---Load some basic macros which are needed later for the confiuration and build---------------- +#---Load some basic macros which are needed later for the configuration and build---------------- include(CheckCompiler) include(RootBuildOptions) include(RootMacros) include(CheckAssembler) include(CheckIntrinsics) +#---Try to download a file to check internet connection----------------------------------------- + +# The connection check only makes sense for fail-on-missing=OFF, where the +# result is used to decide whether to download a missing dependency as a builtin +# from the internet, or to disable the feature that has the missing dependency. +# With fail-on-missing=ON, it doesn't matter because disabling features is not +# allowed. Therefore, we can skip the connection check to save some +# configuration overhead and just assume we have internet: if a builtin can't be +# downloaded there will be a configuration failure either way. + +if(fail-on-missing) + set(NO_CONNECTION FALSE) +else() + message(STATUS "Checking internet connectivity") + file(DOWNLOAD https://root.cern/files/cmake_connectivity_test.txt ${CMAKE_CURRENT_BINARY_DIR}/cmake_connectivity_test.txt + TIMEOUT 10 STATUS DOWNLOAD_STATUS + ) + # Get the status code from the download status + list(GET DOWNLOAD_STATUS 0 STATUS_CODE) + # Check if download was successful. + if(${STATUS_CODE} EQUAL 0) + # Success + message(STATUS "Checking internet connectivity - found") + # Now let's delete the file + file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/cmake_connectivity_test.txt) + set(NO_CONNECTION FALSE) + else() + # Error + message(STATUS "Checking internet connectivity - failed: will not automatically download external dependencies") + set(NO_CONNECTION TRUE) + endif() +endif() + +if(NO_CONNECTION AND clad) + message(STATUS "No internet connection, disabling the 'clad' option") + set(clad OFF CACHE BOOL "Disabled because there is no internet connection" FORCE) +endif() + + # relatedrepo_GetClosestMatch(REPO_NAME ORIGIN_PREFIX UPSTREAM_PREFIX # FETCHURL_VARIABLE FETCHREF_VARIABLE ) # Return the clone URL and head/tag of the closest match for `repo` (e.g. roottest), based on the @@ -553,7 +563,7 @@ else() endif() # FIXME: move installation of PCMS in ROOT_GENERATE_DICTIONARY(). -# We are excluding directories, which are accidentaly copied via unxpected behaviour of install(DIRECTORY ..) +# We are excluding directories, which are accidentally copied via unexpected behaviour of install(DIRECTORY ..) install( DIRECTORY ${CMAKE_BINARY_DIR}/lib/ DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -634,7 +644,7 @@ endif() add_custom_target(distsrc COMMAND ${CMAKE_SOURCE_DIR}/build/unix/makedistsrc.sh "${ROOT_FULL_VERSION}" "${CMAKE_SOURCE_DIR}") add_custom_target(dist COMMAND cpack --config CPackConfig.cmake) -#---Configure and install various files neded later and for clients ----------------------------- +#---Configure and install various files needed later and for clients ----------------------------- include(RootConfiguration) #---Installation of project-wise artifacts-------------------------------------------------------