Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 117 additions & 3 deletions cmake/modules/RootMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,79 @@ 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 defined following FILE_SET naming conventions:
# linkDef for Linkdef*.h, HEADERS for public headers, not4dict_header_files for public headers
# that should be excluded from the rootclign call.
# <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__<target>, ie with G__ prepended.;
# the macro creates (among other files) the dictionary source as G__<target>.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(NoDictList ${target} HEADER_SET_not4dict_header_files)
if(HeaderList AND NoDictList)
list(REMOVE_ITEM HeaderList ${NoDictList})
endif()
get_target_property(HeaderBaseDirs ${target} HEADER_DIRS)
get_target_property(LinkdefList ${target} HEADER_SET_linkDef)
# 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)
set(LinkdefList)
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} ${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)

#---------------------------------------------------------------------------------------------------
#---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)
#
# <dictionary> is the dictionary stem; the macro creates (among other files) the dictionary source as
# <dictionary>.cxx
Expand All @@ -302,7 +370,7 @@ endfunction(ROOT_REPLACE_BUILD_INTERFACE)
# 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.
Expand All @@ -326,8 +394,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 $<BUILD_INTERFACE:>
Expand Down Expand Up @@ -1304,6 +1388,36 @@ 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:
# - linkDef for the LinkDef*.h file
# - HEADERS for public headers
# - not4dict_header_files for public headers purposely excluded from dictionaries
#---------------------------------------------------------------------------------------------------
function(ROOT_INSTALL_TARGET target)
install(TARGETS ${target}
EXPORT ${CMAKE_PROJECT_NAME}Exports
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
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # add /ROOT to make Debian happy

FILE_SET not4dict_header_files
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # add /ROOT to make Debian happy

FILE_SET linkDef
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)

#---------------------------------------------------------------------------------------------------
#---ROOT_INSTALL_HEADERS([dir1 dir2 ...] [FILTER <regex>] [HEADERS <header1> ...])
# Declare the install command for headers and copy them into <binary_dir>/include.
Expand Down
2 changes: 1 addition & 1 deletion main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ endif()
ROOT_EXECUTABLE(rootnb.exe nbmain.cxx LIBRARIES Core CMAKENOEXPORT)

#---ReadSpeed-------------------------------------------------------------------------------------
ROOT_EXECUTABLE(rootreadspeed src/readspeed.cxx LIBRARIES RIO Tree TreePlayer ReadSpeed CMAKENOEXPORT)
ROOT_EXECUTABLE(rootreadspeed src/readspeed.cxx LIBRARIES ReadSpeed CMAKENOEXPORT)

#---CreateHaddCommandLineOptions------------------------------------------------------------------
generateHeader(hadd
Expand Down
2 changes: 1 addition & 1 deletion roofit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
set(roofit_legacy_eval_backend ON CACHE BOOL "" FORCE)

add_subdirectory(batchcompute)
add_subdirectory(codegen)
if(NOT WIN32)
add_subdirectory(multiprocess)
endif()
Expand All @@ -18,6 +17,7 @@ if(mathmore)
endif()
add_subdirectory(roostats)
add_subdirectory(histfactory)
add_subdirectory(codegen)
add_subdirectory(hs3)
if(roofit_legacy_eval_backend AND NOT MSVC)
add_subdirectory(xroofit)
Expand Down
40 changes: 19 additions & 21 deletions roofit/codegen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,26 @@
# @author Pere Mato, CERN
############################################################################

ROOT_STANDARD_LIBRARY_PACKAGE(RooFitCodegen
HEADERS
RooFit/CodegenImpl.h
SOURCES
src/CodegenImpl.cxx
DICTIONARY_OPTIONS
"-writeEmptyRootPCM"
DEPENDENCIES
RooFit
RooFitCore
HistFactory
add_library(RooFitCodegen SHARED)
target_sources(RooFitCodegen
PRIVATE
src/CodegenImpl.cxx
PUBLIC
FILE_SET HEADERS TYPE HEADERS BASE_DIRS inc/ FILES
inc/RooFit/CodegenImpl.h
)

target_sources(
RooFitCodegen
PRIVATE
FILE_SET private_header_files
TYPE HEADERS
BASE_DIRS inc/
FILES
# LinkDef.h # empty, not being used by ROOT_STANDARD_LIBRARY_PACKAGE call
inc/RooFit/CodegenImpl.h
target_link_libraries(RooFitCodegen PUBLIC
RooFit
RooFitCore
HistFactory
)
ROOT_GENERATE_TARGET_DICTIONARY(RooFitCodegen "-writeEmptyRootPCM")
ROOT_INSTALL_TARGET(RooFitCodegen)

# workaround to include privately headers that are not public, from a "friend" target
get_target_property(RooFitCore_Friend_Dirs RooFitCore HEADER_DIRS_friend_header_files)
if(RooFitCore_Friend_Dirs)
target_include_directories(RooFitCodegen PRIVATE ${RooFitCore_Friend_Dirs})
endif()

ROOT_ADD_TEST_SUBDIRECTORY(test)
7 changes: 0 additions & 7 deletions roofit/codegen/LinkDef.h

This file was deleted.

6 changes: 6 additions & 0 deletions roofit/histfactory/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,10 @@ target_sources(
inc/HFMsgService.h # not part of list above
)

# workaround to include privately headers that are not public, from a "friend" target
get_target_property(RooFitCore_Friend_Dirs RooFitCore HEADER_DIRS_friend_header_files)
if(RooFitCore_Friend_Dirs)
target_include_directories(HistFactory PRIVATE ${RooFitCore_Friend_Dirs})
endif()

ROOT_ADD_TEST_SUBDIRECTORY(test)
6 changes: 6 additions & 0 deletions roofit/hs3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,10 @@ target_sources(
src/static_execute.h
)

# workaround to include privately headers that are not public, from a "friend" target
get_target_property(RooFitCore_Friend_Dirs RooFitCore HEADER_DIRS_friend_header_files)
if(RooFitCore_Friend_Dirs)
target_include_directories(RooFitHS3 PRIVATE ${RooFitCore_Friend_Dirs})
endif()

ROOT_ADD_TEST_SUBDIRECTORY(test)
95 changes: 45 additions & 50 deletions roofit/multiprocess/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<BUILD_INTERFACE:${RooFitMultiProcess_INCLUDE_DIR}>)

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)
19 changes: 12 additions & 7 deletions roofit/multiprocess/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Loading