From 2ec063a57aa4a99eefecd5153b343855e5ea1306 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Wed, 2 Oct 2024 18:04:50 +0200 Subject: [PATCH] [CMake] Make it possible to pass existing `CLAD_SOURCE_DIR` This would address two annoyances I have at the same time: 1. One can now clone both `root` and `clad`, linking the source directories together. This makes it much easier to try out changes in clad in the context of ROOT. 2. ROOT can now configure and build without an internet connection, even with `Dclad=ON`. This partially addresses #11603. --- CMakeLists.txt | 3 ++- cmake/modules/RootBuildOptions.cmake | 4 ++-- interpreter/cling/tools/plugins/clad/CMakeLists.txt | 12 +++++++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 95708d92e5450..63940b24a783f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,7 +109,8 @@ include(RootMacros) include(CheckAssembler) include(CheckIntrinsics) -if(clad AND NO_CONNECTION) +# Building Clad requires an internet connection, if we're not side-loading the source directory +if(clad AND NOT DEFINED CLAD_SOURCE_DIR AND NO_CONNECTION) if(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") else() diff --git a/cmake/modules/RootBuildOptions.cmake b/cmake/modules/RootBuildOptions.cmake index 3f9505d14d854..31e4ce5f25973 100644 --- a/cmake/modules/RootBuildOptions.cmake +++ b/cmake/modules/RootBuildOptions.cmake @@ -113,11 +113,11 @@ ROOT_BUILD_OPTION(builtin_zstd OFF "Build included libzstd, or use system libzst ROOT_BUILD_OPTION(ccache OFF "Enable ccache usage for speeding up builds") ROOT_BUILD_OPTION(distcc OFF "Enable distcc usage for speeding up builds (ccache is called first if enabled)") ROOT_BUILD_OPTION(cefweb OFF "Enable support for CEF (Chromium Embedded Framework) web-based display") -ROOT_BUILD_OPTION(clad ON "Build clad, the cling automatic differentiation plugin (requires network)") +ROOT_BUILD_OPTION(clad ON "Build clad, the cling automatic differentiation plugin (requires network, or existing source directory indicated with -DCLAD_SOURCE_DIR=)") ROOT_BUILD_OPTION(cocoa OFF "Use native Cocoa/Quartz graphics backend (MacOS X only)") ROOT_BUILD_OPTION(coverage OFF "Enable compile flags for coverage testing") ROOT_BUILD_OPTION(cuda OFF "Enable support for CUDA (requires CUDA toolkit >= 7.5)") -ROOT_BUILD_OPTION(cudnn ON "Enable support for cuDNN (default when Cuda is enabled)") +ROOT_BUILD_OPTION(cudnn ON "Enable support for cuDNN (default when CUDA is enabled)") ROOT_BUILD_OPTION(daos OFF "Enable RNTuple support for Intel DAOS") ROOT_BUILD_OPTION(dataframe ON "Enable ROOT RDataFrame") ROOT_BUILD_OPTION(test_distrdf_pyspark OFF "Enable distributed RDataFrame tests that use pyspark") diff --git a/interpreter/cling/tools/plugins/clad/CMakeLists.txt b/interpreter/cling/tools/plugins/clad/CMakeLists.txt index f6b9d29602460..aa541e1db9fc6 100644 --- a/interpreter/cling/tools/plugins/clad/CMakeLists.txt +++ b/interpreter/cling/tools/plugins/clad/CMakeLists.txt @@ -52,14 +52,20 @@ endif(LLVM_FORCE_USE_OLD_TOOLCHAIN) list(APPEND _clad_extra_cmake_args -DCLAD_BUILD_STATIC_ONLY=ON) # Wrap download, configure and build steps in a script to log output -set(_clad_cmake_logging_settings +set(_clad_extra_settings LOG_DOWNLOAD ON LOG_CONFIGURE ON LOG_BUILD ON LOG_INSTALL ON + LOG_OUTPUT_ON_FAILURE ON ) -list(APPEND _clad_cmake_logging_settings LOG_OUTPUT_ON_FAILURE ON) +# If the CLAD_SOURCE_DIR variable is defined in the CMake configuration, we're +# skipping the download of the repository and use the passed directory. +if (DEFINED CLAD_SOURCE_DIR) + list(APPEND _clad_extra_settings DOWNLOAD_COMMAND "") + list(APPEND _clad_extra_settings SOURCE_DIR ${CLAD_SOURCE_DIR}) +endif() #list(APPEND _clad_patches_list "patch1.patch" "patch2.patch") #set(_clad_patch_command @@ -88,7 +94,7 @@ ExternalProject_Add( BUILD_COMMAND ${CMAKE_COMMAND} --build . ${EXTRA_BUILD_ARGS} INSTALL_COMMAND ${CMAKE_COMMAND} --build . ${EXTRA_BUILD_ARGS} --target install BUILD_BYPRODUCTS ${CLAD_BYPRODUCTS} - ${_clad_cmake_logging_settings} + ${_clad_extra_settings} # We need the target clangBasic to be built before building clad. However, we # support building prebuilt clang and adding clangBasic breaks this case. # Delegate the dependency resolution to the clingInterpreter target (which