From 143bae7a8c854fea49d8424a0b1a6f8e22774daa Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Sat, 14 Jun 2025 13:58:55 +0200 Subject: [PATCH 1/3] [CMake] Explicitly install byproducts of generating Core dictionaries Explicitly install byproducts of generating Core dictionaries, and put the CMake code right next to where these byproducts are declared. This is better than relying on all `.pcm` files getting installed via some other part of the CMake code. --- core/CMakeLists.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 3d2069d3d1d38..6d9c180ec9a53 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -121,10 +121,14 @@ target_compile_definitions(Core PRIVATE if (runtime_cxxmodules) list(APPEND core_implicit_modules "-mSystemByproducts") # Force generation of _Builtin_intrinsics from Core. - list(APPEND core_implicit_modules "-m" "_Builtin_intrinsics" "-mByproduct" "_Builtin_intrinsics") - list(APPEND core_implicit_modules "-mByproduct" "ROOT_Foundation_Stage1_NoRTTI") - list(APPEND core_implicit_modules "-mByproduct" "ROOT_Foundation_C") - list(APPEND core_implicit_modules "-mByproduct" "ROOT_Rtypes") + list(APPEND core_implicit_modules "-m" "_Builtin_intrinsics") + + set(byproducts _Builtin_intrinsics ROOT_Foundation_Stage1_NoRTTI ROOT_Foundation_C ROOT_Rtypes) + foreach(byproduct ${byproducts}) + list(APPEND core_implicit_modules "-mByproduct" "${byproduct}") + install(FILES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${byproduct}.pcm DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endforeach() + unset(byproducts) endif(runtime_cxxmodules) get_target_property(CORE_DICT_HEADERS Core DICT_HEADERS) From b032e940e9235ec09d14223f2ab3db6d8f885a73 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Sat, 14 Jun 2025 14:02:27 +0200 Subject: [PATCH 2/3] [CMake] Explicitly install the `modules.idx` file Explicitly installing the `modules.idx` file is better than copying it by regex when copying the full library output directory. --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e37676441ac97..e0c6e0f21c913 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -525,7 +525,6 @@ install( DESTINATION ${CMAKE_INSTALL_LIBDIR} FILES_MATCHING PATTERN "*.pcm" - PATTERN "modules.idx" PATTERN "JupyROOT" EXCLUDE PATTERN "python*" EXCLUDE PATTERN "cmake" EXCLUDE @@ -553,6 +552,8 @@ if(runtime_cxxmodules) add_dependencies(modules_idx ${modules_idx_deps}) set_property(TARGET modules_idx PROPERTY modules_idx_file ${library_output_dir}/modules.idx) set_directory_properties(PROPERTIES ADDITIONAL_CLEAN_FILES "${library_output_dir}/modules.timestamp") + + install(FILES ${library_output_dir}/modules.idx DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() ROOT_ADD_TEST_SUBDIRECTORY(tutorials) From 17436d952d2baa0456878da7965296d9f7cc76c4 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Sat, 14 Jun 2025 14:02:49 +0200 Subject: [PATCH 3/3] [CMake] Explicitly install implicitly generated `pcm` files Explicitly listing all the `pcm` files that otherwise would not get installed seems tedious, but it has one clear advantage over `install(DIRECTORY ...)`. The problem with the latter is that it copies any subdirectories, not matter if the files in it were matched by regex or not. So what happens is that you end up with several empty directories in the install tree, notably the full directory structure of the Python interfaces, in case they are installed to a different directory. One way to fix this is to install the individual pcm files instead, as suggested by this commit. --- CMakeLists.txt | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0c6e0f21c913..5048a6cc5b422 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -518,22 +518,36 @@ else() install(DIRECTORY ${CMAKE_BINARY_DIR}/etc/dictpch DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}) endif() -# FIXME: move installation of PCMS in ROOT_GENERATE_DICTIONARY(). -# We are excluding directories, which are accidentaly copied via unxpected behaviour of install(DIRECTORY ..) -install( - DIRECTORY ${CMAKE_BINARY_DIR}/lib/ - DESTINATION ${CMAKE_INSTALL_LIBDIR} - FILES_MATCHING - PATTERN "*.pcm" - PATTERN "JupyROOT" EXCLUDE - PATTERN "python*" EXCLUDE - PATTERN "cmake" EXCLUDE - PATTERN "pkgconfig" EXCLUDE -) - # modules.idx if(runtime_cxxmodules) + ROOT_GET_LIBRARY_OUTPUT_DIR(library_output_dir) + + # Explicitly install the modules that are built by Clang implicitly. See + # also the comment in rootcling_impl.cxx about the "horrible workaround" to + # fix the incremental builds. The list needs to be kept up to date manually, + # it is better than globbing for all pcm files from the library output + # directory. The platform-dependent system modules match the LoadModule() + # calls in TCling.cxx. + set(implicit_pcm_files + Cling_Runtime.pcm + Cling_Runtime_Extra.pcm + ROOT_Config.pcm + _Builtin_stddef.pcm + std.pcm + ) + if(WIN32) + list(APPEND implicit_pcm_files vcruntime.pcm services.pcm) + elseif(APPLE) + list(APPEND implicit_pcm_files Darwin.pcm) + else() + list(APPEND implicit_pcm_files libc.pcm) + endif() + foreach(implicit_pcm_file ${implicit_pcm_files}) + install(FILES ${library_output_dir}/${implicit_pcm_file} DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endforeach() + unset(implicit_pcm_files) + get_property(modules_idx_deps GLOBAL PROPERTY modules_idx_deps_property) if(WIN32) set(modules_idx_cmd COMMAND ${CMAKE_COMMAND} -E env PATH="${library_output_dir}\\\;%PATH%"