From 66db7f10951163b081aeb671eb920d146ed696a0 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Wed, 4 Nov 2026 09:14:06 +0100 Subject: [PATCH 1/6] [xroofit] experimental use of file sets for library generation --- cmake/modules/RootMacros.cmake | 41 ++++++++++++++++- roofit/xroofit/CMakeLists.txt | 83 ++++++++++++++++++++-------------- 2 files changed, 88 insertions(+), 36 deletions(-) diff --git a/cmake/modules/RootMacros.cmake b/cmake/modules/RootMacros.cmake index fbf71b6c2321b..90c4ccd3e2066 100644 --- a/cmake/modules/RootMacros.cmake +++ b/cmake/modules/RootMacros.cmake @@ -288,11 +288,50 @@ function(ROOT_REPLACE_BUILD_INTERFACE include_dir_var include_dir) set(${include_dir_var} ${include_dir} PARENT_SCOPE) endfunction(ROOT_REPLACE_BUILD_INTERFACE) +#--------------------------------------------------------------------------------------------------- +#---ROOT_GENERATE_TARGET_DICTIONARY( target OPTIONS opt1 opt2 ...) +# +# Creates the dictionary of a predefined CMake target +# is the CMake target on which header file sets and link libraries have been defined +# The output dictionary will be another CMake target called G__ prepended.; +# the macro creates (among other files) the dictionary source as G__.cxx +#--------------------------------------------------------------------------------------------------- +function(ROOT_GENERATE_TARGET_DICTIONARY target options) + # Check if OPTIONS start with a dash. + if (options) + foreach(ARG_O ${options}) + if (NOT ARG_O MATCHES "^-*") + message(FATAL_ERROR "Wrong rootcling option: ${options}") + endif() + endforeach() + endif(options) + + get_target_property(type ${target} TYPE) + if(NOT ${type} STREQUAL "INTERFACE_LIBRARY") + get_target_property(SrcList ${target} SOURCES) + get_target_property(SrcDir ${target} SOURCE_DIR) + list(TRANSFORM SrcList PREPEND ${SrcDir}/) + endif() + get_target_property(HeaderList ${target} HEADER_SET) + get_target_property(LinkdefList ${target} HEADER_SET_linkDefs) + # get_target_property(ModuleList ${target} CXX_MODULE_SET) needs 3.28 + if("HeaderList-NOTFOUND" IN_LIST HeaderList) + message(SEND_ERROR "ROOT_GENERATE_TARGET_DICTIONARY: Missing header file set in ${target}") + endif() + if("LinkdefList-NOTFOUND" IN_LIST LinkdefList) + message(SEND_ERROR "ROOT_GENERATE_TARGET_DICTIONARY: Missing Linkdef file set in ${target}") + endif() + get_target_property(LinkedLibraries ${target} LINK_LIBRARIES) + ROOT_GENERATE_DICTIONARY(G__${target} ${HeaderList} LINKDEF ${LinkdefList} DEPENDENCIES ${LinkedLibraries} OPTIONS ${options}) + # TODO: Probably one could directly call rootcling without all the shenanigan inside ROOT_GENERATE_DICTIONARY with include dirs, now that file_sets are used +endfunction(ROOT_GENERATE_TARGET_DICTIONARY) + #--------------------------------------------------------------------------------------------------- #---ROOT_GENERATE_DICTIONARY( dictionary headerfiles NODEPHEADERS ghdr1 ghdr2 ... # MODULE module DEPENDENCIES dep1 dep2 +# EXTRA_DEPENDENCIES # BUILTINS dep1 dep2 -# STAGE1 LINKDEF linkdef OPTIONS opt1 opt2 ...) +# STAGE1 LINKDEF linkdef OPTIONS opt1 opt2 ... NO_CXXMODULE MULTIDICT NOINSTALL) # # is the dictionary stem; the macro creates (among other files) the dictionary source as # .cxx diff --git a/roofit/xroofit/CMakeLists.txt b/roofit/xroofit/CMakeLists.txt index 375a2cf0f4744..3839b438b4cbf 100644 --- a/roofit/xroofit/CMakeLists.txt +++ b/roofit/xroofit/CMakeLists.txt @@ -1,17 +1,7 @@ -set (XROOFIT_HEADERS - RooBrowser.h - XRooFit.h - RooFit/xRooFit/xRooFit.h - RooFit/xRooFit/xRooNode.h - RooFit/xRooFit/xRooNLLVar.h - RooFit/xRooFit/xRooHypoSpace.h - RooFit/xRooFit/xRooBrowser.h -) - -ROOT_STANDARD_LIBRARY_PACKAGE(RooFitXRooFit - HEADERS - ${XROOFIT_HEADERS} - SOURCES +add_library(RooFitXRooFit SHARED) +target_sources( + RooFitXRooFit + PRIVATE src/Asymptotics.cxx src/xRooBrowser.cxx src/xRooFit.cxx @@ -20,9 +10,36 @@ ROOT_STANDARD_LIBRARY_PACKAGE(RooFitXRooFit src/xRooNode.cxx src/xRooNode_interactive.cxx src/PythonInterface.cxx - DICTIONARY_OPTIONS - "-writeEmptyRootPCM" - DEPENDENCIES + # These below could be also a PRIVATE header file_set if wanted + src/PythonInterface.h + src/coutCapture.h + src/xRooFitVersion.h + PUBLIC + FILE_SET HEADERS + TYPE HEADERS + BASE_DIRS inc/RooFit + FILES + inc/RooFit/xRooFit/xRooFit.h + inc/RooFit/xRooFit/xRooNode.h + inc/RooFit/xRooFit/xRooNLLVar.h + inc/RooFit/xRooFit/xRooHypoSpace.h + inc/RooFit/xRooFit/xRooBrowser.h + inc/RooFit/xRooFit/Config.h # was not part of XROOFIT_HEADERS earlier + PUBLIC + FILE_SET extraHEADERS + TYPE HEADERS + BASE_DIRS inc/ + FILES + inc/RooBrowser.h + inc/XRooFit.h + FILE_SET linkDefs + TYPE HEADERS + BASE_DIRS inc/ + FILES + inc/LinkDef.h +) +target_link_libraries(RooFitXRooFit + PUBLIC HistFactory RooFit RooFitHS3 @@ -32,27 +49,23 @@ ROOT_STANDARD_LIBRARY_PACKAGE(RooFitXRooFit Ged RooFitCore FitPanel - LINKDEF - inc/LinkDef.h ) +ROOT_GENERATE_TARGET_DICTIONARY(RooFitXRooFit "-writeEmptyRootPCM") +install(TARGETS RooFitXRooFit # This could go to another macro if wanted + EXPORT ${CMAKE_PROJECT_NAME}Exports + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + COMPONENT applications -target_include_directories(RooFitXRooFit PRIVATE inc/RooFit) + # with this we no longer need the moveheader target etc + FILE_SET HEADERS + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # add /ROOT to make Debian happy -set(RELATIVE_INC_HEADERS ${XROOFIT_HEADERS}) -list(TRANSFORM RELATIVE_INC_HEADERS PREPEND inc/) -target_sources( - RooFitXRooFit - PRIVATE - FILE_SET private_header_files - TYPE HEADERS - BASE_DIRS inc/ src/ - FILES - ${RELATIVE_INC_HEADERS} - inc/LinkDef.h - inc/RooFit/xRooFit/Config.h # was not part of XROOFIT_HEADERS - src/PythonInterface.h - src/coutCapture.h - src/xRooFitVersion.h + FILE_SET extraHEADERS + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # add /ROOT to make Debian happy + + FILE_SET linkDefs + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # add /ROOT to make Debian happy ) ROOT_ADD_TEST_SUBDIRECTORY(test) From c958b5cf85fcefe4fcb1615d3debabf840367d4c Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Thu, 5 Nov 2026 13:20:09 +0100 Subject: [PATCH 2/6] [cmake] make headerlist passed to gendict relative --- cmake/modules/RootMacros.cmake | 59 +++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 4 deletions(-) diff --git a/cmake/modules/RootMacros.cmake b/cmake/modules/RootMacros.cmake index 90c4ccd3e2066..48fb8174d2d37 100644 --- a/cmake/modules/RootMacros.cmake +++ b/cmake/modules/RootMacros.cmake @@ -291,9 +291,10 @@ endfunction(ROOT_REPLACE_BUILD_INTERFACE) #--------------------------------------------------------------------------------------------------- #---ROOT_GENERATE_TARGET_DICTIONARY( target OPTIONS opt1 opt2 ...) # -# Creates the dictionary of a predefined CMake target +# Creates the dictionary of a predefined CMake target defined following FILE_SET naming conventions: +# linkDefs for Linkdef.h, HEADERS for public headers # is the CMake target on which header file sets and link libraries have been defined -# The output dictionary will be another CMake target called G__ prepended.; +# The output dictionary will be another CMake target called G__, ie with G__ prepended.; # the macro creates (among other files) the dictionary source as G__.cxx #--------------------------------------------------------------------------------------------------- function(ROOT_GENERATE_TARGET_DICTIONARY target options) @@ -313,16 +314,39 @@ function(ROOT_GENERATE_TARGET_DICTIONARY target options) list(TRANSFORM SrcList PREPEND ${SrcDir}/) endif() get_target_property(HeaderList ${target} HEADER_SET) + get_target_property(HeaderBaseDirs ${target} HEADER_DIRS) get_target_property(LinkdefList ${target} HEADER_SET_linkDefs) - # get_target_property(ModuleList ${target} CXX_MODULE_SET) needs 3.28 + # get_target_property(ModuleList ${target} CXX_MODULE_SET) needs CMake 3.28 if("HeaderList-NOTFOUND" IN_LIST HeaderList) message(SEND_ERROR "ROOT_GENERATE_TARGET_DICTIONARY: Missing header file set in ${target}") endif() if("LinkdefList-NOTFOUND" IN_LIST LinkdefList) message(SEND_ERROR "ROOT_GENERATE_TARGET_DICTIONARY: Missing Linkdef file set in ${target}") endif() + + # Transform absolute header paths to relative paths based on BASE_DIRS + set(RelativeHeaderList "") + foreach(header_file ${HeaderList}) + set(resolved_path "") + foreach(base_dir ${HeaderBaseDirs}) + file(RELATIVE_PATH rel_path "${base_dir}" "${header_file}") + # If the path doesn't start with "../", it means it's under this base directory + if(NOT "${rel_path}" MATCHES "^\\.\\./") + set(resolved_path "${rel_path}") + break() + endif() + endforeach() + + if(resolved_path) + list(APPEND RelativeHeaderList "${resolved_path}") + else() + # Fallback to absolute if it couldn't be resolved relative to any base dir + list(APPEND RelativeHeaderList "${header_file}") + endif() + endforeach() + get_target_property(LinkedLibraries ${target} LINK_LIBRARIES) - ROOT_GENERATE_DICTIONARY(G__${target} ${HeaderList} LINKDEF ${LinkdefList} DEPENDENCIES ${LinkedLibraries} OPTIONS ${options}) + ROOT_GENERATE_DICTIONARY(G__${target} ${RelativeHeaderList} LINKDEF ${LinkdefList} MODULE ${target} DEPENDENCIES ${LinkedLibraries} OPTIONS ${options}) # TODO: Probably one could directly call rootcling without all the shenanigan inside ROOT_GENERATE_DICTIONARY with include dirs, now that file_sets are used endfunction(ROOT_GENERATE_TARGET_DICTIONARY) @@ -1343,6 +1367,33 @@ function(ROOT_FIND_DIRS_WITH_HEADERS result_dirs) set(${result_dirs} ${dirs} PARENT_SCOPE) endfunction() +#--------------------------------------------------------------------------------------------------- +#---ROOT_INSTALL_TARGET(target) +# Declare the install command for CMake target defined according to the following naming conventions +# for FILE_SETS: +# - linkDefs for LinkDef*.h files +# - HEADERS for public headers +# - extraHEADERS for public headers purposely excluded from dictionaries +#--------------------------------------------------------------------------------------------------- +function(ROOT_INSTALL_TARGET target) + install(TARGETS ${target} + EXPORT ${CMAKE_PROJECT_NAME}Exports + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + COMPONENT applications + + # with this we no longer need the moveheader target etc + FILE_SET HEADERS + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # add /ROOT to make Debian happy + + FILE_SET extraHEADERS + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # add /ROOT to make Debian happy + + FILE_SET linkDefs + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # add /ROOT to make Debian happy + ) +endfunction(ROOT_INSTALL_TARGET) + #--------------------------------------------------------------------------------------------------- #---ROOT_INSTALL_HEADERS([dir1 dir2 ...] [FILTER ] [HEADERS ...]) # Declare the install command for headers and copy them into /include. From dcac5bfd0564a395af3fa1202f630ba2ad658cc5 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Thu, 5 Nov 2026 13:22:45 +0100 Subject: [PATCH 3/6] [cmake] try compact layout --- roofit/xroofit/CMakeLists.txt | 98 +++++++++++++---------------------- 1 file changed, 37 insertions(+), 61 deletions(-) diff --git a/roofit/xroofit/CMakeLists.txt b/roofit/xroofit/CMakeLists.txt index 3839b438b4cbf..680aa69c97a5e 100644 --- a/roofit/xroofit/CMakeLists.txt +++ b/roofit/xroofit/CMakeLists.txt @@ -1,71 +1,47 @@ add_library(RooFitXRooFit SHARED) -target_sources( - RooFitXRooFit - PRIVATE - src/Asymptotics.cxx - src/xRooBrowser.cxx - src/xRooFit.cxx - src/xRooHypoSpace.cxx - src/xRooNLLVar.cxx - src/xRooNode.cxx - src/xRooNode_interactive.cxx - src/PythonInterface.cxx - # These below could be also a PRIVATE header file_set if wanted +target_sources(RooFitXRooFit +PRIVATE + src/Asymptotics.cxx + src/xRooBrowser.cxx + src/xRooFit.cxx + src/xRooHypoSpace.cxx + src/xRooNLLVar.cxx + src/xRooNode.cxx + src/xRooNode_interactive.cxx + src/PythonInterface.cxx +PRIVATE + FILE_SET privateHEADERS TYPE HEADERS BASE_DIRS src/ FILES src/PythonInterface.h src/coutCapture.h src/xRooFitVersion.h - PUBLIC - FILE_SET HEADERS - TYPE HEADERS - BASE_DIRS inc/RooFit - FILES - inc/RooFit/xRooFit/xRooFit.h - inc/RooFit/xRooFit/xRooNode.h - inc/RooFit/xRooFit/xRooNLLVar.h - inc/RooFit/xRooFit/xRooHypoSpace.h - inc/RooFit/xRooFit/xRooBrowser.h - inc/RooFit/xRooFit/Config.h # was not part of XROOFIT_HEADERS earlier - PUBLIC - FILE_SET extraHEADERS - TYPE HEADERS - BASE_DIRS inc/ - FILES - inc/RooBrowser.h - inc/XRooFit.h - FILE_SET linkDefs - TYPE HEADERS - BASE_DIRS inc/ - FILES - inc/LinkDef.h +PUBLIC + FILE_SET HEADERS TYPE HEADERS BASE_DIRS inc/ FILES + inc/RooFit/xRooFit/xRooFit.h + inc/RooFit/xRooFit/xRooNode.h + inc/RooFit/xRooFit/xRooNLLVar.h + inc/RooFit/xRooFit/xRooHypoSpace.h + inc/RooFit/xRooFit/xRooBrowser.h + inc/RooFit/xRooFit/Config.h + inc/RooBrowser.h + inc/XRooFit.h + FILE_SET linkDefs TYPE HEADERS BASE_DIRS inc/ FILES + inc/LinkDef.h ) +target_include_directories(RooFitXRooFit PRIVATE $) # for easening life in .cxx target_link_libraries(RooFitXRooFit - PUBLIC - HistFactory - RooFit - RooFitHS3 - RooStats - FitPanel - Gui - Ged - RooFitCore - FitPanel +PUBLIC + HistFactory + RooFit + RooFitHS3 + RooStats + FitPanel + Gui + Ged + RooFitCore + FitPanel ) -ROOT_GENERATE_TARGET_DICTIONARY(RooFitXRooFit "-writeEmptyRootPCM") -install(TARGETS RooFitXRooFit # This could go to another macro if wanted - EXPORT ${CMAKE_PROJECT_NAME}Exports - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT applications - - # with this we no longer need the moveheader target etc - FILE_SET HEADERS - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # add /ROOT to make Debian happy - - FILE_SET extraHEADERS - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # add /ROOT to make Debian happy - FILE_SET linkDefs - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # add /ROOT to make Debian happy -) +ROOT_GENERATE_TARGET_DICTIONARY(RooFitXRooFit "-writeEmptyRootPCM") +ROOT_INSTALL_TARGET(RooFitXRooFit) ROOT_ADD_TEST_SUBDIRECTORY(test) From caa46e4530440c010ccc9b33090bce194a218b85 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Thu, 5 Nov 2026 15:05:16 +0100 Subject: [PATCH 4/6] modules incdirs: different branch when file_sets were used trying to fix 2026-11-05T12:36:40.6393830Z Warning in : after creating module "RooFitXRooFit" the following headers are not part of that module: 2026-11-05T12:36:40.7063250Z /Users/sftnight/ROOT-CI/build/include/ROOT.modulemap:2953:46: error: cannot emit module RooFitXRooFit: size must be explicitly specified for missing header file "RooFit/xRooFit/xRooFit.h" 2026-11-05T12:36:40.7063940Z module "RooFit/xRooFit/xRooFit.h" { header "RooFit/xRooFit/xRooFit.h" export * } 2026-11-05T12:36:40.7064260Z ^ 2026-11-05T12:36:40.7064810Z /Users/sftnight/ROOT-CI/build/include/ROOT.modulemap:2954:47: error: cannot emit module RooFitXRooFit: size must be explicitly specified for missing header file "RooFit/xRooFit/xRooNode.h" 2026-11-05T12:36:40.7065490Z module "RooFit/xRooFit/xRooNode.h" { header "RooFit/xRooFit/xRooNode.h" export * } --- cmake/modules/RootMacros.cmake | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/cmake/modules/RootMacros.cmake b/cmake/modules/RootMacros.cmake index 48fb8174d2d37..ecf5007d5a2e5 100644 --- a/cmake/modules/RootMacros.cmake +++ b/cmake/modules/RootMacros.cmake @@ -346,7 +346,7 @@ function(ROOT_GENERATE_TARGET_DICTIONARY target options) endforeach() get_target_property(LinkedLibraries ${target} LINK_LIBRARIES) - ROOT_GENERATE_DICTIONARY(G__${target} ${RelativeHeaderList} LINKDEF ${LinkdefList} MODULE ${target} DEPENDENCIES ${LinkedLibraries} OPTIONS ${options}) + ROOT_GENERATE_DICTIONARY(G__${target} ${RelativeHeaderList} LINKDEF ${LinkdefList} MODULE ${target} DEPENDENCIES ${LinkedLibraries} OPTIONS ${options} USE_FILE_SETS) # TODO: Probably one could directly call rootcling without all the shenanigan inside ROOT_GENERATE_DICTIONARY with include dirs, now that file_sets are used endfunction(ROOT_GENERATE_TARGET_DICTIONARY) @@ -365,7 +365,7 @@ endfunction(ROOT_GENERATE_TARGET_DICTIONARY) # no error is emitted. The dictionary does not depend on these headers. #--------------------------------------------------------------------------------------------------- function(ROOT_GENERATE_DICTIONARY dictionary) - CMAKE_PARSE_ARGUMENTS(ARG "STAGE1;MULTIDICT;NOINSTALL;NO_CXXMODULE" + CMAKE_PARSE_ARGUMENTS(ARG "STAGE1;MULTIDICT;NOINSTALL;NO_CXXMODULE;USE_FILE_SETS" "MODULE;LINKDEF" "NODEPHEADERS;OPTIONS;DEPENDENCIES;EXTRA_DEPENDENCIES;BUILTINS" ${ARGN}) # Check if OPTIONS start with a dash. @@ -389,8 +389,24 @@ function(ROOT_GENERATE_DICTIONARY dictionary) if((CMAKE_PROJECT_NAME STREQUAL ROOT) AND (TARGET ${ARG_MODULE})) set(headerdirs) - get_target_property(target_incdirs ${ARG_MODULE} INCLUDE_DIRECTORIES) + if(ARG_USE_FILE_SETS) + get_target_property(target_incdirs ${ARG_MODULE} INTERFACE_INCLUDE_DIRECTORIES) + if(NOT target_incdirs) + set(target_incdirs "") + endif() + get_target_property(target_fileset_dirs ${ARG_MODULE} HEADER_DIRS) + if(target_fileset_dirs) + list(APPEND target_incdirs ${target_fileset_dirs}) + endif() + else() + get_target_property(target_incdirs ${ARG_MODULE} INCLUDE_DIRECTORIES) + if(NOT target_incdirs) + set(target_incdirs "") + endif() + endif() + if(target_incdirs) + list(REMOVE_DUPLICATES target_incdirs) foreach(dir ${target_incdirs}) ROOT_REPLACE_BUILD_INTERFACE(dir ${dir}) # check that dir not a empty dir like $ From 57553172aa348fb61d9e4f8751f9ebcb302a6bd6 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Thu, 5 Nov 2026 16:13:24 +0100 Subject: [PATCH 5/6] [RF] use standard CMake file set code instead of ROOT_LINKER_LIBRARY --- cmake/modules/RootMacros.cmake | 9 ++- roofit/multiprocess/CMakeLists.txt | 95 ++++++++++++++---------------- roofit/roofitcore/CMakeLists.txt | 8 +++ 3 files changed, 59 insertions(+), 53 deletions(-) diff --git a/cmake/modules/RootMacros.cmake b/cmake/modules/RootMacros.cmake index ecf5007d5a2e5..637a764793d50 100644 --- a/cmake/modules/RootMacros.cmake +++ b/cmake/modules/RootMacros.cmake @@ -1394,9 +1394,9 @@ endfunction() function(ROOT_INSTALL_TARGET target) install(TARGETS ${target} EXPORT ${CMAKE_PROJECT_NAME}Exports - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT applications + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries # with this we no longer need the moveheader target etc FILE_SET HEADERS @@ -1408,6 +1408,9 @@ function(ROOT_INSTALL_TARGET target) FILE_SET linkDefs DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # add /ROOT to make Debian happy ) + export(TARGETS ${target} NAMESPACE ROOT:: + APPEND FILE ${PROJECT_BINARY_DIR}/ROOTConfig-Targets.cmake + ) endfunction(ROOT_INSTALL_TARGET) #--------------------------------------------------------------------------------------------------- diff --git a/roofit/multiprocess/CMakeLists.txt b/roofit/multiprocess/CMakeLists.txt index 09c1920207f84..12454a947e21a 100644 --- a/roofit/multiprocess/CMakeLists.txt +++ b/roofit/multiprocess/CMakeLists.txt @@ -3,58 +3,53 @@ # @author Patrick Bos, Netherlands eScience Center ############################################################################ -ROOT_LINKER_LIBRARY(RooFitMultiProcess - src/worker.cxx - src/Channel.cxx - src/Messenger.cxx - src/ProcessManager.cxx - src/util.cxx - src/Queue.cxx - src/FIFOQueue.cxx - src/PriorityQueue.cxx - src/JobManager.cxx - src/Job.cxx - src/Config.cxx - src/ProcessTimer.cxx - src/HeatmapAnalyzer.cxx - LIBRARIES - Core +add_library(RooFitMultiProcess SHARED) +target_sources(RooFitMultiProcess +PRIVATE + src/worker.cxx + src/Channel.cxx + src/Messenger.cxx + src/ProcessManager.cxx + src/util.cxx + src/Queue.cxx + src/FIFOQueue.cxx + src/PriorityQueue.cxx + src/JobManager.cxx + src/Job.cxx + src/Config.cxx + src/ProcessTimer.cxx + src/HeatmapAnalyzer.cxx +PRIVATE + FILE_SET private_header_files TYPE HEADERS BASE_DIRS src/ FILES + src/FIFOQueue.h + src/PriorityQueue.h + FILE_SET friend_header_files TYPE HEADERS BASE_DIRS res/ FILES # they are private, but we allow calling them from .cxx files within other RF targets + res/RooFit/MultiProcess/Channel.h + res/RooFit/MultiProcess/JobManager.h + res/RooFit/MultiProcess/Job.h + res/RooFit/MultiProcess/Message.h + res/RooFit/MultiProcess/Messenger.h + res/RooFit/MultiProcess/Messenger_decl.h + res/RooFit/MultiProcess/Poller.h + res/RooFit/MultiProcess/ProcessManager.h + res/RooFit/MultiProcess/ProcessTimer.h + res/RooFit/MultiProcess/Queue.h + res/RooFit/MultiProcess/util.h + res/RooFit/MultiProcess/worker.h +PUBLIC + FILE_SET HEADERS TYPE HEADERS BASE_DIRS inc/ FILES + inc/RooFit/MultiProcess/Config.h + inc/RooFit/MultiProcess/HeatmapAnalyzer.h + inc/RooFit/MultiProcess/types.h ) - -target_link_libraries(RooFitMultiProcess PUBLIC Hist) -set(RooFitMultiProcess_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/res") -target_include_directories(RooFitMultiProcess - PRIVATE ${RooFitMultiProcess_INCLUDE_DIR} - INTERFACE $) - -target_link_libraries(RooFitMultiProcess PRIVATE nlohmann_json::nlohmann_json) - -target_sources( - RooFitMultiProcess - PRIVATE - FILE_SET private_header_files - TYPE HEADERS - BASE_DIRS inc/ res/ src/ - FILES - inc/RooFit/MultiProcess/Config.h - inc/RooFit/MultiProcess/HeatmapAnalyzer.h - inc/RooFit/MultiProcess/types.h - res/RooFit/MultiProcess/Channel.h - res/RooFit/MultiProcess/JobManager.h - res/RooFit/MultiProcess/Job.h - res/RooFit/MultiProcess/Message.h - res/RooFit/MultiProcess/Messenger.h - res/RooFit/MultiProcess/Messenger_decl.h - res/RooFit/MultiProcess/Poller.h - res/RooFit/MultiProcess/ProcessManager.h - res/RooFit/MultiProcess/ProcessTimer.h - res/RooFit/MultiProcess/Queue.h - res/RooFit/MultiProcess/util.h - res/RooFit/MultiProcess/worker.h - src/FIFOQueue.h - src/PriorityQueue.h +target_link_libraries(RooFitMultiProcess +PRIVATE + Core + nlohmann_json::nlohmann_json +PUBLIC + Hist ) ROOT_ADD_TEST_SUBDIRECTORY(test) -ROOT_INSTALL_HEADERS() +ROOT_INSTALL_TARGET(RooFitMultiProcess) diff --git a/roofit/roofitcore/CMakeLists.txt b/roofit/roofitcore/CMakeLists.txt index 72c3c030be679..02957c93d6963 100644 --- a/roofit/roofitcore/CMakeLists.txt +++ b/roofit/roofitcore/CMakeLists.txt @@ -573,4 +573,12 @@ target_sources( res/RooUnitTest.h ) +if (NOT WIN32) + # we include privately headers that are not public, from a "friend" target + get_target_property(RooFitMultiProcess_Friend_Dirs RooFitMultiProcess HEADER_DIRS_friend_header_files) + if(RooFitMultiProcess_Friend_Dirs) + target_include_directories(RooFitCore PRIVATE ${RooFitMultiProcess_Friend_Dirs}) + endif() +endif() + ROOT_ADD_TEST_SUBDIRECTORY(test) From 991804a4005565ac122348600443ec3627b610d3 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Thu, 5 Nov 2026 16:38:16 +0100 Subject: [PATCH 6/6] [RF] use also protected header dir in test --- roofit/multiprocess/test/CMakeLists.txt | 19 ++++++++++++------- roofit/roofitcore/CMakeLists.txt | 2 +- roofit/roofitcore/test/CMakeLists.txt | 5 +++++ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/roofit/multiprocess/test/CMakeLists.txt b/roofit/multiprocess/test/CMakeLists.txt index 1c080fc00d94f..44035a957723f 100644 --- a/roofit/multiprocess/test/CMakeLists.txt +++ b/roofit/multiprocess/test/CMakeLists.txt @@ -2,19 +2,24 @@ add_library(RooFit_multiprocess_testing_utils INTERFACE) target_link_libraries(RooFit_multiprocess_testing_utils INTERFACE RooFitCore) -target_include_directories(RooFit_multiprocess_testing_utils INTERFACE ${RooFitMultiProcess_INCLUDE_DIR}) +# workaround to include privately headers that are not public, from a "friend" target +add_library(RooFit_multiprocess_friend_utils INTERFACE) +get_target_property(RooFitMultiProcess_Friend_Dirs RooFitMultiProcess HEADER_DIRS_friend_header_files) +if(RooFitMultiProcess_Friend_Dirs) + target_include_directories(RooFit_multiprocess_friend_utils INTERFACE ${RooFitMultiProcess_Friend_Dirs}) +endif() ROOT_ADD_GTEST(test_RooFit_MultiProcess_Job test_Job.cxx LIBRARIES RooFitMultiProcess Core) # link to the INTERFACE library separately, ROOT_EXECUTABLE cannot handle INTERFACE library properties: -target_link_libraries(test_RooFit_MultiProcess_Job PUBLIC RooFit_multiprocess_testing_utils) +target_link_libraries(test_RooFit_MultiProcess_Job PUBLIC RooFit_multiprocess_testing_utils RooFit_multiprocess_friend_utils) -ROOT_ADD_GTEST(test_RooFit_MultiProcess_Channel test_Channel.cxx LIBRARIES RooFitMultiProcess) -ROOT_ADD_GTEST(test_RooFit_MultiProcess_ProcessManager test_ProcessManager.cxx LIBRARIES RooFitMultiProcess) -ROOT_ADD_GTEST(test_RooFit_MultiProcess_Messenger test_Messenger.cxx LIBRARIES RooFitMultiProcess) +ROOT_ADD_GTEST(test_RooFit_MultiProcess_Channel test_Channel.cxx LIBRARIES RooFitMultiProcess RooFit_multiprocess_friend_utils) +ROOT_ADD_GTEST(test_RooFit_MultiProcess_ProcessManager test_ProcessManager.cxx LIBRARIES RooFitMultiProcess RooFit_multiprocess_friend_utils) +ROOT_ADD_GTEST(test_RooFit_MultiProcess_Messenger test_Messenger.cxx LIBRARIES RooFitMultiProcess RooFit_multiprocess_friend_utils) -ROOT_ADD_GTEST(test_RooFit_MultiProcess_Queue test_Queue.cxx LIBRARIES RooFitMultiProcess) +ROOT_ADD_GTEST(test_RooFit_MultiProcess_Queue test_Queue.cxx LIBRARIES RooFitMultiProcess RooFit_multiprocess_friend_utils) #nlohmann is only a private dependency of RF_MP, but this test includes a header in res/ -ROOT_ADD_GTEST(test_RooFit_MultiProcess_ProcessTimer test_ProcessTimer.cxx LIBRARIES RooFitMultiProcess nlohmann_json::nlohmann_json) +ROOT_ADD_GTEST(test_RooFit_MultiProcess_ProcessTimer test_ProcessTimer.cxx LIBRARIES RooFitMultiProcess RooFit_multiprocess_friend_utils nlohmann_json::nlohmann_json) ROOT_ADD_GTEST(test_RooFit_MultiProcess_HeatmapAnalyzer test_HeatmapAnalyzer.cxx LIBRARIES RooFitMultiProcess COPY_TO_BUILDDIR ${CMAKE_CURRENT_SOURCE_DIR}/test_logs/p_0.json COPY_TO_BUILDDIR ${CMAKE_CURRENT_SOURCE_DIR}/test_logs/p_1.json diff --git a/roofit/roofitcore/CMakeLists.txt b/roofit/roofitcore/CMakeLists.txt index 02957c93d6963..4ad5dbc65cec8 100644 --- a/roofit/roofitcore/CMakeLists.txt +++ b/roofit/roofitcore/CMakeLists.txt @@ -574,7 +574,7 @@ target_sources( ) if (NOT WIN32) - # we include privately headers that are not public, from a "friend" target + # workaround to include privately headers that are not public, from a "friend" target get_target_property(RooFitMultiProcess_Friend_Dirs RooFitMultiProcess HEADER_DIRS_friend_header_files) if(RooFitMultiProcess_Friend_Dirs) target_include_directories(RooFitCore PRIVATE ${RooFitMultiProcess_Friend_Dirs}) diff --git a/roofit/roofitcore/test/CMakeLists.txt b/roofit/roofitcore/test/CMakeLists.txt index 0a1268a4d05aa..22de9af8c2bef 100644 --- a/roofit/roofitcore/test/CMakeLists.txt +++ b/roofit/roofitcore/test/CMakeLists.txt @@ -96,6 +96,11 @@ ROOT_ADD_GTEST(testRooTruthModel testRooTruthModel.cxx LIBRARIES RooFitCore RooF COPY_TO_BUILDDIR ${CMAKE_CURRENT_SOURCE_DIR}/rooAbsAnaConvPdf_classV3.root) if(NOT WIN32) + # workaround to include privately headers that are not public, from a "friend" target + get_target_property(RooFitMultiProcess_Friend_Dirs RooFitMultiProcess HEADER_DIRS_friend_header_files) + if(RooFitMultiProcess_Friend_Dirs) + list(APPEND RooFitCore_MultiProcess_TestStatistics_INCLUDE_DIR ${RooFitMultiProcess_Friend_Dirs}) + endif() ROOT_ADD_GTEST(testTestStatisticsPlot TestStatistics/testPlot.cxx LIBRARIES RooFitMultiProcess RooFitCore RooFit) ROOT_ADD_GTEST(testLikelihoodGradientJob TestStatistics/testLikelihoodGradientJob.cxx LIBRARIES RooFitMultiProcess RooFitCore m ROOT::TestSupport) target_include_directories(testLikelihoodGradientJob PRIVATE ${RooFitCore_MultiProcess_TestStatistics_INCLUDE_DIR})