diff --git a/cmake/modules/RootBuildOptions.cmake b/cmake/modules/RootBuildOptions.cmake index e5d0ac2fc5497..38d1b78a0d03f 100644 --- a/cmake/modules/RootBuildOptions.cmake +++ b/cmake/modules/RootBuildOptions.cmake @@ -149,6 +149,7 @@ ROOT_BUILD_OPTION(roofit OFF "Build the libRooFit advanced fitting package") ROOT_BUILD_OPTION(root7 OFF "Build the ROOT 7 interface prototype, requires >= cxx14") ROOT_BUILD_OPTION(rpath OFF "Set run-time library load path on executables and shared libraries (at installation area)") ROOT_BUILD_OPTION(ruby OFF "Ruby ROOT bindings, requires ruby >= 1.8") +ROOT_BUILD_OPTION(runtime_cxxmodules OFF "Enable runtime support for C++ modules.") ROOT_BUILD_OPTION(sapdb ON "MaxDB/SapDB support, requires libsqlod and libsqlrte") ROOT_BUILD_OPTION(shadowpw ON "Shadow password support") ROOT_BUILD_OPTION(shared ON "Use shared 3rd party libraries if possible") diff --git a/cmake/modules/RootNewMacros.cmake b/cmake/modules/RootNewMacros.cmake index 68cba05309b5c..be06327eed305 100644 --- a/cmake/modules/RootNewMacros.cmake +++ b/cmake/modules/RootNewMacros.cmake @@ -387,29 +387,26 @@ function(ROOT_GENERATE_DICTIONARY dictionary) list(APPEND _implicitdeps CXX ${_dep}) endforeach() + # Add other rootcling invocations for our PCM generation. This is only necessary when rootcling is supposed + # to generate C++ modules as those build upon the generated modules of other rootcling invocations. set(module_dependencies "") - foreach(dep ${ARG_DEPENDENCIES}) - if(TARGET ROOTCLING_${dep}) + if(runtime_cxxmodules) + foreach(dep ${ARG_DEPENDENCIES}) set(module_dependencies ${module_dependencies} ROOTCLING_${dep}) - else() - set(module_dependencies ${module_dependencies} ${dep}) - endif() - endforeach() + endforeach() + endif() #---call rootcint------------------------------------------ add_custom_command(OUTPUT ${dictionary}.cxx ${pcm_name} ${rootmap_name} COMMAND ${command} -v2 -f ${dictionary}.cxx ${newargs} ${excludepathsargs} ${rootmapargs} ${ARG_OPTIONS} ${definitions} ${includedirs} ${headerfiles} ${_linkdef} IMPLICIT_DEPENDS ${_implicitdeps} - DEPENDS ${_list_of_header_dependencies} ${_linkdef} ${ROOTCINTDEP} ${ARG_DEPENDENCIES}) + DEPENDS ${_list_of_header_dependencies} ${_linkdef} ${ROOTCINTDEP} ${ARG_DEPENDENCIES} ${module_dependencies}) get_filename_component(dictname ${dictionary} NAME) #---roottest compability - if(ARG_NOINSTALL OR CMAKE_ROOTTEST_DICT OR (NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)) - add_custom_target(${dictname} DEPENDS ${dictionary}.cxx) - else() - add_custom_target(${dictname} DEPENDS ${dictionary}.cxx) - + add_custom_target(${dictname} DEPENDS ${dictionary}.cxx ${pcm_name} ${rootmap_name}) + if(NOT ARG_NOINSTALL AND NOT CMAKE_ROOTTEST_DICT AND DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY) set_property(GLOBAL APPEND PROPERTY ROOT_DICTIONARY_TARGETS ${dictname}) set_property(GLOBAL APPEND PROPERTY ROOT_DICTIONARY_FILES ${CMAKE_CURRENT_BINARY_DIR}/${dictionary}.cxx) @@ -423,12 +420,12 @@ function(ROOT_GENERATE_DICTIONARY dictionary) endif() # Create a target for this rootcling invocation based on the module name. # We can use this in other ROOT_GENERATE_DICTIONARY that only care about - # the generation of PCMs without waiting on the whole module. - if(ARG_MODULE) + # the generation of PCMs without waiting on the whole module compilation. + if(ARG_MODULE AND NOT ARG_MULTIDICT) # If we have multiple modules with the same name, let's just attach the # generation of this dictionary to the ROOTCLING_X target of the existing - # module. This happens for example with ROOTCLING_Smatrix which also comes - # in a "Smatrix32" version. + # module. This happens for example with ROOTCLING_Smatrix which also has a + # "Smatrix32" part. if (TARGET ROOTCLING_${ARG_MODULE}) add_dependencies(ROOTCLING_${ARG_MODULE} ${dictname}) else()