From 1ccfdaf9e4025343039b46988f80291413cc86cd Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Thu, 11 Jul 2024 12:58:53 +0200 Subject: [PATCH 01/48] Replaced genreflex with rootcling --- cmake/FindROOT.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindROOT.cmake b/cmake/FindROOT.cmake index 50bc06ee8..2b341eed5 100644 --- a/cmake/FindROOT.cmake +++ b/cmake/FindROOT.cmake @@ -198,7 +198,7 @@ function(REFLEX_GENERATE_DICTIONARY dictionary) #set(rootmapopts --rootmap=${rootmapname} --rootmap-lib=${libprefix}${dictionary}Dict) #---Actual command---------------------------------------- add_custom_command(OUTPUT ${gensrcdict} ${rootmapname} ${dictionary}_rdict.pcm - COMMAND ${LAUNCHER} ${GENREFLEX_EXECUTABLE} ${headerfiles} -o ${gensrcdict} ${rootmapopts} --select=${selectionfile} --noIncludePaths + COMMAND ${LAUNCHER} ${ROOTCLING_EXECUTABLE} --reflex -o ${gensrcdict} ${rootmapopts} ${headerfiles} ${selectionfile} --noIncludePaths ${ARG_OPTIONS} ${includedirs} ${definitions} DEPENDS ${headerfiles} ${selectionfile}) endfunction() From 2e4dcd79f9f952cf5b5f7d7c747e4de2d8e2b205 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 17 Jul 2024 11:39:57 +0200 Subject: [PATCH 02/48] Added solution from FairROOT/#385 --- cmake/FindROOT.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindROOT.cmake b/cmake/FindROOT.cmake index 2b341eed5..efd2203c2 100644 --- a/cmake/FindROOT.cmake +++ b/cmake/FindROOT.cmake @@ -198,7 +198,7 @@ function(REFLEX_GENERATE_DICTIONARY dictionary) #set(rootmapopts --rootmap=${rootmapname} --rootmap-lib=${libprefix}${dictionary}Dict) #---Actual command---------------------------------------- add_custom_command(OUTPUT ${gensrcdict} ${rootmapname} ${dictionary}_rdict.pcm - COMMAND ${LAUNCHER} ${ROOTCLING_EXECUTABLE} --reflex -o ${gensrcdict} ${rootmapopts} ${headerfiles} ${selectionfile} --noIncludePaths + COMMAND ${LAUNCHER} ${ROOTCLING_EXECUTABLE} --reflex -o ${gensrcdict} ${rootmapopts} ${headerfiles} ${selectionfile} --noIncludePaths -inlineInputHeader ${ARG_OPTIONS} ${includedirs} ${definitions} DEPENDS ${headerfiles} ${selectionfile}) endfunction() From 0c3e4c9808ab694d63e30433323e05f8fe34f1b8 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 24 Jul 2024 16:16:02 +0200 Subject: [PATCH 03/48] Get rid of genreflex instances --- cmake/BioDynaMo.cmake | 4 ++-- cmake/FindROOT.cmake | 4 +--- cmake/utils.cmake | 5 ++--- util/makefile-build/bdm-code-generation | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/cmake/BioDynaMo.cmake b/cmake/BioDynaMo.cmake index 24f9080ab..12727eadb 100644 --- a/cmake/BioDynaMo.cmake +++ b/cmake/BioDynaMo.cmake @@ -108,7 +108,7 @@ function(build_shared_library TARGET) # We always need dictionaries for the plugins (plugin manager requires class # information) if(dict OR DEFINED ARG_PLUGIN) - # generate dictionary using genreflex + # generate dictionary using rootcling reflex set(DICT_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib${TARGET}_dict") set(BDM_DICT_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib${TARGET}_bdm_dict.cc") @@ -179,7 +179,7 @@ function(generate_rootlogon) set(CONTENT "${CONTENT}\n gROOT->ProcessLine(\"cout << \\\"ERROR: Loading BioDynaMo into ROOT failed!\\\" << endl\;\")\;") set(CONTENT "${CONTENT}\n gROOT->ProcessLine(\"cout << \\\" BioDynaMo was not built with dict=ON\\\" << endl\;\")\;") endif() - + set(CONTENT "${CONTENT}\n}\n") file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/rootlogon.C" ${CONTENT}) endfunction(generate_rootlogon) diff --git a/cmake/FindROOT.cmake b/cmake/FindROOT.cmake index efd2203c2..d53c56e54 100644 --- a/cmake/FindROOT.cmake +++ b/cmake/FindROOT.cmake @@ -97,8 +97,6 @@ mark_as_advanced(ROOT_CONFIG_EXECUTABLE) include(CMakeParseArguments) find_program(ROOTCLING_EXECUTABLE rootcling HINTS "$ENV{ROOTSYS}/bin" "$ENV{BDM_ROOT_DIR}/bin" "${CMAKE_THIRD_PARTY_DIR}/root/bin") -find_program(GENREFLEX_EXECUTABLE genreflex - HINTS "$ENV{ROOTSYS}/bin" "$ENV{BDM_ROOT_DIR}/bin" "${CMAKE_THIRD_PARTY_DIR}/root/bin") #find_package(GCCXML) # We use the launcher script to emulate a `source thisbdm.sh` call @@ -198,7 +196,7 @@ function(REFLEX_GENERATE_DICTIONARY dictionary) #set(rootmapopts --rootmap=${rootmapname} --rootmap-lib=${libprefix}${dictionary}Dict) #---Actual command---------------------------------------- add_custom_command(OUTPUT ${gensrcdict} ${rootmapname} ${dictionary}_rdict.pcm - COMMAND ${LAUNCHER} ${ROOTCLING_EXECUTABLE} --reflex -o ${gensrcdict} ${rootmapopts} ${headerfiles} ${selectionfile} --noIncludePaths -inlineInputHeader + COMMAND ${LAUNCHER} ${ROOTCLING_EXECUTABLE} --reflex -o ${gensrcdict} ${rootmapopts} ${headerfiles} ${selectionfile} --noIncludePaths -inlineInputHeader -cxxmodule ${ARG_OPTIONS} ${includedirs} ${definitions} DEPENDS ${headerfiles} ${selectionfile}) endfunction() diff --git a/cmake/utils.cmake b/cmake/utils.cmake index d7fc23074..e3c895b1c 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -109,7 +109,6 @@ function(verify_ROOT) SET(ROOT_ETC_DIR ${ROOT_ETC_DIR} PARENT_SCOPE) SET(ROOT_CONFIG_EXECUTABLE ${ROOT_CONFIG_EXECUTABLE} PARENT_SCOPE) SET(ROOTCLING_EXECUTABLE ${ROOTCLING_EXECUTABLE} PARENT_SCOPE) - SET(GENREFLEX_EXECUTABLE ${GENREFLEX_EXECUTABLE} PARENT_SCOPE) else() # When ROOT is found, but it's not C++17 compliant, we exit the installation, because ROOT needs # to be properly sourced prior to invoking CMake (CMake cannot do this for us, because it requires @@ -549,12 +548,12 @@ Unset the environment variable BDM_LOCAL_LFS to download the file.") DOWNLOAD_DIR ${DEST_PARENT} SOURCE_DIR ${DEST} ) - + FetchContent_GetProperties(${TAR_FILENAME}) if (NOT ${TAR_FILENAME}_POPULATED) FetchContent_Populate(${TAR_FILENAME}) endif() - + # Remove subbuild files, we don't need them file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/_deps/) endif() diff --git a/util/makefile-build/bdm-code-generation b/util/makefile-build/bdm-code-generation index cd7dce8b8..1edcf505b 100755 --- a/util/makefile-build/bdm-code-generation +++ b/util/makefile-build/bdm-code-generation @@ -58,7 +58,7 @@ CXX_INCLUDES=$(${BDM_CONFIG} --cxxincludes | sed 's|-isystem |-I|g') CXX_DEFINES=$(${BDM_CONFIG} --cxxdefines) -genreflex ${HEADERS} -o ${DICT} --noIncludePaths --select=${SELECTIONFILE} ${CXX_DEFINES} ${CXX_INCLUDES} $ADDITIONAL_CXX_FLAGS +rootcling -reflex -o ${DICT} ${HEADERS} --noIncludePaths -inlineInputHeader --select=${SELECTIONFILE} ${CXX_DEFINES} ${CXX_INCLUDES} $ADDITIONAL_CXX_FLAGS # Generate bdm dictionary and append to DICT BDM_DICT=$(mktemp) From aacbf409cded276ce184514fa14a39f8196b31af Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 24 Jul 2024 16:29:00 +0200 Subject: [PATCH 04/48] Remove -cxxmodule flag --- cmake/FindROOT.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindROOT.cmake b/cmake/FindROOT.cmake index d53c56e54..7e7b01a19 100644 --- a/cmake/FindROOT.cmake +++ b/cmake/FindROOT.cmake @@ -196,7 +196,7 @@ function(REFLEX_GENERATE_DICTIONARY dictionary) #set(rootmapopts --rootmap=${rootmapname} --rootmap-lib=${libprefix}${dictionary}Dict) #---Actual command---------------------------------------- add_custom_command(OUTPUT ${gensrcdict} ${rootmapname} ${dictionary}_rdict.pcm - COMMAND ${LAUNCHER} ${ROOTCLING_EXECUTABLE} --reflex -o ${gensrcdict} ${rootmapopts} ${headerfiles} ${selectionfile} --noIncludePaths -inlineInputHeader -cxxmodule + COMMAND ${LAUNCHER} ${ROOTCLING_EXECUTABLE} --reflex -o ${gensrcdict} ${rootmapopts} ${headerfiles} ${selectionfile} --noIncludePaths -inlineInputHeader ${ARG_OPTIONS} ${includedirs} ${definitions} DEPENDS ${headerfiles} ${selectionfile}) endfunction() From 9a7680a23e60f0ff2dccdda8da425b8537fc4e12 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Sat, 27 Jul 2024 17:28:09 +0200 Subject: [PATCH 05/48] Remove LAUNCHER invocation --- cmake/FindROOT.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindROOT.cmake b/cmake/FindROOT.cmake index 7e7b01a19..21fc7c527 100644 --- a/cmake/FindROOT.cmake +++ b/cmake/FindROOT.cmake @@ -196,7 +196,7 @@ function(REFLEX_GENERATE_DICTIONARY dictionary) #set(rootmapopts --rootmap=${rootmapname} --rootmap-lib=${libprefix}${dictionary}Dict) #---Actual command---------------------------------------- add_custom_command(OUTPUT ${gensrcdict} ${rootmapname} ${dictionary}_rdict.pcm - COMMAND ${LAUNCHER} ${ROOTCLING_EXECUTABLE} --reflex -o ${gensrcdict} ${rootmapopts} ${headerfiles} ${selectionfile} --noIncludePaths -inlineInputHeader + COMMAND ${ROOTCLING_EXECUTABLE} --reflex -o ${gensrcdict} ${rootmapopts} ${headerfiles} ${selectionfile} --noIncludePaths -inlineInputHeader ${ARG_OPTIONS} ${includedirs} ${definitions} DEPENDS ${headerfiles} ${selectionfile}) endfunction() From e79411fb54c6979da4fcefd88deca084ac808705 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Sat, 27 Jul 2024 18:33:10 +0200 Subject: [PATCH 06/48] Add -f flag to overwrite files According to https://github.com/root-project/root/blob/fb17cef3cb381772f7d930c213801b82b65fef52/core/dictgen/src/rootcling_impl.cxx#L5572 and genreflex -debug, the -f is needed --- cmake/FindROOT.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindROOT.cmake b/cmake/FindROOT.cmake index 21fc7c527..e666b14cc 100644 --- a/cmake/FindROOT.cmake +++ b/cmake/FindROOT.cmake @@ -196,7 +196,7 @@ function(REFLEX_GENERATE_DICTIONARY dictionary) #set(rootmapopts --rootmap=${rootmapname} --rootmap-lib=${libprefix}${dictionary}Dict) #---Actual command---------------------------------------- add_custom_command(OUTPUT ${gensrcdict} ${rootmapname} ${dictionary}_rdict.pcm - COMMAND ${ROOTCLING_EXECUTABLE} --reflex -o ${gensrcdict} ${rootmapopts} ${headerfiles} ${selectionfile} --noIncludePaths -inlineInputHeader + COMMAND ${ROOTCLING_EXECUTABLE} --reflex -f ${gensrcdict} ${rootmapopts} ${headerfiles} ${selectionfile} --noIncludePaths -inlineInputHeader ${ARG_OPTIONS} ${includedirs} ${definitions} DEPENDS ${headerfiles} ${selectionfile}) endfunction() From 083b433d4586e29374daeb868dd1fc2b5328f85c Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Sat, 27 Jul 2024 18:38:11 +0200 Subject: [PATCH 07/48] Removed double minus to keep the code clean --- cmake/FindROOT.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindROOT.cmake b/cmake/FindROOT.cmake index e666b14cc..9501baa22 100644 --- a/cmake/FindROOT.cmake +++ b/cmake/FindROOT.cmake @@ -196,7 +196,7 @@ function(REFLEX_GENERATE_DICTIONARY dictionary) #set(rootmapopts --rootmap=${rootmapname} --rootmap-lib=${libprefix}${dictionary}Dict) #---Actual command---------------------------------------- add_custom_command(OUTPUT ${gensrcdict} ${rootmapname} ${dictionary}_rdict.pcm - COMMAND ${ROOTCLING_EXECUTABLE} --reflex -f ${gensrcdict} ${rootmapopts} ${headerfiles} ${selectionfile} --noIncludePaths -inlineInputHeader + COMMAND ${ROOTCLING_EXECUTABLE} -reflex -f ${gensrcdict} ${rootmapopts} ${headerfiles} ${selectionfile} -noIncludePaths -inlineInputHeader ${ARG_OPTIONS} ${includedirs} ${definitions} DEPENDS ${headerfiles} ${selectionfile}) endfunction() From 8139c5be5d23dbf8443f27bfaa90e84e8a5aec73 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Mon, 5 Aug 2024 13:48:21 +0200 Subject: [PATCH 08/48] Fix whitespace changes --- cmake/BioDynaMo.cmake | 2 +- cmake/utils.cmake | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/BioDynaMo.cmake b/cmake/BioDynaMo.cmake index 12727eadb..7b8b60125 100644 --- a/cmake/BioDynaMo.cmake +++ b/cmake/BioDynaMo.cmake @@ -179,7 +179,7 @@ function(generate_rootlogon) set(CONTENT "${CONTENT}\n gROOT->ProcessLine(\"cout << \\\"ERROR: Loading BioDynaMo into ROOT failed!\\\" << endl\;\")\;") set(CONTENT "${CONTENT}\n gROOT->ProcessLine(\"cout << \\\" BioDynaMo was not built with dict=ON\\\" << endl\;\")\;") endif() - + set(CONTENT "${CONTENT}\n}\n") file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/rootlogon.C" ${CONTENT}) endfunction(generate_rootlogon) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index e3c895b1c..f6309066d 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -548,12 +548,12 @@ Unset the environment variable BDM_LOCAL_LFS to download the file.") DOWNLOAD_DIR ${DEST_PARENT} SOURCE_DIR ${DEST} ) - + FetchContent_GetProperties(${TAR_FILENAME}) if (NOT ${TAR_FILENAME}_POPULATED) FetchContent_Populate(${TAR_FILENAME}) endif() - + # Remove subbuild files, we don't need them file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/_deps/) endif() From 21ad68d2a4547878e776f0068fcde07b756ad539 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Mon, 5 Aug 2024 14:13:13 +0200 Subject: [PATCH 09/48] Remove --select from bdm-code-generation --- util/makefile-build/bdm-code-generation | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/makefile-build/bdm-code-generation b/util/makefile-build/bdm-code-generation index 1edcf505b..69e5ac0f5 100755 --- a/util/makefile-build/bdm-code-generation +++ b/util/makefile-build/bdm-code-generation @@ -58,7 +58,7 @@ CXX_INCLUDES=$(${BDM_CONFIG} --cxxincludes | sed 's|-isystem |-I|g') CXX_DEFINES=$(${BDM_CONFIG} --cxxdefines) -rootcling -reflex -o ${DICT} ${HEADERS} --noIncludePaths -inlineInputHeader --select=${SELECTIONFILE} ${CXX_DEFINES} ${CXX_INCLUDES} $ADDITIONAL_CXX_FLAGS +rootcling -reflex -f ${DICT} ${HEADERS} --noIncludePaths -inlineInputHeader ${SELECTIONFILE} ${CXX_DEFINES} ${CXX_INCLUDES} $ADDITIONAL_CXX_FLAGS # Generate bdm dictionary and append to DICT BDM_DICT=$(mktemp) From 68f110d4f34dde9638a6d08d24036b7df73e7446 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 7 Aug 2024 18:15:09 +0200 Subject: [PATCH 10/48] Remove trim whitespaces --- .editorconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index bcd03e659..febd8430e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -6,7 +6,7 @@ root = true charset = utf-8 end_of_line = lf insert_final_newline = true -trim_trailing_whitespace = true +trim_trailing_whitespace = false indent_style = space indent_size = 2 From 7bed6703da8b2eead9e6270dbe8f814781eaf9b5 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 7 Aug 2024 18:16:09 +0200 Subject: [PATCH 11/48] Changed rootcling calls to be the same --- cmake/FindROOT.cmake | 2 +- util/makefile-build/bdm-code-generation | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/FindROOT.cmake b/cmake/FindROOT.cmake index 9501baa22..431a1571e 100644 --- a/cmake/FindROOT.cmake +++ b/cmake/FindROOT.cmake @@ -196,7 +196,7 @@ function(REFLEX_GENERATE_DICTIONARY dictionary) #set(rootmapopts --rootmap=${rootmapname} --rootmap-lib=${libprefix}${dictionary}Dict) #---Actual command---------------------------------------- add_custom_command(OUTPUT ${gensrcdict} ${rootmapname} ${dictionary}_rdict.pcm - COMMAND ${ROOTCLING_EXECUTABLE} -reflex -f ${gensrcdict} ${rootmapopts} ${headerfiles} ${selectionfile} -noIncludePaths -inlineInputHeader + COMMAND ${ROOTCLING_EXECUTABLE} --reflex -f ${gensrcdict} ${rootmapopts} ${headerfiles} ${selectionfile} --noIncludePaths --inlineInputHeader ${ARG_OPTIONS} ${includedirs} ${definitions} DEPENDS ${headerfiles} ${selectionfile}) endfunction() diff --git a/util/makefile-build/bdm-code-generation b/util/makefile-build/bdm-code-generation index 69e5ac0f5..09fd49152 100755 --- a/util/makefile-build/bdm-code-generation +++ b/util/makefile-build/bdm-code-generation @@ -58,7 +58,7 @@ CXX_INCLUDES=$(${BDM_CONFIG} --cxxincludes | sed 's|-isystem |-I|g') CXX_DEFINES=$(${BDM_CONFIG} --cxxdefines) -rootcling -reflex -f ${DICT} ${HEADERS} --noIncludePaths -inlineInputHeader ${SELECTIONFILE} ${CXX_DEFINES} ${CXX_INCLUDES} $ADDITIONAL_CXX_FLAGS +rootcling --reflex -f ${DICT} ${HEADERS} ${SELECTIONFILE} --noIncludePaths --inlineInputHeader ${CXX_DEFINES} ${CXX_INCLUDES} $ADDITIONAL_CXX_FLAGS # Generate bdm dictionary and append to DICT BDM_DICT=$(mktemp) From 59a6ce7539d24a66b5aad39076566d0a02f68c89 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 14 Aug 2024 10:58:29 +0200 Subject: [PATCH 12/48] Add RootMacros.cmake This file contains a updated version of ROOT_GENERATED_DICTIONARY that can generate C++ Modules --- cmake/RootMacros.cmake | 2058 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 2058 insertions(+) create mode 100644 cmake/RootMacros.cmake diff --git a/cmake/RootMacros.cmake b/cmake/RootMacros.cmake new file mode 100644 index 000000000..a483d9727 --- /dev/null +++ b/cmake/RootMacros.cmake @@ -0,0 +1,2058 @@ +# Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. +# All rights reserved. +# +# For the licensing terms see $ROOTSYS/LICENSE. +# For the list of contributors see $ROOTSYS/README/CREDITS. + +#--------------------------------------------------------------------------------------------------- +# RootMacros.cmake +#--------------------------------------------------------------------------------------------------- + +if(WIN32) + set(libprefix lib) + set(ld_library_path PATH) + set(libsuffix .dll) + set(localruntimedir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + set(runtimedir ${CMAKE_INSTALL_BINDIR}) +elseif(APPLE) + set(ld_library_path DYLD_LIBRARY_PATH) + set(ld_preload DYLD_INSERT_LIBRARIES) + set(libprefix ${CMAKE_SHARED_LIBRARY_PREFIX}) + if(CMAKE_PROJECT_NAME STREQUAL ROOT) + set(libsuffix .so) + else() + set(libsuffix ${CMAKE_SHARED_LIBRARY_SUFFIX}) + endif() + set(localruntimedir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) + set(runtimedir ${CMAKE_INSTALL_PYTHONDIR}) +else() + set(ld_library_path LD_LIBRARY_PATH) + set(ld_preload LD_PRELOAD) + set(libprefix ${CMAKE_SHARED_LIBRARY_PREFIX}) + set(libsuffix ${CMAKE_SHARED_LIBRARY_SUFFIX}) + set(localruntimedir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) + set(runtimedir ${CMAKE_INSTALL_PYTHONDIR}) +endif() + +if(soversion) + set(ROOT_LIBRARY_PROPERTIES ${ROOT_LIBRARY_PROPERTIES} + VERSION ${ROOT_VERSION} + SOVERSION ${ROOT_MAJOR_VERSION}.${ROOT_MINOR_VERSION} + SUFFIX ${libsuffix} + PREFIX ${libprefix} ) +else() + set(ROOT_LIBRARY_PROPERTIES ${ROOT_LIBRARY_PROPERTIES} + SUFFIX ${libsuffix} + PREFIX ${libprefix} + IMPORT_PREFIX ${libprefix} ) +endif() + +include(CMakeParseArguments) + +#--------------------------------------------------------------------------------------------------- +#---ROOT_GLOB_FILES( [REALTIVE path] [FILTER regexp] ...) +#--------------------------------------------------------------------------------------------------- +function(ROOT_GLOB_FILES variable) + CMAKE_PARSE_ARGUMENTS(ARG "RECURSE" "RELATIVE;FILTER" "" ${ARGN}) + set(_possibly_recurse "") + if (ARG_RECURSE) + set(_possibly_recurse "_RECURSE") + endif() + if(ARG_RELATIVE) + file(GLOB${_possibly_recurse} _sources RELATIVE ${ARG_RELATIVE} ${ARG_UNPARSED_ARGUMENTS}) + else() + file(GLOB${_possibly_recurse} _sources ${ARG_UNPARSED_ARGUMENTS}) + endif() + if(ARG_FILTER) + foreach(s ${_sources}) + if(s MATCHES ${ARG_FILTER}) + list(REMOVE_ITEM _sources ${s}) + endif() + endforeach() + endif() + set(${variable} ${_sources} PARENT_SCOPE) +endfunction() + +function(ROOT_GLOB_SOURCES variable) + ROOT_GLOB_FILES(_sources FILTER "(^|/)G__" ${ARGN}) + set(${variable} ${_sources} PARENT_SCOPE) +endfunction() + +function(ROOT_GLOB_HEADERS variable) + ROOT_GLOB_FILES(_sources FILTER "LinkDef" ${ARGN}) + set(${variable} ${_sources} PARENT_SCOPE) +endfunction() + +#--------------------------------------------------------------------------------------------------- +#---ROOT_GET_SOURCES( cwd ...) +#--------------------------------------------------------------------------------------------------- +function(ROOT_GET_SOURCES variable cwd ) + set(sources) + foreach( fp ${ARGN}) + if( IS_ABSOLUTE ${fp}) + file(GLOB files ${fp}) + else() + if(root7) + set(root7glob v7/src/${fp}) + endif() + file(GLOB files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${cwd}/${fp} ${root7glob}) + endif() + if(files) + foreach(s ${files}) + if(fp MATCHES "[*]" AND s MATCHES "(^|/)G__") # Eliminate G__* files + elseif(s MATCHES "${cwd}/G__") + set(sources ${fp} ${sources}) + else() + set(sources ${sources} ${s}) + endif() + endforeach() + else() + if(fp MATCHES "(^|/)G__") + set(sources ${fp} ${sources}) + else() + set(sources ${sources} ${fp}) + endif() + endif() + endforeach() + set(${variable} ${sources} PARENT_SCOPE) +endfunction() + +#--------------------------------------------------------------------------------------------------- +#---REFLEX_GENERATE_DICTIONARY( dictionary headerfiles SELECTION selectionfile OPTIONS opt1 opt2 ... +# DEPENDS dependency1 dependency2 ... +# ) +# if dictionary is a TARGET (e.g., created with add_library), we inherit the INCLUDE_DIRECTORES and +# COMPILE_DEFINITIONS properties +# +#--------------------------------------------------------------------------------------------------- +function(REFLEX_GENERATE_DICTIONARY dictionary) + CMAKE_PARSE_ARGUMENTS(ARG "" "SELECTION" "OPTIONS;DEPENDS" ${ARGN}) + #---Get List of header files--------------- + set(headerfiles) + foreach(fp ${ARG_UNPARSED_ARGUMENTS}) + file(GLOB files inc/${fp}) + if(files) + foreach(f ${files}) + if(NOT f MATCHES LinkDef) + set(headerfiles ${headerfiles} ${f}) + endif() + endforeach() + elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${fp}) + set(headerfiles ${headerfiles} ${CMAKE_CURRENT_SOURCE_DIR}/${fp}) + else() + set(headerfiles ${headerfiles} ${fp}) + endif() + endforeach() + #---Get Selection file------------------------------------ + if(IS_ABSOLUTE ${ARG_SELECTION}) + set(selectionfile ${ARG_SELECTION}) + else() + set(selectionfile ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_SELECTION}) + endif() + + set(gensrcdict ${dictionary}.cxx) + + #---roottest compability--------------------------------- + if(CMAKE_ROOTTEST_NOROOTMAP) + set(rootmapname ) + set(rootmapopts ) + elseif(DEFINED CMAKE_ROOTTEST_NOROOTMAP) # Follow the roottest dictionary library naming + set(rootmapname ${dictionary}.rootmap) + set(rootmapopts --rootmap=${rootmapname} --rootmap-lib=${libprefix}${dictionary}_dictrflx) + else() + set(rootmapname ${dictionary}Dict.rootmap) + set(rootmapopts --rootmap=${rootmapname} --rootmap-lib=${libprefix}${dictionary}Dict) + endif() + + set(include_dirs ${CMAKE_CURRENT_SOURCE_DIR}) + get_directory_property(incdirs INCLUDE_DIRECTORIES) + foreach(d ${incdirs}) + if(NOT "${d}" MATCHES "^(AFTER|BEFORE|INTERFACE|PRIVATE|PUBLIC|SYSTEM)$") + list(APPEND include_dirs ${d}) + endif() + endforeach() + + get_directory_property(defs COMPILE_DEFINITIONS) + foreach( d ${defs}) + list(APPEND definitions ${d}) + endforeach() + + IF(TARGET ${dictionary}) + LIST(APPEND include_dirs $) + # The COMPILE_DEFINITIONS list might contain empty elements. These are + # removed with the FILTER generator expression, excluding elements that + # match the ^$ regexp (only matches empty strings). + LIST(APPEND definitions "$,EXCLUDE,^$>") + ENDIF() + + add_custom_command( + OUTPUT ${gensrcdict} ${rootmapname} + COMMAND ${ROOT_genreflex_CMD} + ARGS ${headerfiles} -o ${gensrcdict} ${rootmapopts} --select=${selectionfile} + --gccxmlpath=${GCCXML_home}/bin ${ARG_OPTIONS} + "-I$>,;-I>" + "$<$>:-D$>" + DEPENDS ${headerfiles} ${selectionfile} ${ARG_DEPENDS} + + COMMAND_EXPAND_LISTS + ) + IF(TARGET ${dictionary}) + target_sources(${dictionary} PRIVATE ${gensrcdict}) + ENDIF() + + #---roottest compability--------------------------------- + if(CMAKE_ROOTTEST_DICT) + ROOTTEST_TARGETNAME_FROM_FILE(targetname ${dictionary}) + + set(targetname "${targetname}-dictgen") + + add_custom_target(${targetname} DEPENDS ${gensrcdict} ${ROOT_LIBRARIES}) + else() + set(targetname "${dictionary}-dictgen") + # Creating this target at ALL level enables the possibility to generate dictionaries (genreflex step) + # well before the dependent libraries of the dictionary are build + add_custom_target(${targetname} ALL DEPENDS ${gensrcdict}) + endif() + + # FIXME: Do not set gensrcdict variable to the outer scope but use an argument to + # REFLEX_GENERATE_DICTIONARY passed from the outside. Note this would be a + # breaking change for roottest and other external users. + set(gensrcdict ${dictionary}.cxx PARENT_SCOPE) + +endfunction() + +#--------------------------------------------------------------------------------------------------- +#---ROOT_GET_LIBRARY_OUTPUT_DIR( result_var ) +# Returns the path to the .so file or .dll file. In the latter case Windows defines the dll files as +# executables and puts them in the $ROOTSYS/bin folder. +function(ROOT_GET_LIBRARY_OUTPUT_DIR result) + set(library_output_dir) + if(MSVC) + if(DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY AND NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY STREQUAL "") + set(library_output_dir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + else() + set(library_output_dir ${CMAKE_CURRENT_BINARY_DIR}) + endif() + else() + if(DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY AND NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY STREQUAL "") + set(library_output_dir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) + else() + set(library_output_dir ${CMAKE_CURRENT_BINARY_DIR}) + endif() + endif() + SET(${result} "${library_output_dir}" PARENT_SCOPE) +endfunction(ROOT_GET_LIBRARY_OUTPUT_DIR) + +#--------------------------------------------------------------------------------------------------- +#---ROOT_GET_INSTALL_DIR( result_var ) +# Returns the path to the shared libraries installation directory. On Windows the pcms and rootmap +# files must go in the $ROOTSYS/bin folder. +function(ROOT_GET_INSTALL_DIR result) + set(shared_lib_install_dir) + if(MSVC) + set(shared_lib_install_dir ${CMAKE_INSTALL_BINDIR}) + else() + set(shared_lib_install_dir ${CMAKE_INSTALL_LIBDIR}) + endif() + SET(${result} "${shared_lib_install_dir}" PARENT_SCOPE) +endfunction(ROOT_GET_INSTALL_DIR) + +#--------------------------------------------------------------------------------------------------- +#---ROOT_REPLACE_BUILD_INTERFACE( include_dir_var include_dir ) +# Update the `include_dir` variable after resolve the BUILD_INTERFACE +function(ROOT_REPLACE_BUILD_INTERFACE include_dir_var include_dir) + string(REGEX REPLACE "^[$]" "\\1" include_dir ${include_dir}) + # BUILD_INTERFACE might contain space-separated paths. They are split by + # foreach, leaving a trailing 'include/something>'. Remove the trailing '>'. + string(REGEX REPLACE ">$" "" include_dir ${include_dir}) + set(${include_dir_var} ${include_dir} PARENT_SCOPE) +endfunction(ROOT_REPLACE_BUILD_INTERFACE) + +#--------------------------------------------------------------------------------------------------- +#---ROOT_GENERATE_DICTIONARY( dictionary headerfiles NODEPHEADERS ghdr1 ghdr2 ... +# MODULE module DEPENDENCIES dep1 dep2 +# BUILTINS dep1 dep2 +# STAGE1 LINKDEF linkdef OPTIONS opt1 opt2 ...) +# +# is the dictionary stem; the macro creates (among other files) the dictionary source as +# .cxx +# are "as included"; set appropriate INCLUDE_DIRECTORIES property on the directory. +# The dictionary target depends on these headers. These files must exist. +# same as . If these files are not found (given the target include path) +# 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" + "MODULE;LINKDEF" "NODEPHEADERS;OPTIONS;DEPENDENCIES;EXTRA_DEPENDENCIES;BUILTINS" ${ARGN}) + + # Check if OPTIONS start with a dash. + if (ARG_OPTIONS) + foreach(ARG_O ${ARG_OPTIONS}) + if (NOT ARG_O MATCHES "^-*") + message(FATAL_ERROR "Wrong rootcling option: ${ARG_OPTIONS}") + endif() + endforeach() + endif(ARG_OPTIONS) + + #---roottest compability--------------------------------- + if(CMAKE_ROOTTEST_DICT) + set(CMAKE_INSTALL_LIBDIR ${CMAKE_CURRENT_BINARY_DIR}) + set(libprefix "") + endif() + + # list of include directories for dictionary generation + set(incdirs) + + if((CMAKE_PROJECT_NAME STREQUAL ROOT) AND (TARGET ${ARG_MODULE})) + set(headerdirs) + + get_target_property(target_incdirs ${ARG_MODULE} INCLUDE_DIRECTORIES) + if(target_incdirs) + foreach(dir ${target_incdirs}) + ROOT_REPLACE_BUILD_INTERFACE(dir ${dir}) + # check that dir not a empty dir like $ + if(NOT ${dir} MATCHES "^[$]") + list(APPEND incdirs ${dir}) + string(FIND ${dir} "${CMAKE_SOURCE_DIR}" src_dir_in_dir) + if(${src_dir_in_dir} EQUAL 0) + list(APPEND headerdirs ${dir}) + endif() + endif() + endforeach() + endif() + + # if (cxxmodules OR runtime_cxxmodules) + # Comments from Vassil: + # FIXME: We prepend ROOTSYS/include because if we have built a module + # and try to resolve the 'same' header from a different location we will + # get a redefinition error. + # We should remove these lines when the fallback include is removed. Then + # we will need a module.modulemap file per `inc` directory. + # Comments from Sergey: + # Remove all source dirs also while they preserved in root dictionaries and + # ends in the gInterpreter->GetIncludePath() + + list(FILTER incdirs EXCLUDE REGEX "^${CMAKE_SOURCE_DIR}") + list(FILTER incdirs EXCLUDE REGEX "^${CMAKE_BINARY_DIR}/ginclude") + list(FILTER incdirs EXCLUDE REGEX "^${CMAKE_BINARY_DIR}/externals") + list(FILTER incdirs EXCLUDE REGEX "^${CMAKE_BINARY_DIR}/builtins") + list(INSERT incdirs 0 ${CMAKE_BINARY_DIR}/include) + # endif() + + # this instruct rootcling do not store such paths in dictionary + set(excludepaths ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/ginclude ${CMAKE_BINARY_DIR}/externals ${CMAKE_BINARY_DIR}/builtins) + + set(headerfiles) + set(_list_of_header_dependencies) + foreach(fp ${ARG_UNPARSED_ARGUMENTS}) + if(IS_ABSOLUTE ${fp}) + set(headerFile ${fp}) + else() + find_file(headerFile ${fp} + HINTS ${headerdirs} + NO_DEFAULT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_FIND_ROOT_PATH) + endif() + if(NOT headerFile) + message(FATAL_ERROR "Cannot find header ${fp} to generate dictionary ${dictionary} for. Did you forget to set the INCLUDE_DIRECTORIES property for the current directory?") + endif() + list(APPEND headerfiles ${fp}) + list(APPEND _list_of_header_dependencies ${headerFile}) + unset(headerFile CACHE) # find_file, forget headerFile! + endforeach() + + foreach(fp ${ARG_NODEPHEADERS}) + list(APPEND headerfiles ${fp}) + # no dependency - think "vector" etc. + endforeach() + + if(NOT (headerfiles OR ARG_LINKDEF)) + message(FATAL_ERROR "No headers nor LinkDef.h supplied / found for dictionary ${dictionary}!") + endif() + + else() + + ####################### old-style includes/headers generation - starts ################## + + #---Get the list of include directories------------------ + get_directory_property(incdirs INCLUDE_DIRECTORIES) + # rootcling invoked on foo.h should find foo.h in the current source dir, + # no matter what. + list(APPEND incdirs ${CMAKE_CURRENT_SOURCE_DIR}) + + if(TARGET ${ARG_MODULE}) + get_target_property(target_incdirs ${ARG_MODULE} INCLUDE_DIRECTORIES) + foreach(dir ${target_incdirs}) + ROOT_REPLACE_BUILD_INTERFACE(dir ${dir}) + if(NOT ${dir} MATCHES "^[$]") + list(APPEND incdirs ${dir}) + endif() + endforeach() + endif() + + set(headerdirs_dflt) + + if(CMAKE_PROJECT_NAME STREQUAL ROOT) + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/inc) + list(APPEND headerdirs_dflt ${CMAKE_CURRENT_SOURCE_DIR}/inc) + endif() + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/v7/inc) + list(APPEND headerdirs_dflt ${CMAKE_CURRENT_SOURCE_DIR}/v7/inc) + endif() + endif() + + #---Get the list of header files------------------------- + # CMake needs dependencies from ${CMAKE_CURRENT_SOURCE_DIR} while rootcling wants + # header files "as included" (and thus as passed as argument to this CMake function). + set(headerfiles) + set(_list_of_header_dependencies) + foreach(fp ${ARG_UNPARSED_ARGUMENTS}) + if(${fp} MATCHES "[*?]") # Is this header a globbing expression? + file(GLOB files inc/${fp} ${fp}) # Elements of ${fp} have the complete path. + foreach(f ${files}) + if(NOT f MATCHES LinkDef) # skip LinkDefs from globbing result + set(add_inc_as_include On) + string(REGEX REPLACE "^${CMAKE_CURRENT_SOURCE_DIR}/inc/" "" f_no_inc ${f}) + list(APPEND headerfiles ${f_no_inc}) + list(APPEND _list_of_header_dependencies ${f}) + endif() + endforeach() + else() + if(IS_ABSOLUTE ${fp}) + set(headerFile ${fp}) + else() + set(incdirs_in_build) + set(incdirs_in_prefix ${headerdirs_dflt}) + foreach(incdir ${incdirs}) + string(FIND ${incdir} "${CMAKE_SOURCE_DIR}" src_dir_in_dir) + string(FIND ${incdir} "${CMAKE_BINARY_DIR}" bin_dir_in_dir) + string(FIND ${incdir} "${CMAKE_CURRENT_BINARY_DIR}" cur_dir_in_dir) + if(NOT IS_ABSOLUTE ${incdir} + OR ${src_dir_in_dir} EQUAL 0 + OR ${bin_dir_in_dir} EQUAL 0 + OR ${cur_dir_in_dir} EQUAL 0) + list(APPEND incdirs_in_build ${incdir}) + else() + list(APPEND incdirs_in_prefix ${incdir}) + endif() + endforeach() + if(incdirs_in_build) + find_file(headerFile ${fp} + HINTS ${incdirs_in_build} + NO_DEFAULT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_FIND_ROOT_PATH) + endif() + # Try this even if NOT incdirs_in_prefix: might not need a HINT. + if(NOT headerFile) + find_file(headerFile ${fp} + HINTS ${incdirs_in_prefix} + NO_DEFAULT_PATH + NO_SYSTEM_ENVIRONMENT_PATH) + endif() + endif() + if(NOT headerFile) + message(FATAL_ERROR "Cannot find header ${fp} to generate dictionary ${dictionary} for. Did you forget to set the INCLUDE_DIRECTORIES property for the current directory?") + endif() + list(APPEND headerfiles ${fp}) + list(APPEND _list_of_header_dependencies ${headerFile}) + unset(headerFile CACHE) # find_file, forget headerFile! + endif() + endforeach() + + foreach(fp ${ARG_NODEPHEADERS}) + list(APPEND headerfiles ${fp}) + # no dependency - think "vector" etc. + endforeach() + + if(NOT (headerfiles OR ARG_LINKDEF)) + message(FATAL_ERROR "No headers nor LinkDef.h supplied / found for dictionary ${dictionary}!") + endif() + + if(CMAKE_PROJECT_NAME STREQUAL ROOT) + list(APPEND incdirs ${CMAKE_BINARY_DIR}/include) + list(APPEND incdirs ${CMAKE_BINARY_DIR}/etc/cling) # This is for the RuntimeUniverse + # list(APPEND incdirs ${CMAKE_SOURCE_DIR}) + set(excludepaths ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) + elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/inc) + list(APPEND incdirs ${CMAKE_CURRENT_SOURCE_DIR}/inc) + endif() + + foreach(dep ${ARG_DEPENDENCIES}) + if(TARGET ${dep}) + get_target_property(dep_include_dirs ${dep} INTERFACE_INCLUDE_DIRECTORIES) + if (NOT dep_include_dirs) + get_target_property(dep_include_dirs ${dep} INCLUDE_DIRECTORIES) + endif() + if (dep_include_dirs) + foreach(d ${dep_include_dirs}) + list(APPEND incdirs ${d}) + endforeach() + endif() + endif() + endforeach() + + ####################### old-style includes/headers generation - end ################## + endif() + + #---Get the list of definitions--------------------------- + get_directory_property(defs COMPILE_DEFINITIONS) + foreach( d ${defs}) + if((NOT d MATCHES "=") AND (NOT d MATCHES "^[$]<.*>$")) # avoid generator expressions + set(definitions ${definitions} -D${d}) + endif() + endforeach() + #---Get LinkDef.h file------------------------------------ + foreach( f ${ARG_LINKDEF}) + if( IS_ABSOLUTE ${f}) + set(_linkdef ${_linkdef} ${f}) + else() + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f}) + set(_linkdef ${_linkdef} ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f}) + else() + set(_linkdef ${_linkdef} ${CMAKE_CURRENT_SOURCE_DIR}/${f}) + endif() + endif() + endforeach() + + #---Build the names for library, pcm and rootmap file ---- + set(library_target_name) + if(dictionary MATCHES "^G__") + string(REGEX REPLACE "^G__(.*)" "\\1" library_target_name ${dictionary}) + if (ARG_MULTIDICT) + string(REGEX REPLACE "(.*)32$" "\\1" library_target_name ${library_target_name}) + endif (ARG_MULTIDICT) + else() + get_filename_component(library_target_name ${dictionary} NAME_WE) + endif() + if (ARG_MODULE) + if (NOT ${ARG_MODULE} STREQUAL ${library_target_name}) +# message(AUTHOR_WARNING "The MODULE argument ${ARG_MODULE} and the deduced library name " +# "${library_target_name} mismatch. Deduction stem: ${dictionary}.") + set(library_target_name ${ARG_MODULE}) + endif() + endif(ARG_MODULE) + + #---Set the library output directory----------------------- + ROOT_GET_LIBRARY_OUTPUT_DIR(library_output_dir) + set(runtime_cxxmodule_dependencies ) + set(cpp_module) + set(library_name ${libprefix}${library_target_name}${libsuffix}) + set(newargs -s ${library_output_dir}/${library_name}) + set(rootmap_name ${library_output_dir}/${libprefix}${library_target_name}.rootmap) + set(pcm_name ${library_output_dir}/${libprefix}${library_target_name}_rdict.pcm) + if(ARG_MODULE) + if(ARG_MULTIDICT) + set(newargs ${newargs} -multiDict) + set(pcm_name ${library_output_dir}/${libprefix}${library_target_name}_${dictionary}_rdict.pcm) + set(rootmap_name ${library_output_dir}/${libprefix}${library_target_name}32.rootmap) + else() + set(cpp_module ${library_target_name}) + endif(ARG_MULTIDICT) + + if(runtime_cxxmodules) + # If we specify NO_CXXMODULE we should be able to still install the produced _rdict.pcm file. + if(NOT ARG_NO_CXXMODULE) + set(pcm_name) + endif() + if(cpp_module) + set(cpp_module_file ${library_output_dir}/${cpp_module}.pcm) + # The module depends on its modulemap file. + if (cpp_module_file AND CMAKE_PROJECT_NAME STREQUAL ROOT) + set (runtime_cxxmodule_dependencies copymodulemap "${CMAKE_BINARY_DIR}/include/ROOT.modulemap") + endif() + endif(cpp_module) + endif() + endif() + + # modules.idx deps + get_property(local_modules_idx_deps GLOBAL PROPERTY modules_idx_deps_property) + get_property(local_no_cxxmodules GLOBAL PROPERTY no_cxxmodules_property) + if (ARG_NO_CXXMODULE) + list(APPEND local_no_cxxmodules ${cpp_module}) + set_property(GLOBAL PROPERTY no_cxxmodules_property "${local_no_cxxmodules}") + unset(cpp_module) + unset(cpp_module_file) + else() + list(APPEND local_modules_idx_deps ${cpp_module}) + set_property(GLOBAL PROPERTY modules_idx_deps_property "${local_modules_idx_deps}") + endif(ARG_NO_CXXMODULE) + + + + if(CMAKE_ROOTTEST_NOROOTMAP OR cpp_module_file) + set(rootmap_name) + set(rootmapargs) + else() + set(rootmapargs -rml ${library_name} -rmf ${rootmap_name}) + endif() + + #---Get the library and module dependencies----------------- + if(ARG_DEPENDENCIES) + foreach(dep ${ARG_DEPENDENCIES}) + set(dependent_pcm ${libprefix}${dep}_rdict.pcm) + if (runtime_cxxmodules AND NOT dep IN_LIST local_no_cxxmodules) + set(dependent_pcm ${dep}.pcm) + endif() + set(newargs ${newargs} -m ${dependent_pcm}) + endforeach() + endif() + + if(cpp_module_file) + set(newargs -cxxmodule ${newargs}) + endif() + + #---what rootcling command to use-------------------------- + if(ARG_STAGE1) + if(MSVC AND CMAKE_ROOTTEST_DICT) + set(command ${CMAKE_COMMAND} -E ${CMAKE_BINARY_DIR}/bin/rootcling_stage1.exe) + else() + set(command ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" $) + endif() + set(ROOTCINTDEP rconfigure) + set(pcm_name) + else() + if(CMAKE_PROJECT_NAME STREQUAL ROOT) + if(MSVC AND CMAKE_ROOTTEST_DICT) + set(command ${CMAKE_COMMAND} -E env "ROOTIGNOREPREFIX=1" ${CMAKE_BINARY_DIR}/bin/rootcling.exe) + else() + set(command ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" + "ROOTIGNOREPREFIX=1" $ -rootbuild) + # Modules need RConfigure.h copied into include/. + set(ROOTCINTDEP rootcling rconfigure) + endif() + elseif(TARGET ROOT::rootcling) + if(APPLE) + set(command ${CMAKE_COMMAND} -E env "DYLD_LIBRARY_PATH=${ROOT_LIBRARY_DIR}:$ENV{DYLD_LIBRARY_PATH}" $) + else() + set(command ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${ROOT_LIBRARY_DIR}:$ENV{LD_LIBRARY_PATH}" $) + endif() + else() + set(command ${CMAKE_COMMAND} -E env rootcling) + endif() + endif() + + #---build the path exclusion switches---------------------- + set(excludepathsargs "") + foreach(excludepath ${excludepaths}) + set(excludepathsargs ${excludepathsargs} -excludePath ${excludepath}) + endforeach() + + #---build the implicit dependencies arguments + # NOTE: only the Makefile generator respects this! + foreach(_dep ${_linkdef} ${_list_of_header_dependencies}) + list(APPEND _implicitdeps CXX ${_dep}) + endforeach() + + if(ARG_MODULE) + set(MODULE_LIB_DEPENDENCY ${ARG_DEPENDENCIES}) + + # get target properties added after call to ROOT_GENERATE_DICTIONARY() + if(TARGET ${ARG_MODULE}) + # NOTE that module_sysincs is already part of ${module_sysincs}. But -isystem "wins", + # and list exclusion for generator expressions is too complex. + set(module_incs $>) + set(module_sysincs $>) + # The COMPILE_DEFINITIONS list might contain empty elements. These are + # removed with the FILTER generator expression, excluding elements that + # match the ^$ regexp (only matches empty strings). + set(module_defs "$,EXCLUDE,^$>") + endif() + endif() + + # provide list of includes for dictionary + set(includedirs) + if(incdirs) + list(REMOVE_DUPLICATES incdirs) + foreach(dir ${incdirs}) + if (NOT ${dir} MATCHES "^\\$:-D$>" + ${compIncPaths} + "$<$:-isystem;$>" + ${includedirs} "$<$:-I$>" + ${headerfiles} ${_linkdef} + IMPLICIT_DEPENDS ${_implicitdeps} + DEPENDS ${_list_of_header_dependencies} ${_linkdef} ${ROOTCINTDEP} + ${MODULE_LIB_DEPENDENCY} ${ARG_EXTRA_DEPENDENCIES} + ${runtime_cxxmodule_dependencies} + COMMAND_EXPAND_LISTS) + + # If we are adding to an existing target and it's not the dictionary itself, + # we make an object library and add its output object file as source to the target. + # This works around bug https://cmake.org/Bug/view.php?id=14633 in CMake by keeping + # the generated source at the same scope level as its owning target, something that + # would not happen if we used target_sources() directly with the dictionary source. + if(TARGET "${ARG_MODULE}" AND NOT "${ARG_MODULE}" STREQUAL "${dictionary}") + add_library(${dictionary} OBJECT ${dictionary}.cxx) + set_target_properties(${dictionary} PROPERTIES POSITION_INDEPENDENT_CODE TRUE) + target_sources(${ARG_MODULE} PRIVATE $) + + target_compile_options(${dictionary} PRIVATE + $) + + target_compile_definitions(${dictionary} PRIVATE + ${definitions} $) + + target_compile_features(${dictionary} PRIVATE + $) + + target_include_directories(${dictionary} PRIVATE + ${incdirs} $) + else() + get_filename_component(dictionary_name ${dictionary} NAME) + add_custom_target(${dictionary_name} DEPENDS ${dictionary}.cxx ${pcm_name} ${rootmap_name} ${cpp_module_file}) + endif() + + if(PROJECT_NAME STREQUAL "ROOT") + set_property(GLOBAL APPEND PROPERTY ROOT_PCH_DEPENDENCIES ${dictionary}) + set_property(GLOBAL APPEND PROPERTY ROOT_PCH_DICTIONARIES ${CMAKE_CURRENT_BINARY_DIR}/${dictionary}.cxx) + endif() + + if(ARG_MULTIDICT) + if(NOT TARGET "G__${ARG_MODULE}") + message(FATAL_ERROR + " Target G__${ARG_MODULE} not found!\n" + " Please create target G__${ARG_MODULE} before using MULTIDICT.") + endif() + add_dependencies(G__${ARG_MODULE} ${dictionary}) + endif() + + if(NOT ARG_NOINSTALL AND NOT CMAKE_ROOTTEST_DICT AND DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY) + ROOT_GET_INSTALL_DIR(shared_lib_install_dir) + # Install the C++ module if we generated one. + if (cpp_module_file) + install(FILES ${cpp_module_file} + DESTINATION ${shared_lib_install_dir} COMPONENT libraries) + endif() + + if(ARG_STAGE1) + install(FILES ${rootmap_name} + DESTINATION ${shared_lib_install_dir} COMPONENT libraries) + else() + install(FILES ${pcm_name} ${rootmap_name} + DESTINATION ${shared_lib_install_dir} COMPONENT libraries) + endif() + endif() + + if(ARG_BUILTINS) + foreach(arg1 ${ARG_BUILTINS}) + if(TARGET ${${arg1}_TARGET}) + add_dependencies(${dictionary} ${${arg1}_TARGET}) + endif() + endforeach() + endif() + + # FIXME: Support mulptiple dictionaries. In some cases (libSMatrix and + # libGenVector) we have to have two or more dictionaries (eg. for math, + # we need the two for double vs Double32_t template specializations). + # In some other cases, eg. libTreePlayer.so we add in a separate dictionary + # files which for some reason (temporarily?) cannot be put in the PCH. Eg. + # all rest of the first dict is in the PCH but this file is not and it + # cannot be present in the original dictionary. + if(cpp_module) + ROOT_CXXMODULES_APPEND_TO_MODULEMAP("${cpp_module}" "${headerfiles}") + endif() +endfunction(ROOT_GENERATE_DICTIONARY) + +#--------------------------------------------------------------------------------------------------- +#---ROOT_CXXMODULES_APPEND_TO_MODULEMAP( library library_headers ) +#--------------------------------------------------------------------------------------------------- +function (ROOT_CXXMODULES_APPEND_TO_MODULEMAP library library_headers) + ROOT_FIND_DIRS_WITH_HEADERS(dirs) + + set(found_headers "") + set(dir_headers "") + foreach(d ${dirs}) + ROOT_GLOB_FILES(dir_headers + RECURSE + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/${d} + FILTER "LinkDef" ${d}/*) + list(APPEND found_headers "${dir_headers}") + endforeach() + + set(excluded_headers RConfig.h RVersion.h core/foundation/inc/ROOT/RVersion.hxx RtypesImp.h + RtypesCore.h TClassEdit.h + TIsAProxy.h TVirtualIsAProxy.h + DllImport.h ESTLType.h Varargs.h + ThreadLocalStorage.h + TBranchProxyTemplate.h TGLWSIncludes.h + snprintf.h strlcpy.h) + + # Deprecated header files. + set (excluded_headers "${excluded_headers}") + + set(modulemap_entry "module \"${library}\" {") + + # Add a `use` directive to Core/Thread to signal that they use some + # split out submodules and we pass the rootcling integrity check. + if ("${library}" STREQUAL Core) + set (modulemap_entry "${modulemap_entry}\n use ROOT_Foundation_Stage1_NoRTTI\n") + set (modulemap_entry "${modulemap_entry}\n use ROOT_Foundation_C\n") + elseif ("${library}" STREQUAL Thread) + set (modulemap_entry "${modulemap_entry}\n use ROOT_Foundation_C\n") + endif() + + # For modules GCocoa and GQuartz we need objc and cplusplus context. + if (NOT ${library} MATCHES "GCocoa") + set (modulemap_entry "${modulemap_entry}\n requires cplusplus\n") + endif() + if (library_headers) + set(found_headers ${library_headers}) + endif() + foreach(header ${found_headers}) + set(textual_header "") + if (${header} MATCHES ".*\\.icc$") + set(textual_header "textual ") + endif() + # Check if header is in included header list + set(is_excluded NO) + foreach(excluded_header ${excluded_headers}) + if(${header} MATCHES ${excluded_header}) + set(is_excluded YES) + break() + endif() + endforeach() + if(NOT is_excluded) + set(modulemap_entry "${modulemap_entry} module \"${header}\" { ${textual_header}header \"${header}\" export * }\n") + endif() + endforeach() + set(modulemap_entry "${modulemap_entry} link \"${libprefix}${library}${libsuffix}\"\n") + set(modulemap_entry "${modulemap_entry} export *\n}\n\n") + # Non ROOT projects need a modulemap generated for them in the current + # directory. The same happens with test dictionaries in ROOT which are not + # exposed via the main modulemap. This is exposed by setting the + # ROOT_CXXMODULES_WRITE_TO_CURRENT_DIR. + if (NOT "${CMAKE_PROJECT_NAME}" STREQUAL ROOT OR ROOT_CXXMODULES_WRITE_TO_CURRENT_DIR) + set(modulemap_output_file "${CMAKE_CURRENT_BINARY_DIR}/module.modulemap") + + # It's possible that multiple modulemaps are needed in the current + # directory and we need to merge them. As we don't want to have multiple + # modules in the same moduluemap when rerunning CMake, we do a quick + # check if the current module is already in the modulemap (in which case + # we know we rerun CMake at the moment and start writing a new modulemap + # instead of appending new modules). + + # The string we use to identify if the current module is already in the + # modulemap. + set(modulemap_needle "module \"${library}\"") + # Check if the needle is in the modulemap. If the file doesn't exist + # we just pretend we didn't found the string in the modulemap. + set(match_result -1) + if (EXISTS "${modulemap_output_file}") + file(READ "${modulemap_output_file}" existing_contents) + string(FIND "${existing_contents}" "${modulemap_needle}" match_result) + endif() + # Append our new module to the existing modulemap containing other modules. + if(${match_result} EQUAL -1) + file(APPEND "${modulemap_output_file}" "${modulemap_entry}") + else() + file(WRITE "${modulemap_output_file}" "${modulemap_entry}") + endif() + + # Sanity check that the string we're looking for is actually in the content + # we're writing to this file. + string(FIND "${modulemap_entry}" "${modulemap_needle}" match_result) + if(${match_result} EQUAL -1) + message(AUTHOR_WARNING "Couldn't find module declaration in modulemap file." + "This would break the modulemap generation when " + " rerunning CMake. Module needle was " + "'${modulemap_needle}' and the content was '${modulemap_entry}'") + endif() + + else() + set_property(GLOBAL APPEND PROPERTY ROOT_CXXMODULES_EXTRA_MODULEMAP_CONTENT ${modulemap_entry}) + endif() +endfunction() + +#--------------------------------------------------------------------------------------------------- +#---ROOT_LINKER_LIBRARY( source1 source2 ...[TYPE STATIC|SHARED] [DLLEXPORT] +# [NOINSTALL] LIBRARIES library1 library2 ... +# DEPENDENCIES dep1 dep2 +# BUILTINS dep1 dep2) +#--------------------------------------------------------------------------------------------------- +function(ROOT_LINKER_LIBRARY library) + CMAKE_PARSE_ARGUMENTS(ARG "DLLEXPORT;CMAKENOEXPORT;TEST;NOINSTALL" "TYPE" "LIBRARIES;DEPENDENCIES;BUILTINS" ${ARGN}) + ROOT_GET_SOURCES(lib_srcs src ${ARG_UNPARSED_ARGUMENTS}) + if(NOT ARG_TYPE) + set(ARG_TYPE SHARED) + endif() + if(ARG_TEST) # we are building a test, so add EXCLUDE_FROM_ALL + set(_all EXCLUDE_FROM_ALL) + endif() + set(library_name ${library}) + if(TARGET ${library}) + message("Target ${library} already exists. Renaming target name to ${library}_new") + set(library ${library}_new) + endif() + if(WIN32 AND ARG_TYPE STREQUAL SHARED AND NOT ARG_DLLEXPORT) + if(MSVC) + set(library_name ${libprefix}${library}) + endif() + #---create a shared library with the .def file------------------------ + add_library(${library} ${_all} SHARED ${lib_srcs}) + target_link_libraries(${library} PUBLIC ${ARG_LIBRARIES} ${ARG_DEPENDENCIES}) + set_target_properties(${library} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) + else() + add_library( ${library} ${_all} ${ARG_TYPE} ${lib_srcs}) + if(ARG_TYPE STREQUAL SHARED) + set_target_properties(${library} PROPERTIES ${ROOT_LIBRARY_PROPERTIES} ) + endif() + target_link_libraries(${library} PUBLIC ${ARG_LIBRARIES} ${ARG_DEPENDENCIES}) + endif() + + if(DEFINED CMAKE_CXX_STANDARD) + target_compile_features(${library} INTERFACE cxx_std_${CMAKE_CXX_STANDARD}) + endif() + + if(PROJECT_NAME STREQUAL "ROOT") + if(NOT TARGET ROOT::${library}) + add_library(ROOT::${library} ALIAS ${library}) + endif() + endif() + + ROOT_ADD_INCLUDE_DIRECTORIES(${library}) + + if(PROJECT_NAME STREQUAL "ROOT") + set(dep_list) + if(ARG_DEPENDENCIES) + foreach(lib ${ARG_DEPENDENCIES}) + if((TARGET ${lib}) AND NOT (${lib} STREQUAL Core)) + # Include directories property is different for INTERFACE libraries + get_target_property(_target_type ${lib} TYPE) + if(${_target_type} STREQUAL "INTERFACE_LIBRARY") + get_target_property(lib_incdirs ${lib} INTERFACE_INCLUDE_DIRECTORIES) + else() + get_target_property(lib_incdirs ${lib} INCLUDE_DIRECTORIES) + endif() + if(lib_incdirs) + foreach(dir ${lib_incdirs}) + ROOT_REPLACE_BUILD_INTERFACE(dir ${dir}) + if(NOT ${dir} MATCHES "^[$]") + list(APPEND dep_list ${dir}) + endif() + endforeach() + endif() + endif() + endforeach() + endif() + if(dep_list) + list(REMOVE_DUPLICATES dep_list) + endif() + foreach(incl ${dep_list}) + target_include_directories(${library} PRIVATE ${incl}) + endforeach() + endif() + + if(PROJECT_NAME STREQUAL "ROOT") + set(dep_inc_list) + if(ARG_LIBRARIES) + foreach(lib ${ARG_LIBRARIES}) + if(TARGET ${lib}) + get_target_property(_target_type ${lib} TYPE) + if(${_target_type} STREQUAL "INTERFACE_LIBRARY") + get_target_property(lib_incdirs ${lib} INTERFACE_INCLUDE_DIRECTORIES) + get_target_property(lib_rpath ${lib} INTERFACE_BUILD_RPATH) + else() + get_target_property(lib_incdirs ${lib} INCLUDE_DIRECTORIES) + get_target_property(lib_rpath ${lib} BUILD_RPATH) + endif() + if(lib_incdirs) + foreach(dir ${lib_incdirs}) + ROOT_REPLACE_BUILD_INTERFACE(dir ${dir}) + if(NOT ${dir} MATCHES "^[$]") + list(APPEND dep_inc_list ${dir}) + endif() + endforeach() + endif() + if(lib_rpath) + set_target_properties(${library} PROPERTIES BUILD_RPATH ${lib_rpath}) + endif() + endif() + endforeach() + endif() + if(dep_inc_list) + list(REMOVE_DUPLICATES dep_inc_list) + foreach(incl ${dep_inc_list}) + target_include_directories(${library} PRIVATE ${incl}) + endforeach() + endif() + endif() + + if(TARGET G__${library}) + add_dependencies(${library} G__${library}) + endif() + if(CMAKE_PROJECT_NAME STREQUAL ROOT) + add_dependencies(${library} move_headers) + endif() + set_property(GLOBAL APPEND PROPERTY ROOT_EXPORTED_TARGETS ${library}) + set_target_properties(${library} PROPERTIES OUTPUT_NAME ${library_name}) + set_target_properties(${library} PROPERTIES INTERFACE_LINK_LIBRARIES "${ARG_DEPENDENCIES}") + target_include_directories(${library} INTERFACE $) + # Do not add -Dname_EXPORTS to the command-line when building files in this + # target. Doing so is actively harmful for the modules build because it + # creates extra module variants, and not useful because we don't use these + # macros. + set_target_properties(${library} PROPERTIES DEFINE_SYMBOL "") + if(ARG_BUILTINS) + foreach(arg1 ${ARG_BUILTINS}) + if(${arg1}_TARGET) + add_dependencies(${library} ${${arg1}_TARGET}) + endif() + endforeach() + endif() + + #----Installation details------------------------------------------------------- + if(NOT ARG_TEST AND NOT ARG_NOINSTALL AND CMAKE_LIBRARY_OUTPUT_DIRECTORY) + if(ARG_CMAKENOEXPORT) + install(TARGETS ${library} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) + else() + install(TARGETS ${library} 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) + endif() + if(WIN32 AND ARG_TYPE STREQUAL SHARED) + install(FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/lib${library}.pdb + CONFIGURATIONS Debug RelWithDebInfo + DESTINATION ${CMAKE_INSTALL_BINDIR} + COMPONENT libraries) + endif() + endif() +endfunction() + +#--------------------------------------------------------------------------------------------------- +#---ROOT_ADD_INCLUDE_DIRECTORIES(library) +#--------------------------------------------------------------------------------------------------- +function(ROOT_ADD_INCLUDE_DIRECTORIES library) + + if(PROJECT_NAME STREQUAL "ROOT") + + if(TARGET Core) + get_target_property(lib_incdirs Core INCLUDE_DIRECTORIES) + if(lib_incdirs) + foreach(dir ${lib_incdirs}) + ROOT_REPLACE_BUILD_INTERFACE(dir ${dir}) + if(NOT ${dir} MATCHES "^[$]") + target_include_directories(${library} BEFORE PRIVATE ${dir}) + endif() + endforeach() + endif() + endif() + + if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res) + target_include_directories(${library} BEFORE PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/res) + endif() + + if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc) + target_include_directories(${library} BEFORE PUBLIC $) + endif() + + if(root7 AND (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/v7/inc)) + target_include_directories(${library} BEFORE PUBLIC $) + endif() + + endif() + +endfunction(ROOT_ADD_INCLUDE_DIRECTORIES) + +#--------------------------------------------------------------------------------------------------- +#---ROOT_OBJECT_LIBRARY( source1 source2 ... BUILTINS dep1 dep2 ...) +#--------------------------------------------------------------------------------------------------- +function(ROOT_OBJECT_LIBRARY library) + CMAKE_PARSE_ARGUMENTS(ARG "" "" "BUILTINS" ${ARGN}) + ROOT_GET_SOURCES(lib_srcs src ${ARG_UNPARSED_ARGUMENTS}) + add_library( ${library} OBJECT ${lib_srcs}) + if(lib_srcs MATCHES "(^|/)(G__[^.]*)[.]cxx.*") + add_dependencies(${library} ${CMAKE_MATCH_2}) + endif() + add_dependencies(${library} move_headers) + + ROOT_ADD_INCLUDE_DIRECTORIES(${library}) + + #--- Only for building shared libraries + set_property(TARGET ${library} PROPERTY POSITION_INDEPENDENT_CODE 1) + # Do not add -Dname_EXPORTS to the command-line when building files in this + # target. Doing so is actively harmful for the modules build because it + # creates extra module variants, and not useful because we don't use these + # macros. + set_target_properties(${library} PROPERTIES DEFINE_SYMBOL "") + if(WIN32) + set_target_properties(${library} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) + endif() + + if(ARG_BUILTINS) + foreach(arg1 ${ARG_BUILTINS}) + if(${arg1}_TARGET) + add_dependencies(${library} ${${arg1}_TARGET}) + endif() + endforeach() + endif() + + #--- Fill the property OBJECTS with all the object files + # This is needed because the generator expression $ + # does not get expanded when used in custom command dependencies + get_target_property(sources ${library} SOURCES) + foreach(s ${sources}) + if(CMAKE_GENERATOR MATCHES Xcode) + get_filename_component(name ${s} NAME_WE) + set(obj ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.build/${CMAKE_CFG_INTDIR}/${library}.build/Objects-normal/x86_64/${name}${CMAKE_CXX_OUTPUT_EXTENSION}) + else() + if(IS_ABSOLUTE ${s}) + string(FIND ${s} "${CMAKE_CURRENT_SOURCE_DIR}" src_dir_in_src) + string(FIND ${s} "${CMAKE_CURRENT_BINARY_DIR}" bin_dir_in_src) + if(${src_dir_in_src} EQUAL 0) + string(REPLACE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${library}.dir src ${s}) + elseif(${bin_dir_in_src} EQUAL 0) + string(REPLACE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${library}.dir src ${s}) + else() + #message(WARNING "Unknown location of source ${s} for object library ${library}") + endif() + else() + set(src ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${library}.dir/${s}) + endif() + set(obj ${src}${CMAKE_CXX_OUTPUT_EXTENSION}) + endif() + set_property(TARGET ${library} APPEND PROPERTY OBJECTS ${obj}) + endforeach() +endfunction() + +#--------------------------------------------------------------------------------------------------- +#---ROOT_MODULE_LIBRARY( source1 source2 ... LIBRARIES library1 library2 ...) +#--------------------------------------------------------------------------------------------------- +function(ROOT_MODULE_LIBRARY library) + CMAKE_PARSE_ARGUMENTS(ARG "" "" "LIBRARIES" ${ARGN}) + ROOT_GET_SOURCES(lib_srcs src ${ARG_UNPARSED_ARGUMENTS}) + add_library(${library} SHARED ${lib_srcs}) + add_dependencies(${library} move_headers) + set_target_properties(${library} PROPERTIES ${ROOT_LIBRARY_PROPERTIES}) + # Do not add -Dname_EXPORTS to the command-line when building files in this + # target. Doing so is actively harmful for the modules build because it + # creates extra module variants, and not useful because we don't use these + # macros. + set_target_properties(${library} PROPERTIES DEFINE_SYMBOL "") + + ROOT_ADD_INCLUDE_DIRECTORIES(${library}) + + target_link_libraries(${library} PUBLIC ${ARG_LIBRARIES}) + #----Installation details------------------------------------------------------- + install(TARGETS ${library} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) +endfunction() + +#--------------------------------------------------------------------------------------------------- +#---ROOT_GENERATE_ROOTMAP( library LINKDEF linkdef LIBRRARY lib DEPENDENCIES lib1 lib2 ) +#--------------------------------------------------------------------------------------------------- +function(ROOT_GENERATE_ROOTMAP library) + return() #--- No needed anymore + CMAKE_PARSE_ARGUMENTS(ARG "" "LIBRARY" "LINKDEF;DEPENDENCIES" ${ARGN}) + get_filename_component(libname ${library} NAME_WE) + get_filename_component(path ${library} PATH) + + #---Set the library output directory----------------------- + ROOT_GET_LIBRARY_OUTPUT_DIR(library_output_dir) + + set(outfile ${library_output_dir}/${libprefix}${libname}.rootmap) + foreach( f ${ARG_LINKDEF}) + if( IS_ABSOLUTE ${f}) + set(_linkdef ${_linkdef} ${f}) + else() + set(_linkdef ${_linkdef} ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f}) + endif() + endforeach() + foreach(d ${ARG_DEPENDENCIES}) + get_filename_component(_ext ${d} EXT) + if(_ext) + set(_dependencies ${_dependencies} ${d}) + else() + set(_dependencies ${_dependencies} ${libprefix}${d}${CMAKE_SHARED_LIBRARY_SUFFIX}) + endif() + endforeach() + if(ARG_LIBRARY) + set(_library ${ARG_LIBRARY}) + else() + set(_library ${libprefix}${library}${CMAKE_SHARED_LIBRARY_SUFFIX}) + endif() + #---Build the rootmap file-------------------------------------- + #add_custom_command(OUTPUT ${outfile} + # COMMAND ${rlibmap_cmd} -o ${outfile} -l ${_library} -d ${_dependencies} -c ${_linkdef} + # DEPENDS ${_linkdef} ${rlibmap_cmd} ) + add_custom_target( ${libprefix}${library}.rootmap ALL DEPENDS ${outfile}) + set_target_properties(${libprefix}${library}.rootmap PROPERTIES FOLDER RootMaps ) + #---Install the rootmap file------------------------------------ + install(FILES ${outfile} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) +endfunction(ROOT_GENERATE_ROOTMAP) + +#--------------------------------------------------------------------------------------------------- +#---ROOT_FIND_DIRS_WITH_HEADERS([dir1 dir2 ...] OPTIONS [options]) +#--------------------------------------------------------------------------------------------------- +function(ROOT_FIND_DIRS_WITH_HEADERS result_dirs) + set(dirs "") + if(ARGN) + set(dirs ${ARGN}) + else() + if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc) + set(dirs inc/) + endif() + if(root7 AND IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/v7/inc) + set(dirs ${dirs} v7/inc/) + endif() + endif() + set(${result_dirs} ${dirs} PARENT_SCOPE) +endfunction() + +#--------------------------------------------------------------------------------------------------- +#---ROOT_INSTALL_HEADERS([dir1 dir2 ...] OPTIONS [options]) +#--------------------------------------------------------------------------------------------------- +function(ROOT_INSTALL_HEADERS) + CMAKE_PARSE_ARGUMENTS(ARG "OPTIONS" "" "FILTER" ${ARGN}) + if (${ARG_OPTIONS}) + message(FATAL_ERROR "ROOT_INSTALL_HEADERS no longer supports the OPTIONS argument. Rewrite using the FILTER argument.") + endif() + ROOT_FIND_DIRS_WITH_HEADERS(dirs ${ARG_UNPARSED_ARGUMENTS}) + set (filter "LinkDef") + set (options REGEX "LinkDef" EXCLUDE) + foreach (f ${ARG_FILTER}) + set (filter "${filter}|${f}") + set (options ${options} REGEX "${f}" EXCLUDE) + endforeach() + set (filter "(${filter})") + foreach(d ${dirs}) + install(DIRECTORY ${d} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + COMPONENT headers + ${options}) + string(REGEX REPLACE "(.*)/$" "\\1" d ${d}) + ROOT_GLOB_FILES(include_files + RECURSE + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/${d} + FILTER ${filter} + ${d}/*.h ${d}/*.hxx ${d}/*.icc ) + foreach (include_file ${include_files}) + set (src ${CMAKE_CURRENT_SOURCE_DIR}/${d}/${include_file}) + set (dst ${CMAKE_BINARY_DIR}/include/${include_file}) + add_custom_command( + OUTPUT ${dst} + COMMAND ${CMAKE_COMMAND} -E copy ${src} ${dst} + COMMENT "Copying header ${src} to ${CMAKE_BINARY_DIR}/include" + DEPENDS ${src}) + list(APPEND dst_list ${dst}) + endforeach() + endforeach() + if (dst_list) + string(REPLACE ${CMAKE_SOURCE_DIR} "" tgt ${CMAKE_CURRENT_SOURCE_DIR}) + string(MAKE_C_IDENTIFIER move_header${tgt} tgt) + set_property(GLOBAL APPEND PROPERTY ROOT_HEADER_TARGETS ${tgt}) + add_custom_target(${tgt} DEPENDS ${dst_list}) + endif() +endfunction() + +#--------------------------------------------------------------------------------------------------- +#---ROOT_STANDARD_LIBRARY_PACKAGE(libname +# [NO_INSTALL_HEADERS] : don't install headers for this package +# [STAGE1] : use rootcling_stage1 for generating +# HEADERS header1 header2 : relative header path as #included; pass -I to find them. If not specified, globbing for *.h is used +# NODEPHEADERS header1 header2 : like HEADERS, but no dependency is generated +# [NO_HEADERS] : don't glob to fill HEADERS variable +# SOURCES source1 source2 : if not specified, globbing for *.cxx is used +# [NO_SOURCES] : don't glob to fill SOURCES variable +# [OBJECT_LIBRARY] : use ROOT_OBJECT_LIBRARY to generate object files +# and then use those for linking. +# LIBRARIES lib1 lib2 : linking flags such as dl, readline +# DEPENDENCIES lib1 lib2 : dependencies such as Core, MathCore +# BUILTINS builtin1 builtin2 : builtins like AFTERIMAGE +# LINKDEF LinkDef.h : linkdef file, default value is "LinkDef.h" +# DICTIONARY_OPTIONS option : options passed to rootcling +# INSTALL_OPTIONS option : options passed to install headers +# NO_CXXMODULE : don't generate a C++ module for this package +# ) +#--------------------------------------------------------------------------------------------------- +function(ROOT_STANDARD_LIBRARY_PACKAGE libname) + set(options NO_INSTALL_HEADERS STAGE1 NO_HEADERS NO_SOURCES OBJECT_LIBRARY NO_CXXMODULE) + set(oneValueArgs LINKDEF) + set(multiValueArgs DEPENDENCIES HEADERS NODEPHEADERS SOURCES BUILTINS LIBRARIES DICTIONARY_OPTIONS INSTALL_OPTIONS) + CMAKE_PARSE_ARGUMENTS(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + # Check if we have any unparsed arguments + if(ARG_UNPARSED_ARGUMENTS) + message(AUTHOR_WARNING "Unparsed arguments for ROOT_STANDARD_LIBRARY_PACKAGE: ${ARG_UNPARSED_ARGUMENTS}") + endif() + # Check that the user doesn't pass NO_HEADERS (to disable globbing) and HEADERS at the same time. + if ((ARG_HEADERS OR ARG_NODEPHEADERS) AND ARG_NO_HEADERS) + message(AUTHOR_WARNING "HEADERS and NO_HEADERS arguments are mutually exclusive.") + endif() + if (ARG_SOURCES AND ARG_NO_SOURCES) + message(AUTHOR_WARNING "SOURCES and NO_SOURCES arguments are mutually exclusive.") + endif() + + # Set default values + # If HEADERS/SOURCES are not parsed, we glob for those files. + if (NOT (ARG_HEADERS OR ARG_NO_HEADERS OR ARG_NODEPHEADERS)) + set(ARG_HEADERS "*.h") + endif() + if (NOT ARG_SOURCES AND NOT ARG_NO_SOURCES) + set(ARG_SOURCES "*.cxx") + endif() + if (NOT ARG_LINKDEF) + set(ARG_LINKDEF "LinkDef.h") + endif() + + if (ARG_STAGE1) + set(STAGE1_FLAG "STAGE1") + endif() + + if (ARG_NO_CXXMODULE) + set(NO_CXXMODULE_FLAG "NO_CXXMODULE") + endif() + + if(ARG_NO_SOURCES) + # Workaround bug in CMake by adding a dummy source file if all sources are generated, since + # in that case the initial call to add_library() may not list any sources and CMake complains. + add_custom_command(OUTPUT dummy.cxx COMMAND ${CMAKE_COMMAND} -E touch dummy.cxx) + endif() + + if(runtime_cxxmodules) + # Record ROOT targets to be used as a dependency targets for "onepcm" target. + set(ROOT_LIBRARY_TARGETS "${ROOT_LIBRARY_TARGETS};${libname}" CACHE STRING "List of ROOT targets generated from ROOT_STANDARD_LIBRARY_PACKAGE()" FORCE) + endif() + + if (PROJECT_NAME STREQUAL ROOT) + include_directories(BEFORE "inc") + if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/v7/inc") + include_directories(BEFORE "v7/inc") + endif() + endif() + + if (ARG_OBJECT_LIBRARY) + ROOT_OBJECT_LIBRARY(${libname}Objs ${ARG_SOURCES} + $<$:dummy.cxx>) + ROOT_LINKER_LIBRARY(${libname} $ + LIBRARIES ${ARG_LIBRARIES} + DEPENDENCIES ${ARG_DEPENDENCIES} + BUILTINS ${ARG_BUILTINS} + ) + else(ARG_OBJECT_LIBRARY) + ROOT_LINKER_LIBRARY(${libname} ${ARG_SOURCES} + $<$:dummy.cxx> + LIBRARIES ${ARG_LIBRARIES} + DEPENDENCIES ${ARG_DEPENDENCIES} + BUILTINS ${ARG_BUILTINS} + ) + endif(ARG_OBJECT_LIBRARY) + + if (NOT (ARG_HEADERS OR ARG_NODEPHEADERS)) + message(AUTHOR_WARNING "Called with no HEADERS and no NODEPHEADER. The generated " + "dictionary will be empty. Consider using ROOT_LINKER_LIBRARY instead.") + endif() + + ROOT_GENERATE_DICTIONARY(G__${libname} ${ARG_HEADERS} + ${NO_CXXMODULE_FLAG} + ${STAGE1_FLAG} + MODULE ${libname} + LINKDEF ${ARG_LINKDEF} + NODEPHEADERS ${ARG_NODEPHEADERS} + OPTIONS ${ARG_DICTIONARY_OPTIONS} + DEPENDENCIES ${ARG_DEPENDENCIES} + BUILTINS ${ARG_BUILTINS} + ) + + # Dictionary might include things from the current src dir, e.g. tests. Alas + # there is no way to set the include directory for a source file (except for + # the generic COMPILE_FLAGS), so this needs to be glued to the target. + if(NOT (CMAKE_PROJECT_NAME STREQUAL ROOT)) + target_include_directories(${libname} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + endif() + + # Install headers if we have any headers and if the user didn't explicitly + # disabled this. + if (NOT ARG_NO_INSTALL_HEADERS OR ARG_NO_HEADERS) + ROOT_INSTALL_HEADERS(${ARG_INSTALL_OPTIONS}) + endif() +endfunction() + +#--------------------------------------------------------------------------------------------------- +#---ROOT_EXECUTABLE( source1 source2 ... LIBRARIES library1 library2 ... BUILTINS dep1 dep2 ...) +#--------------------------------------------------------------------------------------------------- +function(ROOT_EXECUTABLE executable) + CMAKE_PARSE_ARGUMENTS(ARG "CMAKENOEXPORT;NOINSTALL;TEST" "" "LIBRARIES;BUILTINS;ADDITIONAL_COMPILE_FLAGS" ${ARGN}) + ROOT_GET_SOURCES(exe_srcs src ${ARG_UNPARSED_ARGUMENTS}) + set(executable_name ${executable}) + if(TARGET ${executable}) + message("Target ${executable} already exists. Renaming target name to ${executable}_new") + set(executable ${executable}_new) + endif() + if(ARG_TEST) # we are building a test, so add EXCLUDE_FROM_ALL + set(_all EXCLUDE_FROM_ALL) + endif() + if(NOT (PROJECT_NAME STREQUAL "ROOT")) + # only for non-ROOT executable use $ROOTSYS/include + include_directories(BEFORE ${CMAKE_BINARY_DIR}/include) + elseif(MSVC) + set(exe_srcs ${exe_srcs} ${ROOT_RC_SCRIPT}) + endif() + add_executable(${executable} ${_all} ${exe_srcs}) + target_link_libraries(${executable} ${ARG_LIBRARIES}) + + if(PROJECT_NAME STREQUAL "ROOT") + set(dep_list) + if(ARG_LIBRARIES) + foreach(lib ${ARG_LIBRARIES}) + if(TARGET ${lib}) + get_target_property(lib_incdirs ${lib} INCLUDE_DIRECTORIES) + if(lib_incdirs) + foreach(dir ${lib_incdirs}) + ROOT_REPLACE_BUILD_INTERFACE(dir ${dir}) + if(NOT ${dir} MATCHES "^[$]") + list(APPEND dep_list ${dir}) + endif() + endforeach() + endif() + endif() + endforeach() + endif() + if(dep_list) + list(REMOVE_DUPLICATES dep_list) + foreach(incl ${dep_list}) + target_include_directories(${executable} PRIVATE ${incl}) + endforeach() + endif() + endif() + + if(WIN32 AND ${executable} MATCHES \\.exe) + set_target_properties(${executable} PROPERTIES SUFFIX "") + endif() + set_property(GLOBAL APPEND PROPERTY ROOT_EXPORTED_TARGETS ${executable}) + set_target_properties(${executable} PROPERTIES OUTPUT_NAME ${executable_name}) + if (ARG_ADDITIONAL_COMPILE_FLAGS) + set_target_properties(${executable} PROPERTIES COMPILE_FLAGS ${ARG_ADDITIONAL_COMPILE_FLAGS}) + endif() + if(CMAKE_PROJECT_NAME STREQUAL ROOT) + add_dependencies(${executable} move_headers) + endif() + if(ARG_BUILTINS) + foreach(arg1 ${ARG_BUILTINS}) + if(${arg1}_TARGET) + add_dependencies(${executable} ${${arg1}_TARGET}) + endif() + endforeach() + endif() + if(TARGET ROOT::ROOTStaticSanitizerConfig) + set_property(TARGET ${executable} + APPEND PROPERTY LINK_LIBRARIES ROOT::ROOTStaticSanitizerConfig) + endif() + #----Installation details------------------------------------------------------ + if(NOT ARG_NOINSTALL AND CMAKE_RUNTIME_OUTPUT_DIRECTORY) + if(ARG_CMAKENOEXPORT) + install(TARGETS ${executable} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT applications) + else() + install(TARGETS ${executable} EXPORT ${CMAKE_PROJECT_NAME}Exports RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT applications) + endif() + if(WIN32) + install(FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${executable}.pdb + CONFIGURATIONS Debug RelWithDebInfo + DESTINATION ${CMAKE_INSTALL_BINDIR} + COMPONENT applications) + endif() + endif() +endfunction() + +#--------------------------------------------------------------------------------------------------- +#---REFLEX_BUILD_DICTIONARY( dictionary headerfiles selectionfile OPTIONS opt1 opt2 ... LIBRARIES lib1 lib2 ... ) +#--------------------------------------------------------------------------------------------------- +function(REFLEX_BUILD_DICTIONARY dictionary headerfiles selectionfile ) + CMAKE_PARSE_ARGUMENTS(ARG "" "" "LIBRARIES;OPTIONS" ${ARGN}) + REFLEX_GENERATE_DICTIONARY(${dictionary} ${headerfiles} SELECTION ${selectionfile} OPTIONS ${ARG_OPTIONS}) + add_library(${dictionary}Dict MODULE ${gensrcdict}) + target_link_libraries(${dictionary}Dict ${ARG_LIBRARIES} ${ROOT_Reflex_LIBRARY}) + #----Installation details------------------------------------------------------- + install(TARGETS ${dictionary}Dict LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + set(mergedRootMap ${CMAKE_INSTALL_PREFIX}/${lib}/${CMAKE_PROJECT_NAME}Dict.rootmap) + set(srcRootMap ${CMAKE_CURRENT_BINARY_DIR}/${rootmapname}) + install(CODE "EXECUTE_PROCESS(COMMAND ${merge_rootmap_cmd} --do-merge --input-file ${srcRootMap} --merged-file ${mergedRootMap})") +endfunction() + +# Need to set this outside of the function so that ${CMAKE_CURRENT_LIST_DIR} +# is for RootMacros.cmake and not for the file currently calling the function. +set(ROOT_TEST_DRIVER ${CMAKE_CURRENT_LIST_DIR}/RootTestDriver.cmake) + +#---------------------------------------------------------------------------- +# function ROOT_ADD_TEST( COMMAND cmd [arg1... ] +# [PRECMD cmd [arg1...]] [POSTCMD cmd [arg1...]] +# [OUTPUT outfile] [ERROR errfile] [INPUT infile] +# [ENVIRONMENT var1=val1 var2=val2 ... +# [DEPENDS test1 ...] +# [RUN_SERIAL] +# [TIMEOUT seconds] +# [DEBUG] +# [SOURCE_DIR dir] [BINARY_DIR dir] +# [WORKING_DIR dir] [COPY_TO_BUILDDIR files] +# [BUILD target] [PROJECT project] +# [PASSREGEX exp] [FAILREGEX epx] +# [PASSRC code] +# [RESOURCE_LOCK lock] +# [FIXTURES_SETUP ...] [FIXTURES_CLEANUP ...] [FIXTURES_REQUIRED ...] +# [LABELS label1 label2] +# [PYTHON_DEPS numpy numba keras torch ...] # List of python packages required to run this test. +# A fixture will be added the tries to import them before the test starts. +# [PROPERTIES prop1 value1 prop2 value2...] +# ) +# +function(ROOT_ADD_TEST test) + CMAKE_PARSE_ARGUMENTS(ARG "DEBUG;WILLFAIL;CHECKOUT;CHECKERR;RUN_SERIAL" + "TIMEOUT;BUILD;INPUT;OUTPUT;ERROR;SOURCE_DIR;BINARY_DIR;WORKING_DIR;PROJECT;PASSRC;RESOURCE_LOCK" + "COMMAND;COPY_TO_BUILDDIR;DIFFCMD;OUTCNV;OUTCNVCMD;PRECMD;POSTCMD;ENVIRONMENT;COMPILEMACROS;DEPENDS;PASSREGEX;OUTREF;ERRREF;FAILREGEX;LABELS;PYTHON_DEPS;FIXTURES_SETUP;FIXTURES_CLEANUP;FIXTURES_REQUIRED;PROPERTIES" + ${ARGN}) + + #- Handle COMMAND argument + list(LENGTH ARG_COMMAND _len) + if(_len LESS 1) + if(NOT ARG_BUILD) + message(FATAL_ERROR "ROOT_ADD_TEST: command is mandatory (without build)") + endif() + else() + list(GET ARG_COMMAND 0 _prg) + list(REMOVE_AT ARG_COMMAND 0) + + if(TARGET ${_prg}) # if command is a target, get the actual executable + set(_prg "$") + set(_cmd ${_prg} ${ARG_COMMAND}) + else() + find_program(_exe ${_prg}) + if(_exe) # if the command is found in the system, use it + set(_cmd ${_exe} ${ARG_COMMAND}) + elseif(NOT IS_ABSOLUTE ${_prg}) # if not absolute, assume is found in current binary dir + set(_prg ${CMAKE_CURRENT_BINARY_DIR}/${_prg}) + set(_cmd ${_prg} ${ARG_COMMAND}) + else() # take as it is + set(_cmd ${_prg} ${ARG_COMMAND}) + endif() + unset(_exe CACHE) + endif() + + string(REPLACE ";" "^" _cmd "${_cmd}") + endif() + + set(_command ${CMAKE_COMMAND} -DCMD=${_cmd}) + + #- Handle PRE and POST commands + if(ARG_PRECMD) + string(REPLACE ";" "^" _pre "${ARG_PRECMD}") + set(_command ${_command} -DPRE=${_pre}) + endif() + + if(ARG_POSTCMD) + string(REPLACE ";" "^" _post "${ARG_POSTCMD}") + set(_command ${_command} -DPOST=${_post}) + endif() + + #- Handle INPUT, OUTPUT, ERROR, DEBUG arguments + if(ARG_INPUT) + set(_command ${_command} -DIN=${ARG_INPUT}) + endif() + + if(ARG_OUTPUT) + set(_command ${_command} -DOUT=${ARG_OUTPUT}) + endif() + + if(ARG_OUTREF) + set(_command ${_command} -DOUTREF=${ARG_OUTREF}) + endif() + + if(ARG_ERRREF) + set(_command ${_command} -DERRREF=${ARG_ERRREF}) + endif() + + if(ARG_ERROR) + set(_command ${_command} -DERR=${ARG_ERROR}) + endif() + + if(ARG_WORKING_DIR) + set(_command ${_command} -DCWD=${ARG_WORKING_DIR}) + endif() + + if(ARG_DEBUG) + set(_command ${_command} -DDBG=ON) + endif() + + if(ARG_PASSRC) + set(_command ${_command} -DRC=${ARG_PASSRC}) + endif() + + if(ARG_OUTCNVCMD) + string(REPLACE ";" "^" _outcnvcmd "${ARG_OUTCNVCMD}") + string(REPLACE "=" "@" _outcnvcmd "${_outcnvcmd}") + set(_command ${_command} -DCNVCMD=${_outcnvcmd}) + endif() + + if(ARG_OUTCNV) + string(REPLACE ";" "^" _outcnv "${ARG_OUTCNV}") + set(_command ${_command} -DCNV=${_outcnv}) + endif() + + if(ARG_DIFFCMD) + string(REPLACE ";" "^" _diff_cmd "${ARG_DIFFCMD}") + set(_command ${_command} -DDIFFCMD=${_diff_cmd}) + + if(TARGET ROOT::ROOTStaticSanitizerConfig) + # We have to set up leak sanitizer such that it doesn't report on suppressed + # leaks. Otherwise, all diffs will fail. + set(LSAN_OPT ARG_ENVIRONMENT) + list(FILTER LSAN_OPT INCLUDE REGEX LSAN_OPTIONS=[^;]+) + if(NOT LSAN_OPT MATCHES LSAN_OPTIONS=.*) + set(LSAN_OPT LSAN_OPTIONS=) + endif() + string(APPEND LSAN_OPT ":print_suppressions=0") + list(FILTER ARG_ENVIRONMENT EXCLUDE REGEX LSAN_OPTIONS.*) + list(APPEND ARG_ENVIRONMENT ${LSAN_OPT}) + endif() + endif() + + if(ARG_CHECKOUT) + set(_command ${_command} -DCHECKOUT=true) + endif() + + if(ARG_CHECKERR) + set(_command ${_command} -DCHECKERR=true) + endif() + + set(_command ${_command} -DSYS=${ROOTSYS}) + + #- Handle ENVIRONMENT argument + if(ASAN_EXTRA_LD_PRELOAD) + # Address sanitizer runtime needs to be preloaded in all python tests + # Check now if the -DCMD= contains "python[0-9.] ", but exclude helper + # scripts such as roottest/root/meta/genreflex/XMLParsing/parseXMLs.py + # and roottest/root/rint/driveTabCom.py + set(theCommand ${_command}) + list(FILTER theCommand INCLUDE REGEX "^-DCMD=.*python[0-9.]*[\\^]") + if((theCommand AND + NOT (_command MATCHES XMLParsing/parseXMLs.py OR + _command MATCHES roottest/root/rint/driveTabCom.py)) + OR (_command MATCHES roottest/python/cmdLineUtils AND + NOT _command MATCHES MakeNameCyclesRootmvInput)) + set(_command ${_command} -DCMD_ENV=${ld_preload}=${ASAN_EXTRA_LD_PRELOAD}) + endif() + endif() + + if(ARG_ENVIRONMENT) + string(REPLACE ";" "#" _env "${ARG_ENVIRONMENT}") + set(_command ${_command} -DENV=${_env}) + endif() + + #- Copy files to the build directory. + if(ARG_COPY_TO_BUILDDIR) + string(REPLACE ";" "^" _copy_files "${ARG_COPY_TO_BUILDDIR}") + set(_command ${_command} -DCOPY=${_copy_files}) + endif() + + set(_command ${_command} -P ${ROOT_TEST_DRIVER}) + + if(ARG_WILLFAIL) + set(test ${test}_WILL_FAIL) + endif() + + #- Now we can actually add the test + if(ARG_BUILD) + if(NOT ARG_SOURCE_DIR) + set(ARG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + endif() + if(NOT ARG_BINARY_DIR) + set(ARG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) + endif() + if(NOT ARG_PROJECT) + if(NOT PROJECT_NAME STREQUAL "ROOT") + set(ARG_PROJECT ${PROJECT_NAME}) + else() + set(ARG_PROJECT ${ARG_BUILD}) + endif() + endif() + add_test(NAME ${test} COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test ${ARG_SOURCE_DIR} ${ARG_BINARY_DIR} + --build-generator ${CMAKE_GENERATOR} + --build-makeprogram ${CMAKE_MAKE_PROGRAM} + --build-target ${ARG_BUILD} + --build-project ${ARG_PROJECT} + --build-config $ + --build-noclean + --test-command ${_command} ) + set_property(TEST ${test} PROPERTY ENVIRONMENT ROOT_DIR=${CMAKE_BINARY_DIR}) + else() + add_test(NAME ${test} COMMAND ${_command}) + if (gnuinstall) + set_property(TEST ${test} PROPERTY ENVIRONMENT ROOTIGNOREPREFIX=1) + endif() + endif() + + #- provided fixtures and resource lock are set here + if (ARG_FIXTURES_SETUP) + set_property(TEST ${test} PROPERTY + FIXTURES_SETUP ${ARG_FIXTURES_SETUP}) + endif() + + if (ARG_FIXTURES_CLEANUP) + set_property(TEST ${test} PROPERTY + FIXTURES_CLEANUP ${ARG_FIXTURES_CLEANUP}) + endif() + + if (ARG_FIXTURES_REQUIRED) + set_property(TEST ${test} PROPERTY + FIXTURES_REQUIRED ${ARG_FIXTURES_REQUIRED}) + endif() + + if (ARG_RESOURCE_LOCK) + set_property(TEST ${test} PROPERTY + RESOURCE_LOCK ${ARG_RESOURCE_LOCK}) + endif() + + set_property(TEST ${test} APPEND PROPERTY ENVIRONMENT ROOT_HIST=0) + + #- Handle TIMEOUT and DEPENDS arguments + if(ARG_TIMEOUT) + set_property(TEST ${test} PROPERTY TIMEOUT ${ARG_TIMEOUT}) + endif() + + if(ARG_DEPENDS) + set_property(TEST ${test} PROPERTY DEPENDS ${ARG_DEPENDS}) + endif() + + if(ARG_PASSREGEX) + set_property(TEST ${test} PROPERTY PASS_REGULAR_EXPRESSION ${ARG_PASSREGEX}) + endif() + + if(ARG_FAILREGEX) + set_property(TEST ${test} PROPERTY FAIL_REGULAR_EXPRESSION ${ARG_FAILREGEX}) + endif() + + if(ARG_WILLFAIL) + set_property(TEST ${test} PROPERTY WILL_FAIL true) + endif() + + if(ARG_LABELS) + set_tests_properties(${test} PROPERTIES LABELS "${ARG_LABELS}") + endif() + + if(ARG_PYTHON_DEPS) + foreach(python_dep ${ARG_PYTHON_DEPS}) + if(NOT TEST test-import-${python_dep}) + add_test(NAME test-import-${python_dep} COMMAND ${Python3_EXECUTABLE} -c "import ${python_dep}") + set_tests_properties(test-import-${python_dep} PROPERTIES FIXTURES_SETUP requires_${python_dep}) + endif() + list(APPEND fixtures "requires_${python_dep}") + endforeach() + if(fixtures) + set_tests_properties(${test} PROPERTIES FIXTURES_REQUIRED "${fixtures}") + endif() + endif() + + if(ARG_RUN_SERIAL) + set_property(TEST ${test} PROPERTY RUN_SERIAL true) + endif() + + # Pass PROPERTIES argument to the set_tests_properties as-is + if(ARG_PROPERTIES) + set_tests_properties(${test} PROPERTIES ${ARG_PROPERTIES}) + endif() + +endfunction() + +#---------------------------------------------------------------------------- +# ROOT_PATH_TO_STRING( path PATH_SEPARATOR_REPLACEMENT replacement ) +# +# Mangle the path to a string. +#---------------------------------------------------------------------------- +function(ROOT_PATH_TO_STRING resultvar path) + # FIXME: Copied and modified from ROOTTEST_TARGETNAME_FROM_FILE. We should find a common place for that code. + # FIXME: ROOTTEST_TARGETNAME_FROM_FILE could be replaced by just a call to string(MAKE_C_IDENTIFIER)... + CMAKE_PARSE_ARGUMENTS(ARG "" "" "PATH_SEPARATOR_REPLACEMENT" ${ARGN}) + + set(sep_replacement "") + if (ARG_PATH_SEPARATOR_REPLACEMENT) + set(sep_replacement ${ARG_PATH_SEPARATOR_REPLACEMENT}) + endif() + + get_filename_component(realfp ${path} ABSOLUTE) + get_filename_component(filename_we ${path} NAME_WE) + + string(REPLACE "${CMAKE_SOURCE_DIR}" "" relativepath ${realfp}) + string(REPLACE "${path}" "" relativepath ${relativepath}) + + string(MAKE_C_IDENTIFIER ${relativepath}${filename_we} mangledname) + string(REPLACE "_" "${sep_replacement}" mangledname ${mangledname}) + + set(${resultvar} "${mangledname}" PARENT_SCOPE) +endfunction(ROOT_PATH_TO_STRING) + +#---------------------------------------------------------------------------- +# ROOT_ADD_UNITTEST_DIR() +#---------------------------------------------------------------------------- +function(ROOT_ADD_UNITTEST_DIR) + ROOT_GLOB_FILES(test_files ${CMAKE_CURRENT_SOURCE_DIR}/*.cxx) + # Get the component from the path. Eg. core to form coreTests test suite name. + ROOT_PATH_TO_STRING(test_name ${CMAKE_CURRENT_SOURCE_DIR}/) + ROOT_ADD_GTEST(${test_name}Unit ${test_files} LIBRARIES ${ARGN}) +endfunction() + +#---------------------------------------------------------------------------- +# function ROOT_ADD_GTEST( source1 source2... +# [WILLFAIL] Negate output of test +# [TIMEOUT seconds] +# [COPY_TO_BUILDDIR file1 file2] Copy listed files when ctest invokes the test. +# [LIBRARIES lib1 lib2...] -- Libraries to link against +# [LABELS label1 label2...] -- Labels to annotate the test +# [INCLUDE_DIRS label1 label2...] -- Extra target include directories +# [REPEATS number] -- Repeats testsuite `number` times, stopping at the first failure. +# [FAILREGEX ...] Fail test if this regex matches. +# Creates a new googletest exectuable, and registers it as a test. +#---------------------------------------------------------------------------- +function(ROOT_ADD_GTEST test_suite) + cmake_parse_arguments(ARG + "WILLFAIL" + "TIMEOUT;REPEATS;FAILREGEX" + "COPY_TO_BUILDDIR;LIBRARIES;LABELS;INCLUDE_DIRS" ${ARGN}) + + ROOT_GET_SOURCES(source_files . ${ARG_UNPARSED_ARGUMENTS}) + # Note we cannot use ROOT_EXECUTABLE without user-specified set of LIBRARIES to link with. + # The test suites should choose this in their specific CMakeLists.txt file. + # FIXME: For better coherence we could restrict the libraries the test suite could link + # against. For example, tests in Core should link only against libCore. This could be tricky + # to implement because some ROOT components create more than one library. + ROOT_EXECUTABLE(${test_suite} ${source_files} LIBRARIES ${ARG_LIBRARIES}) + target_link_libraries(${test_suite} gtest_main gmock gmock_main) + if(TARGET ROOT::TestSupport) + target_link_libraries(${test_suite} ROOT::TestSupport) + else() + message(WARNING "ROOT_ADD_GTEST(${test_suite} ...): The target ROOT::TestSupport is missing. It looks like the test is declared against a ROOT build that is configured with -Dtesting=OFF. + If this test sends warning or error messages, this will go unnoticed.") + endif() + target_include_directories(${test_suite} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) + if (ARG_INCLUDE_DIRS) + target_include_directories(${test_suite} PRIVATE ${ARG_INCLUDE_DIRS}) + endif(ARG_INCLUDE_DIRS) + + if(MSVC) + set(test_exports "/EXPORT:_Init_thread_abort /EXPORT:_Init_thread_epoch + /EXPORT:_Init_thread_footer /EXPORT:_Init_thread_header /EXPORT:_tls_index") + set_property(TARGET ${test_suite} APPEND_STRING PROPERTY LINK_FLAGS ${test_exports}) + endif() + + if(ARG_WILLFAIL) + set(willfail WILLFAIL) + endif() + + if(ARG_REPEATS) + set(extra_command --gtest_repeat=${ARG_REPEATS} --gtest_break_on_failure) + endif() + + ROOT_PATH_TO_STRING(mangled_name ${test_suite} PATH_SEPARATOR_REPLACEMENT "-") + ROOT_ADD_TEST( + gtest${mangled_name} + COMMAND ${test_suite} ${extra_command} + WORKING_DIR ${CMAKE_CURRENT_BINARY_DIR} + COPY_TO_BUILDDIR "${ARG_COPY_TO_BUILDDIR}" + ${willfail} + TIMEOUT "${ARG_TIMEOUT}" + LABELS "${ARG_LABELS}" + FAILREGEX "${ARG_FAILREGEX}" + ) +endfunction() + + +#---------------------------------------------------------------------------- +# ROOT_ADD_TEST_SUBDIRECTORY( ) +#---------------------------------------------------------------------------- +function(ROOT_ADD_TEST_SUBDIRECTORY subdir) + file(RELATIVE_PATH subdir ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}) + set_property(GLOBAL APPEND PROPERTY ROOT_TEST_SUBDIRS ${subdir}) +endfunction() + +#---------------------------------------------------------------------------- +# ROOT_ADD_PYUNITTESTS( ) +#---------------------------------------------------------------------------- +function(ROOT_ADD_PYUNITTESTS name) + if(MSVC) + set(ROOT_ENV ROOTSYS=${ROOTSYS} + PYTHONPATH=${ROOTSYS}/bin;$ENV{PYTHONPATH}) + else() + set(ROOT_ENV ROOTSYS=${ROOTSYS} + PATH=${ROOTSYS}/bin:$ENV{PATH} + LD_LIBRARY_PATH=${ROOTSYS}/lib:$ENV{LD_LIBRARY_PATH} + PYTHONPATH=${ROOTSYS}/lib:$ENV{PYTHONPATH}) + endif() + string(REGEX REPLACE "[_]" "-" good_name "${name}") + ROOT_ADD_TEST(pyunittests-${good_name} + COMMAND ${Python3_EXECUTABLE} -B -m unittest discover -s ${CMAKE_CURRENT_SOURCE_DIR} -p "*.py" -v + ENVIRONMENT ${ROOT_ENV}) +endfunction() + +#---------------------------------------------------------------------------- +# ROOT_ADD_PYUNITTEST( +# [WILLFAIL] +# [COPY_TO_BUILDDIR copy_file1 copy_file1 ...] +# [ENVIRONMENT var1=val1 var2=val2 ...] +# [PYTHON_DEPS dep_x dep_y ...] # Communicate that this test requires python packages. A fixture checking for these will be run before the test.) +#---------------------------------------------------------------------------- +function(ROOT_ADD_PYUNITTEST name file) + CMAKE_PARSE_ARGUMENTS(ARG "WILLFAIL" "" "COPY_TO_BUILDDIR;ENVIRONMENT;PYTHON_DEPS" ${ARGN}) + if(MSVC) + set(ROOT_ENV ROOTSYS=${ROOTSYS} + PYTHONPATH=${ROOTSYS}/bin;$ENV{PYTHONPATH}) + else() + set(ROOT_ENV ROOTSYS=${ROOTSYS} + PATH=${ROOTSYS}/bin:$ENV{PATH} + LD_LIBRARY_PATH=${ROOTSYS}/lib:$ENV{LD_LIBRARY_PATH} + PYTHONPATH=${ROOTSYS}/lib:$ENV{PYTHONPATH}) + endif() + string(REGEX REPLACE "[_]" "-" good_name "${name}") + get_filename_component(file_name ${file} NAME) + get_filename_component(file_dir ${file} DIRECTORY) + + if(ARG_COPY_TO_BUILDDIR) + foreach(copy_file ${ARG_COPY_TO_BUILDDIR}) + get_filename_component(abs_path ${copy_file} ABSOLUTE) + set(copy_files ${copy_files} ${abs_path}) + endforeach() + set(copy_to_builddir COPY_TO_BUILDDIR ${copy_files}) + endif() + + if(ARG_WILLFAIL) + set(will_fail WILLFAIL) + endif() + + if(ARG_PYTHON_DEPS) + list(APPEND labels python_runtime_deps) + endif() + + ROOT_ADD_TEST(pyunittests-${good_name} + COMMAND ${Python3_EXECUTABLE} -B -m unittest discover -s ${CMAKE_CURRENT_SOURCE_DIR}/${file_dir} -p ${file_name} -v + ENVIRONMENT ${ROOT_ENV} ${ARG_ENVIRONMENT} + LABELS ${labels} + ${copy_to_builddir} + ${will_fail} + PYTHON_DEPS ${ARG_PYTHON_DEPS}) +endfunction() + +#---------------------------------------------------------------------------- +# ROOT_ADD_CXX_FLAG(var flag) +#---------------------------------------------------------------------------- +function(ROOT_ADD_CXX_FLAG var flag) + string(REGEX REPLACE "[-.+/:= ]" "_" flag_esc "${flag}") + CHECK_CXX_COMPILER_FLAG("-Werror ${flag}" CXX_HAS${flag_esc}) + if(CXX_HAS${flag_esc}) + set(${var} "${${var}} ${flag}" PARENT_SCOPE) + endif() +endfunction() +#---------------------------------------------------------------------------- +# ROOT_ADD_C_FLAG(var flag) +#---------------------------------------------------------------------------- +function(ROOT_ADD_C_FLAG var flag) + string(REGEX REPLACE "[-.+/:= ]" "_" flag_esc "${flag}") + CHECK_C_COMPILER_FLAG("-Werror ${flag}" C_HAS${flag_esc}) + if(C_HAS${flag_esc}) + set(${var} "${${var}} ${flag}" PARENT_SCOPE) + endif() +endfunction() + +#---------------------------------------------------------------------------- +# ROOT_ADD_COMPILE_OPTIONS(flags) +#---------------------------------------------------------------------------- +macro(ROOT_ADD_COMPILE_OPTIONS flags) + foreach(__flag ${flags}) + check_cxx_compiler_flag("-Werror ${__flag}" __result) + if(__result) + add_compile_options(${__flag}) + endif() + endforeach() + unset(__flag) + unset(__result) +endmacro() + +#---------------------------------------------------------------------------- +# find_python_module(module [REQUIRED] [QUIET]) +#---------------------------------------------------------------------------- +function(find_python_module module) + CMAKE_PARSE_ARGUMENTS(ARG "REQUIRED;QUIET" "" "" ${ARGN}) + string(TOUPPER ${module} module_upper) + if(NOT PY_${module_upper}) + if(ARG_REQUIRED) + set(py_${module}_FIND_REQUIRED TRUE) + endif() + if(ARG_QUIET) + set(py_${module}_FIND_QUIETLY TRUE) + endif() + # A module's location is usually a directory, but for binary modules + # it's a .so file. + execute_process(COMMAND "${Python3_EXECUTABLE}" "-c" + "import re, ${module}; print(re.compile('/__init__.py.*').sub('',${module}.__file__))" + RESULT_VARIABLE _${module}_status + OUTPUT_VARIABLE _${module}_location + ERROR_VARIABLE _${module}_error + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_STRIP_TRAILING_WHITESPACE) + if(NOT _${module}_status) + set(PY_${module_upper} ${_${module}_location} CACHE STRING "Location of Python module ${module}") + mark_as_advanced(PY_${module_upper}) + else() + if(NOT ARG_QUIET) + message(STATUS "Failed to find Python module ${module}: ${_${module}_error}") + endif() + endif() + endif() + find_package_handle_standard_args(py_${module} DEFAULT_MSG PY_${module_upper}) + set(PY_${module_upper}_FOUND ${PY_${module_upper}_FOUND} PARENT_SCOPE) +endfunction() + +#---------------------------------------------------------------------------- +# generateHeader(target input output) +# Generate a help header file with build/misc/argparse2help.py script +# The 1st argument is the target to which the custom command will be attached +# The 2nd argument is the path to the python argparse input file +# The 3rd argument is the path to the output header file +#---------------------------------------------------------------------------- +function(generateHeader target input output) + add_custom_command(OUTPUT ${output} + MAIN_DEPENDENCY + ${input} + DEPENDS + ${CMAKE_SOURCE_DIR}/build/misc/argparse2help.py + COMMAND + ${Python3_EXECUTABLE} -B ${CMAKE_SOURCE_DIR}/build/misc/argparse2help.py ${input} ${output} + ) + target_sources(${target} PRIVATE ${output}) +endfunction() + +#---------------------------------------------------------------------------- +# Generate and install manual page with build/misc/argparse2help.py script +# The 1st argument is the name of the manual page +# The 2nd argument is the path to the python argparse input file +# The 3rd argument is the path to the output manual page +#---------------------------------------------------------------------------- +function(generateManual name input output) + add_custom_target(${name} ALL DEPENDS ${output}) + + add_custom_command(OUTPUT ${output} + MAIN_DEPENDENCY + ${input} + DEPENDS + ${CMAKE_SOURCE_DIR}/build/misc/argparse2help.py + COMMAND + ${Python3_EXECUTABLE} -B ${CMAKE_SOURCE_DIR}/build/misc/argparse2help.py ${input} ${output} + ) + + install(FILES ${output} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) +endfunction() From 6a09c01acb52ecd7ac201d5fbc2e978c19b95f87 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 14 Aug 2024 11:08:31 +0200 Subject: [PATCH 13/48] Add support for REFLEX argument. --- cmake/RootMacros.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/RootMacros.cmake b/cmake/RootMacros.cmake index a483d9727..52fee547d 100644 --- a/cmake/RootMacros.cmake +++ b/cmake/RootMacros.cmake @@ -280,9 +280,11 @@ endfunction(ROOT_REPLACE_BUILD_INTERFACE) # The dictionary target depends on these headers. These files must exist. # same as . If these files are not found (given the target include path) # no error is emitted. The dictionary does not depend on these headers. +# is for enabling rootcling's reflex mode. In this mode the LinkDef needs to be an XML Selection +# file. #--------------------------------------------------------------------------------------------------- function(ROOT_GENERATE_DICTIONARY dictionary) - CMAKE_PARSE_ARGUMENTS(ARG "STAGE1;MULTIDICT;NOINSTALL;NO_CXXMODULE" + CMAKE_PARSE_ARGUMENTS(ARG "STAGE1;MULTIDICT;NOINSTALL;NO_CXXMODULE;REFLEX" "MODULE;LINKDEF" "NODEPHEADERS;OPTIONS;DEPENDENCIES;EXTRA_DEPENDENCIES;BUILTINS" ${ARGN}) # Check if OPTIONS start with a dash. @@ -603,6 +605,10 @@ function(ROOT_GENERATE_DICTIONARY dictionary) set(newargs -cxxmodule ${newargs}) endif() + if(ARG_REFLEX) + set(newargs -reflex ${newargs}) + endif() + #---what rootcling command to use-------------------------- if(ARG_STAGE1) if(MSVC AND CMAKE_ROOTTEST_DICT) From e7f40b3b186198abea1d5af1f9d710cac38a4967 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 14 Aug 2024 11:12:42 +0200 Subject: [PATCH 14/48] Change .cxx entension to .cc BioDynaMo's already uses .cc extension for the dictionary files, so I don't want to change that --- cmake/RootMacros.cmake | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cmake/RootMacros.cmake b/cmake/RootMacros.cmake index 52fee547d..83dd550c9 100644 --- a/cmake/RootMacros.cmake +++ b/cmake/RootMacros.cmake @@ -150,7 +150,7 @@ function(REFLEX_GENERATE_DICTIONARY dictionary) set(selectionfile ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_SELECTION}) endif() - set(gensrcdict ${dictionary}.cxx) + set(gensrcdict ${dictionary}.cc) #---roottest compability--------------------------------- if(CMAKE_ROOTTEST_NOROOTMAP) @@ -217,7 +217,7 @@ function(REFLEX_GENERATE_DICTIONARY dictionary) # FIXME: Do not set gensrcdict variable to the outer scope but use an argument to # REFLEX_GENERATE_DICTIONARY passed from the outside. Note this would be a # breaking change for roottest and other external users. - set(gensrcdict ${dictionary}.cxx PARENT_SCOPE) + set(gensrcdict ${dictionary}.cc PARENT_SCOPE) endfunction() @@ -275,7 +275,7 @@ endfunction(ROOT_REPLACE_BUILD_INTERFACE) # STAGE1 LINKDEF linkdef OPTIONS opt1 opt2 ...) # # is the dictionary stem; the macro creates (among other files) the dictionary source as -# .cxx +# .cc # are "as included"; set appropriate INCLUDE_DIRECTORIES property on the directory. # The dictionary target depends on these headers. These files must exist. # same as . If these files are not found (given the target include path) @@ -684,8 +684,8 @@ function(ROOT_GENERATE_DICTIONARY dictionary) endforeach() #---call rootcint------------------------------------------ - add_custom_command(OUTPUT ${dictionary}.cxx ${pcm_name} ${rootmap_name} ${cpp_module_file} - COMMAND ${command} -v2 -f ${dictionary}.cxx ${newargs} ${excludepathsargs} ${rootmapargs} + add_custom_command(OUTPUT ${dictionary}.cc ${pcm_name} ${rootmap_name} ${cpp_module_file} + COMMAND ${command} -v2 -f ${dictionary}.cc ${newargs} ${excludepathsargs} ${rootmapargs} ${ARG_OPTIONS} ${definitions} "$<$:-D$>" ${compIncPaths} @@ -704,7 +704,7 @@ function(ROOT_GENERATE_DICTIONARY dictionary) # the generated source at the same scope level as its owning target, something that # would not happen if we used target_sources() directly with the dictionary source. if(TARGET "${ARG_MODULE}" AND NOT "${ARG_MODULE}" STREQUAL "${dictionary}") - add_library(${dictionary} OBJECT ${dictionary}.cxx) + add_library(${dictionary} OBJECT ${dictionary}.cc) set_target_properties(${dictionary} PROPERTIES POSITION_INDEPENDENT_CODE TRUE) target_sources(${ARG_MODULE} PRIVATE $) @@ -721,12 +721,12 @@ function(ROOT_GENERATE_DICTIONARY dictionary) ${incdirs} $) else() get_filename_component(dictionary_name ${dictionary} NAME) - add_custom_target(${dictionary_name} DEPENDS ${dictionary}.cxx ${pcm_name} ${rootmap_name} ${cpp_module_file}) + add_custom_target(${dictionary_name} DEPENDS ${dictionary}.cc ${pcm_name} ${rootmap_name} ${cpp_module_file}) endif() if(PROJECT_NAME STREQUAL "ROOT") set_property(GLOBAL APPEND PROPERTY ROOT_PCH_DEPENDENCIES ${dictionary}) - set_property(GLOBAL APPEND PROPERTY ROOT_PCH_DICTIONARIES ${CMAKE_CURRENT_BINARY_DIR}/${dictionary}.cxx) + set_property(GLOBAL APPEND PROPERTY ROOT_PCH_DICTIONARIES ${CMAKE_CURRENT_BINARY_DIR}/${dictionary}.cc) endif() if(ARG_MULTIDICT) From 23ace6115a46237fb89f6938dd8544e4a3453d54 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 14 Aug 2024 11:15:36 +0200 Subject: [PATCH 15/48] Include RootMacros to the CMake Project Also removes the old ROOT_GENERATE_DICTIONARY and REFLEX_GENERATE_DICTIONARY functions from FindROOT.cmake --- cmake/FindROOT.cmake | 97 +------------------------------------------- cmake/utils.cmake | 1 + 2 files changed, 2 insertions(+), 96 deletions(-) diff --git a/cmake/FindROOT.cmake b/cmake/FindROOT.cmake index 431a1571e..9ed799ebe 100644 --- a/cmake/FindROOT.cmake +++ b/cmake/FindROOT.cmake @@ -104,99 +104,4 @@ if(NOT BDM_OUT_OF_SOURCE) set(LAUNCHER ${CMAKE_BINARY_DIR}/launcher.sh) endif() -#---------------------------------------------------------------------------- -# function ROOT_GENERATE_DICTIONARY( dictionary -# header1 header2 ... -# LINKDEF linkdef1 ... -# OPTIONS opt1...) -function(ROOT_GENERATE_DICTIONARY dictionary) - CMAKE_PARSE_ARGUMENTS(ARG "" "" "LINKDEF;OPTIONS" "" ${ARGN}) - #---Get the list of include directories------------------ - get_directory_property(incdirs INCLUDE_DIRECTORIES) - set(includedirs) - foreach( d ${incdirs}) - set(includedirs ${includedirs} -I${d}) - endforeach() - #---Get the list of header files------------------------- - set(headerfiles) - foreach(fp ${ARG_UNPARSED_ARGUMENTS}) - if(${fp} MATCHES "[*?]") # Is this header a globbing expression? - file(GLOB files ${fp}) - foreach(f ${files}) - if(NOT f MATCHES LinkDef) # skip LinkDefs from globbing result - set(headerfiles ${headerfiles} ${f}) - endif() - endforeach() - else() - find_file(headerFile ${fp} HINTS ${incdirs}) - set(headerfiles ${headerfiles} ${headerFile}) - unset(headerFile CACHE) - endif() - endforeach() - #---Get LinkDef.h file------------------------------------ - set(linkdefs) - foreach( f ${ARG_LINKDEF}) - find_file(linkFile ${f} HINTS ${incdirs}) - set(linkdefs ${linkdefs} ${linkFile}) - unset(linkFile CACHE) - endforeach() - #---call rootcling------------------------------------------ - add_custom_command(OUTPUT ${dictionary}.cxx - OUTPUT ${dictionary}_rdict.pcm - COMMAND ${LAUNCHER} ${ROOTCLING_EXECUTABLE} -f ${dictionary}.cxx - -c ${ARG_OPTIONS} ${includedirs} ${headerfiles} ${linkdefs} - DEPENDS ${headerfiles} ${linkdefs} VERBATIM) -endfunction() - -#---------------------------------------------------------------------------- -# function REFLEX_GENERATE_DICTIONARY(dictionary -# header1 header2 ... -# SELECTION selectionfile ... -# OPTIONS opt1...) -function(REFLEX_GENERATE_DICTIONARY dictionary) - CMAKE_PARSE_ARGUMENTS(ARG "" "" "SELECTION;OPTIONS" "" ${ARGN}) - #---Get the list of header files------------------------- - set(headerfiles) - foreach(fp ${ARG_UNPARSED_ARGUMENTS}) - file(GLOB files ${fp}) - if(files) - foreach(f ${files}) - set(headerfiles ${headerfiles} ${f}) - endforeach() - else() - set(headerfiles ${headerfiles} ${fp}) - endif() - endforeach() - #---Get Selection file------------------------------------ - if(IS_ABSOLUTE ${ARG_SELECTION}) - set(selectionfile ${ARG_SELECTION}) - else() - set(selectionfile ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_SELECTION}) - endif() - #---Get the list of include directories------------------ - get_directory_property(incdirs INCLUDE_DIRECTORIES) - set(includedirs) - foreach( d ${incdirs}) - set(includedirs ${includedirs} -I${d}) - endforeach() - #---Get preprocessor definitions-------------------------- - get_directory_property(defs COMPILE_DEFINITIONS) - foreach( d ${defs}) - set(definitions ${definitions} -D${d}) - endforeach() - #---Nanes and others--------------------------------------- - set(gensrcdict ${dictionary}.cc) - if(MSVC) - set(gccxmlopts "--gccxmlopt=\"--gccxml-compiler cl\"") - else() - #set(gccxmlopts "--gccxmlopt=\'--gccxml-cxxflags -m64 \'") - set(gccxmlopts) - endif() - #set(rootmapname ${dictionary}Dict.rootmap) - #set(rootmapopts --rootmap=${rootmapname} --rootmap-lib=${libprefix}${dictionary}Dict) - #---Actual command---------------------------------------- - add_custom_command(OUTPUT ${gensrcdict} ${rootmapname} ${dictionary}_rdict.pcm - COMMAND ${ROOTCLING_EXECUTABLE} --reflex -f ${gensrcdict} ${rootmapopts} ${headerfiles} ${selectionfile} --noIncludePaths --inlineInputHeader - ${ARG_OPTIONS} ${includedirs} ${definitions} - DEPENDS ${headerfiles} ${selectionfile}) -endfunction() +include(${CMAKE_SOURCE_DIR}/cmake/RootMacros.cmake) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index f6309066d..4d31e5d6c 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -273,6 +273,7 @@ function(install_inside_build) ${CMAKE_SOURCE_DIR}/cmake/SetCompilerFlags.cmake ${CMAKE_SOURCE_DIR}/cmake/FindLibroadrunner.cmake ${CMAKE_SOURCE_DIR}/cmake/FindROOT.cmake + ${CMAKE_SOURCE_DIR}/cmake/RootMacros.cmake ${CMAKE_SOURCE_DIR}/cmake/FindVTune.cmake ${CMAKE_SOURCE_DIR}/cmake/FindOpenCL.cmake ${CMAKE_SOURCE_DIR}/cmake/FindNuma.cmake From 6f401fe31c5c0cbb2058278dd197749dafd504ec Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 14 Aug 2024 11:51:41 +0200 Subject: [PATCH 16/48] Add ROOT_GENERATE_DICTIONARY invocation --- cmake/BioDynaMo.cmake | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cmake/BioDynaMo.cmake b/cmake/BioDynaMo.cmake index 7b8b60125..2422f0b81 100644 --- a/cmake/BioDynaMo.cmake +++ b/cmake/BioDynaMo.cmake @@ -111,6 +111,7 @@ function(build_shared_library TARGET) # generate dictionary using rootcling reflex set(DICT_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib${TARGET}_dict") set(BDM_DICT_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib${TARGET}_bdm_dict.cc") + set(module "${TARGET}_dict") # Since the location of the CMake files differ in the build and installation # directory, we check if BDM_CMAKE_DIR is already set (in build directory @@ -118,7 +119,7 @@ function(build_shared_library TARGET) if(NOT DEFINED BDM_CMAKE_DIR) set(BDM_CMAKE_DIR $ENV{BDMSYS}/share/cmake) endif() - REFLEX_GENERATE_DICTIONARY(${DICT_FILE} ${ARG_HEADERS} SELECTION ${BDM_CMAKE_DIR}/${ARG_SELECTION}) + ROOT_GENERATE_DICTIONARY(${DICT_FILE} ${ARG_HEADERS} MODULE ${module} LINKDEF ${BDM_CMAKE_DIR}/${ARG_SELECTION} REFLEX) if (BDM_OUT_OF_SOURCE) set(BDM_DICT_BIN_PATH "$ENV{BDMSYS}/bin") else() @@ -140,9 +141,9 @@ function(build_shared_library TARGET) endif() target_link_libraries(${TARGET} ${ARG_LIBRARIES}) if (DEFINED CMAKE_INSTALL_LIBDIR) - add_custom_command(TARGET ${TARGET} - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${DICT_FILE}_rdict.pcm ${CMAKE_INSTALL_LIBDIR}) + # add_custom_command(TARGET ${TARGET} + # POST_BUILD + # COMMAND ${CMAKE_COMMAND} -E copy ${DICT_FILE}_rdict.pcm ${CMAKE_INSTALL_LIBDIR}) endif() else() add_library(${TARGET} SHARED ${ARG_SOURCES}) From c9db0b919d2c0df0883aa23d38e6c58470d6b9a1 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 14 Aug 2024 11:55:56 +0200 Subject: [PATCH 17/48] Fix rootcling executable invocation --- cmake/RootMacros.cmake | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/cmake/RootMacros.cmake b/cmake/RootMacros.cmake index 83dd550c9..6d588ebfa 100644 --- a/cmake/RootMacros.cmake +++ b/cmake/RootMacros.cmake @@ -609,36 +609,6 @@ function(ROOT_GENERATE_DICTIONARY dictionary) set(newargs -reflex ${newargs}) endif() - #---what rootcling command to use-------------------------- - if(ARG_STAGE1) - if(MSVC AND CMAKE_ROOTTEST_DICT) - set(command ${CMAKE_COMMAND} -E ${CMAKE_BINARY_DIR}/bin/rootcling_stage1.exe) - else() - set(command ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" $) - endif() - set(ROOTCINTDEP rconfigure) - set(pcm_name) - else() - if(CMAKE_PROJECT_NAME STREQUAL ROOT) - if(MSVC AND CMAKE_ROOTTEST_DICT) - set(command ${CMAKE_COMMAND} -E env "ROOTIGNOREPREFIX=1" ${CMAKE_BINARY_DIR}/bin/rootcling.exe) - else() - set(command ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" - "ROOTIGNOREPREFIX=1" $ -rootbuild) - # Modules need RConfigure.h copied into include/. - set(ROOTCINTDEP rootcling rconfigure) - endif() - elseif(TARGET ROOT::rootcling) - if(APPLE) - set(command ${CMAKE_COMMAND} -E env "DYLD_LIBRARY_PATH=${ROOT_LIBRARY_DIR}:$ENV{DYLD_LIBRARY_PATH}" $) - else() - set(command ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${ROOT_LIBRARY_DIR}:$ENV{LD_LIBRARY_PATH}" $) - endif() - else() - set(command ${CMAKE_COMMAND} -E env rootcling) - endif() - endif() - #---build the path exclusion switches---------------------- set(excludepathsargs "") foreach(excludepath ${excludepaths}) @@ -685,7 +655,7 @@ function(ROOT_GENERATE_DICTIONARY dictionary) #---call rootcint------------------------------------------ add_custom_command(OUTPUT ${dictionary}.cc ${pcm_name} ${rootmap_name} ${cpp_module_file} - COMMAND ${command} -v2 -f ${dictionary}.cc ${newargs} ${excludepathsargs} ${rootmapargs} + COMMAND ${ROOTCLING_EXECUTABLE} -v2 -f ${dictionary}.cc ${newargs} ${excludepathsargs} ${rootmapargs} ${ARG_OPTIONS} ${definitions} "$<$:-D$>" ${compIncPaths} From 77cd6dc7317a049057139dc6142256288f4e5d7f Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 14 Aug 2024 12:02:36 +0200 Subject: [PATCH 18/48] Add launcher to rootcling invocation --- cmake/RootMacros.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/RootMacros.cmake b/cmake/RootMacros.cmake index 6d588ebfa..4183083ab 100644 --- a/cmake/RootMacros.cmake +++ b/cmake/RootMacros.cmake @@ -655,7 +655,7 @@ function(ROOT_GENERATE_DICTIONARY dictionary) #---call rootcint------------------------------------------ add_custom_command(OUTPUT ${dictionary}.cc ${pcm_name} ${rootmap_name} ${cpp_module_file} - COMMAND ${ROOTCLING_EXECUTABLE} -v2 -f ${dictionary}.cc ${newargs} ${excludepathsargs} ${rootmapargs} + COMMAND ${LAUNCHER} ${ROOTCLING_EXECUTABLE} -v2 -f ${dictionary}.cc ${newargs} ${excludepathsargs} ${rootmapargs} ${ARG_OPTIONS} ${definitions} "$<$:-D$>" ${compIncPaths} From e6844413d83dcf86c379134119c22fd48e7e53a9 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 14 Aug 2024 12:19:07 +0200 Subject: [PATCH 19/48] Add --noIncludePaths and --inlineInputHeader args --- cmake/BioDynaMo.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/BioDynaMo.cmake b/cmake/BioDynaMo.cmake index 2422f0b81..20812d943 100644 --- a/cmake/BioDynaMo.cmake +++ b/cmake/BioDynaMo.cmake @@ -119,7 +119,7 @@ function(build_shared_library TARGET) if(NOT DEFINED BDM_CMAKE_DIR) set(BDM_CMAKE_DIR $ENV{BDMSYS}/share/cmake) endif() - ROOT_GENERATE_DICTIONARY(${DICT_FILE} ${ARG_HEADERS} MODULE ${module} LINKDEF ${BDM_CMAKE_DIR}/${ARG_SELECTION} REFLEX) + ROOT_GENERATE_DICTIONARY(${DICT_FILE} ${ARG_HEADERS} MODULE ${module} LINKDEF ${BDM_CMAKE_DIR}/${ARG_SELECTION} REFLEX OPTIONS --noIncludePaths --inlineInputHeader) if (BDM_OUT_OF_SOURCE) set(BDM_DICT_BIN_PATH "$ENV{BDMSYS}/bin") else() From 3791701177efdb739987f1861cdfa01a04211434 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 14 Aug 2024 13:39:56 +0200 Subject: [PATCH 20/48] Include RootMacros.cmake in CMakeLists --- CMakeLists.txt | 1 + cmake/FindROOT.cmake | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dc40e73d1..7e5e80f17 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -504,6 +504,7 @@ file(COPY ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/launcher.sh GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) # -------------------- includes ----------------------------------------------- +include(RootMacros) include(BioDynaMo) include(ExternalProject) include(Documentation) diff --git a/cmake/FindROOT.cmake b/cmake/FindROOT.cmake index 42d2d8487..48792b29b 100644 --- a/cmake/FindROOT.cmake +++ b/cmake/FindROOT.cmake @@ -104,4 +104,3 @@ if(NOT BDM_OUT_OF_SOURCE) set(LAUNCHER ${CMAKE_BINARY_DIR}/launcher.sh) endif() -include(${CMAKE_SOURCE_DIR}/cmake/RootMacros.cmake) \ No newline at end of file From 6a2743a392ae774ca060e2c5e1ddde08c51922f6 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 14 Aug 2024 14:10:26 +0200 Subject: [PATCH 21/48] Testing with a different include path --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e5e80f17..4973ece3a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -504,7 +504,7 @@ file(COPY ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/launcher.sh GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) # -------------------- includes ----------------------------------------------- -include(RootMacros) +include(${CMAKE_INSTALL_CMAKEDIR}/RootMacros.cmake) include(BioDynaMo) include(ExternalProject) include(Documentation) From 55e2592324f79988b8689e96c773b73bbdb25f48 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 14 Aug 2024 14:17:22 +0200 Subject: [PATCH 22/48] Fix RootMacros include path --- CMakeLists.txt | 2 +- cmake/UseBioDynaMo.cmake.in | 1 + cmake/utils.cmake | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4973ece3a..7e5e80f17 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -504,7 +504,7 @@ file(COPY ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/launcher.sh GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) # -------------------- includes ----------------------------------------------- -include(${CMAKE_INSTALL_CMAKEDIR}/RootMacros.cmake) +include(RootMacros) include(BioDynaMo) include(ExternalProject) include(Documentation) diff --git a/cmake/UseBioDynaMo.cmake.in b/cmake/UseBioDynaMo.cmake.in index e0c00aa34..469607928 100644 --- a/cmake/UseBioDynaMo.cmake.in +++ b/cmake/UseBioDynaMo.cmake.in @@ -332,6 +332,7 @@ endfunction(bdm_add_test) # -------------------- includes ----------------------------------------------- set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${BDMSYS}/share/cmake") +include("${BDMSYS}/share/cmake/RootMacros.cmake") include("${BDMSYS}/share/cmake/BioDynaMo.cmake") include(${ROOT_USE_FILE}) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 4d31e5d6c..0c797b802 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -268,12 +268,12 @@ function(install_inside_build) # Copy some cmake files add_copy_files(copy_files_bdm DESTINATION ${CMAKE_INSTALL_CMAKEDATADIR} + ${CMAKE_SOURCE_DIR}/cmake/RootMacros.cmake ${CMAKE_SOURCE_DIR}/cmake/BioDynaMoConfig.cmake ${CMAKE_SOURCE_DIR}/cmake/BioDynaMo.cmake ${CMAKE_SOURCE_DIR}/cmake/SetCompilerFlags.cmake ${CMAKE_SOURCE_DIR}/cmake/FindLibroadrunner.cmake ${CMAKE_SOURCE_DIR}/cmake/FindROOT.cmake - ${CMAKE_SOURCE_DIR}/cmake/RootMacros.cmake ${CMAKE_SOURCE_DIR}/cmake/FindVTune.cmake ${CMAKE_SOURCE_DIR}/cmake/FindOpenCL.cmake ${CMAKE_SOURCE_DIR}/cmake/FindNuma.cmake From 5de61fe72c933eb61c30f2a99982afe74dfbac7a Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Mon, 19 Aug 2024 19:27:47 +0200 Subject: [PATCH 23/48] Change full path to relative path on ROOT_GENERATE_DICTIONARY --- cmake/BioDynaMo.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/BioDynaMo.cmake b/cmake/BioDynaMo.cmake index 20812d943..741145346 100644 --- a/cmake/BioDynaMo.cmake +++ b/cmake/BioDynaMo.cmake @@ -112,6 +112,7 @@ function(build_shared_library TARGET) set(DICT_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib${TARGET}_dict") set(BDM_DICT_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib${TARGET}_bdm_dict.cc") set(module "${TARGET}_dict") + string(REPLACE "${CMAKE_SOURCE_DIR}/src/" "" ROOT_HEADERS "${ARG_HEADERS}") # Since the location of the CMake files differ in the build and installation # directory, we check if BDM_CMAKE_DIR is already set (in build directory @@ -119,7 +120,7 @@ function(build_shared_library TARGET) if(NOT DEFINED BDM_CMAKE_DIR) set(BDM_CMAKE_DIR $ENV{BDMSYS}/share/cmake) endif() - ROOT_GENERATE_DICTIONARY(${DICT_FILE} ${ARG_HEADERS} MODULE ${module} LINKDEF ${BDM_CMAKE_DIR}/${ARG_SELECTION} REFLEX OPTIONS --noIncludePaths --inlineInputHeader) + ROOT_GENERATE_DICTIONARY(${DICT_FILE} ${ROOT_HEADERS} MODULE ${module} LINKDEF ${BDM_CMAKE_DIR}/${ARG_SELECTION} REFLEX OPTIONS -I src --noIncludePaths --inlineInputHeader) if (BDM_OUT_OF_SOURCE) set(BDM_DICT_BIN_PATH "$ENV{BDMSYS}/bin") else() From 73b7df5174f858da62bce8bb1e70a29a1c7bfb33 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Fri, 23 Aug 2024 12:22:07 +0200 Subject: [PATCH 24/48] Add deleted code --- cmake/RootMacros.cmake | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/cmake/RootMacros.cmake b/cmake/RootMacros.cmake index 4183083ab..538a1f1ec 100644 --- a/cmake/RootMacros.cmake +++ b/cmake/RootMacros.cmake @@ -604,6 +604,36 @@ function(ROOT_GENERATE_DICTIONARY dictionary) if(cpp_module_file) set(newargs -cxxmodule ${newargs}) endif() + + #---what rootcling command to use-------------------------- + if(ARG_STAGE1) + if(MSVC AND CMAKE_ROOTTEST_DICT) + set(command ${CMAKE_COMMAND} -E ${CMAKE_BINARY_DIR}/bin/rootcling_stage1.exe) + else() + set(command ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" $) + endif() + set(ROOTCINTDEP rconfigure) + set(pcm_name) + else() + if(CMAKE_PROJECT_NAME STREQUAL ROOT) + if(MSVC AND CMAKE_ROOTTEST_DICT) + set(command ${CMAKE_COMMAND} -E env "ROOTIGNOREPREFIX=1" ${CMAKE_BINARY_DIR}/bin/rootcling.exe) + else() + set(command ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" + "ROOTIGNOREPREFIX=1" $ -rootbuild) + # Modules need RConfigure.h copied into include/. + set(ROOTCINTDEP rootcling rconfigure) + endif() + elseif(TARGET ROOT::rootcling) + if(APPLE) + set(command ${CMAKE_COMMAND} -E env "DYLD_LIBRARY_PATH=${ROOT_LIBRARY_DIR}:$ENV{DYLD_LIBRARY_PATH}" $) + else() + set(command ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${ROOT_LIBRARY_DIR}:$ENV{LD_LIBRARY_PATH}" $) + endif() + else() + set(command ${CMAKE_COMMAND} -E env rootcling) + endif() + endif() if(ARG_REFLEX) set(newargs -reflex ${newargs}) @@ -655,7 +685,7 @@ function(ROOT_GENERATE_DICTIONARY dictionary) #---call rootcint------------------------------------------ add_custom_command(OUTPUT ${dictionary}.cc ${pcm_name} ${rootmap_name} ${cpp_module_file} - COMMAND ${LAUNCHER} ${ROOTCLING_EXECUTABLE} -v2 -f ${dictionary}.cc ${newargs} ${excludepathsargs} ${rootmapargs} + COMMAND ${LAUNCHER} ${command} -v2 -f ${dictionary}.cc ${newargs} ${excludepathsargs} ${rootmapargs} ${ARG_OPTIONS} ${definitions} "$<$:-D$>" ${compIncPaths} From 1b0dee00ba73d1d166b3d895398ee712649430ac Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Tue, 27 Aug 2024 03:40:45 +0200 Subject: [PATCH 25/48] Changed path of module.modulemap --- cmake/RootMacros.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/RootMacros.cmake b/cmake/RootMacros.cmake index 538a1f1ec..43e13edb8 100644 --- a/cmake/RootMacros.cmake +++ b/cmake/RootMacros.cmake @@ -844,7 +844,7 @@ function (ROOT_CXXMODULES_APPEND_TO_MODULEMAP library library_headers) # exposed via the main modulemap. This is exposed by setting the # ROOT_CXXMODULES_WRITE_TO_CURRENT_DIR. if (NOT "${CMAKE_PROJECT_NAME}" STREQUAL ROOT OR ROOT_CXXMODULES_WRITE_TO_CURRENT_DIR) - set(modulemap_output_file "${CMAKE_CURRENT_BINARY_DIR}/module.modulemap") + set(modulemap_output_file "${CMAKE_SOURCE_DIR}/src/module.modulemap") # It's possible that multiple modulemaps are needed in the current # directory and we need to merge them. As we don't want to have multiple From e5fc01ab2e8f990583f504f540b3d0dffb453a9c Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Tue, 27 Aug 2024 04:15:56 +0200 Subject: [PATCH 26/48] Add runtime_cxxmodules option --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e5e80f17..4397189dd 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,6 +138,7 @@ option(website "Enable website generation (make website<-live>)." OFF) option(valgrind "Enable valgrind tests and make build compatible with valgrind tool." ON) option(rpath "Link libraries with built-in RPATH (run-time search path)." OFF) option(real_t "Define data type for real numbers. Currently supported: float, double" double) +option(runtime_cxxmodules "Enable C++ Modules support." ON) if(APPLE) # ParaView on Apple devices From f896784ea9c0e6252dfa236eb029b13375bf3a12 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Tue, 27 Aug 2024 04:45:43 +0200 Subject: [PATCH 27/48] Remove _dict suffix --- cmake/BioDynaMo.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/BioDynaMo.cmake b/cmake/BioDynaMo.cmake index 741145346..87d0714e9 100644 --- a/cmake/BioDynaMo.cmake +++ b/cmake/BioDynaMo.cmake @@ -111,7 +111,7 @@ function(build_shared_library TARGET) # generate dictionary using rootcling reflex set(DICT_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib${TARGET}_dict") set(BDM_DICT_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib${TARGET}_bdm_dict.cc") - set(module "${TARGET}_dict") + set(module "${TARGET}") string(REPLACE "${CMAKE_SOURCE_DIR}/src/" "" ROOT_HEADERS "${ARG_HEADERS}") # Since the location of the CMake files differ in the build and installation From 56a3a8e5d826b5dedbe54a348717bdaa1fd1939d Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Fri, 30 Aug 2024 03:52:40 +0200 Subject: [PATCH 28/48] Fix self-contained headers problem --- src/core/operation/mechanical_forces_op.h | 1 + src/neuroscience/new_agent_event/neurite_branching_event.h | 2 ++ src/neuroscience/new_agent_event/new_neurite_extension_event.h | 1 + src/neuroscience/new_agent_event/side_neurite_extension_event.h | 2 ++ src/neuroscience/new_agent_event/split_neurite_element_event.h | 1 + test/unit/core/operation/dividing_cell_op_test.h | 1 + test/unit/core/operation/mechanical_forces_op_test.h | 1 + 7 files changed, 9 insertions(+) diff --git a/src/core/operation/mechanical_forces_op.h b/src/core/operation/mechanical_forces_op.h index 5136d5958..67a42da39 100644 --- a/src/core/operation/mechanical_forces_op.h +++ b/src/core/operation/mechanical_forces_op.h @@ -31,6 +31,7 @@ #include "core/simulation.h" #include "core/util/math.h" #include "core/util/thread_info.h" +#include "core/operation/operation_registry.h" namespace bdm { diff --git a/src/neuroscience/new_agent_event/neurite_branching_event.h b/src/neuroscience/new_agent_event/neurite_branching_event.h index 113f5525b..904cc5592 100644 --- a/src/neuroscience/new_agent_event/neurite_branching_event.h +++ b/src/neuroscience/new_agent_event/neurite_branching_event.h @@ -17,6 +17,8 @@ #include #include "core/agent/new_agent_event.h" +#include "core/real_t.h" +#include "core/container/math_array.h" namespace bdm { namespace neuroscience { diff --git a/src/neuroscience/new_agent_event/new_neurite_extension_event.h b/src/neuroscience/new_agent_event/new_neurite_extension_event.h index b8aa7d10f..fb9cef3cd 100644 --- a/src/neuroscience/new_agent_event/new_neurite_extension_event.h +++ b/src/neuroscience/new_agent_event/new_neurite_extension_event.h @@ -16,6 +16,7 @@ #define NEUROSCIENCE_NEW_AGENT_EVENT_NEW_NEURITE_EXTENSION_EVENT_H_ #include "core/agent/new_agent_event.h" +#include "core/real_t.h" namespace bdm { namespace neuroscience { diff --git a/src/neuroscience/new_agent_event/side_neurite_extension_event.h b/src/neuroscience/new_agent_event/side_neurite_extension_event.h index b72998ba4..1f94055df 100644 --- a/src/neuroscience/new_agent_event/side_neurite_extension_event.h +++ b/src/neuroscience/new_agent_event/side_neurite_extension_event.h @@ -16,6 +16,8 @@ #define NEUROSCIENCE_NEW_AGENT_EVENT_SIDE_NEURITE_EXTENSION_EVENT_H_ #include "core/agent/new_agent_event.h" +#include "core/real_t.h" +#include "core/container/math_array.h" namespace bdm { namespace neuroscience { diff --git a/src/neuroscience/new_agent_event/split_neurite_element_event.h b/src/neuroscience/new_agent_event/split_neurite_element_event.h index fced3bef9..264be460e 100644 --- a/src/neuroscience/new_agent_event/split_neurite_element_event.h +++ b/src/neuroscience/new_agent_event/split_neurite_element_event.h @@ -16,6 +16,7 @@ #define NEUROSCIENCE_NEW_AGENT_EVENT_SPLIT_NEURITE_ELEMENT_EVENT_H_ #include "core/agent/new_agent_event.h" +#include "core/real_t.h" namespace bdm { namespace neuroscience { diff --git a/test/unit/core/operation/dividing_cell_op_test.h b/test/unit/core/operation/dividing_cell_op_test.h index e13e95e48..38f45782b 100644 --- a/test/unit/core/operation/dividing_cell_op_test.h +++ b/test/unit/core/operation/dividing_cell_op_test.h @@ -23,6 +23,7 @@ #include "core/operation/dividing_cell_op.h" #include "core/resource_manager.h" #include "unit/test_util/test_util.h" +#include "core/operation/operation_registry.h" namespace bdm { namespace dividing_cell_op_test_internal { diff --git a/test/unit/core/operation/mechanical_forces_op_test.h b/test/unit/core/operation/mechanical_forces_op_test.h index 55b4efa14..95fe54b43 100644 --- a/test/unit/core/operation/mechanical_forces_op_test.h +++ b/test/unit/core/operation/mechanical_forces_op_test.h @@ -18,6 +18,7 @@ #include "core/agent/cell.h" #include "core/operation/mechanical_forces_op.h" #include "unit/test_util/test_util.h" +#include "core/operation/operation_registry.h" namespace bdm { namespace mechanical_forces_op_test_internal { From 8b35112398e60c7fd35a51794d7242d485b39598 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Mon, 2 Sep 2024 02:56:52 +0200 Subject: [PATCH 29/48] It compiles! --- cmake/selection-libbiodynamo.xml | 1 - cmake/selection.xml | 1 - src/core/environment/uniform_grid_environment.h | 1 - 3 files changed, 3 deletions(-) diff --git a/cmake/selection-libbiodynamo.xml b/cmake/selection-libbiodynamo.xml index 01b08e2f1..3c8aba4a7 100644 --- a/cmake/selection-libbiodynamo.xml +++ b/cmake/selection-libbiodynamo.xml @@ -149,7 +149,6 @@ - diff --git a/cmake/selection.xml b/cmake/selection.xml index e2ccaae4f..c7ce6cf5b 100644 --- a/cmake/selection.xml +++ b/cmake/selection.xml @@ -184,7 +184,6 @@ - diff --git a/src/core/environment/uniform_grid_environment.h b/src/core/environment/uniform_grid_environment.h index 1eddcbb1d..e81109494 100644 --- a/src/core/environment/uniform_grid_environment.h +++ b/src/core/environment/uniform_grid_environment.h @@ -625,7 +625,6 @@ class UniformGridEnvironment : public Environment { uint64_t start, uint64_t end, Functor*>& f) const override; - private: UniformGridEnvironment* grid_; MortonOrder mo_; ParallelResizeVector sorted_boxes_; From 3f71ebf2cb17501deb7c0dfbc7d1d2fb0f36558f Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 4 Sep 2024 17:22:12 +0200 Subject: [PATCH 30/48] Add modulemapfile option --- cmake/BioDynaMo.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/BioDynaMo.cmake b/cmake/BioDynaMo.cmake index 87d0714e9..53c4493ef 100644 --- a/cmake/BioDynaMo.cmake +++ b/cmake/BioDynaMo.cmake @@ -120,7 +120,7 @@ function(build_shared_library TARGET) if(NOT DEFINED BDM_CMAKE_DIR) set(BDM_CMAKE_DIR $ENV{BDMSYS}/share/cmake) endif() - ROOT_GENERATE_DICTIONARY(${DICT_FILE} ${ROOT_HEADERS} MODULE ${module} LINKDEF ${BDM_CMAKE_DIR}/${ARG_SELECTION} REFLEX OPTIONS -I src --noIncludePaths --inlineInputHeader) + ROOT_GENERATE_DICTIONARY(${DICT_FILE} ${ROOT_HEADERS} MODULE ${module} LINKDEF ${BDM_CMAKE_DIR}/${ARG_SELECTION} REFLEX OPTIONS -I src --noIncludePaths --inlineInputHeader --moduleMapFile=${CMAKE_SOURCE_DIR}/src/module.modulemap) if (BDM_OUT_OF_SOURCE) set(BDM_DICT_BIN_PATH "$ENV{BDMSYS}/bin") else() From f6d897cb2a4d1dc5ee6015b4010ac9d60830ee11 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Mon, 16 Sep 2024 12:00:08 +0200 Subject: [PATCH 31/48] Now it compiles! --- cmake/BioDynaMo.cmake | 13 +++++- cmake/RootMacros.cmake | 2 +- cmake/selection-libbiodynamo.xml | 1 + cmake/selection.xml | 44 +++++++++++++++++-- .../src/validation_criterion.h | 5 +++ .../environment/uniform_grid_environment.h | 1 + .../gpu/mechanical_forces_op_cuda_kernel.h | 1 + src/core/operation/load_balancing_op.h | 1 + src/core/util/partition.h | 1 + test/unit/core/count_neighbor_functor.h | 2 + 10 files changed, 65 insertions(+), 6 deletions(-) diff --git a/cmake/BioDynaMo.cmake b/cmake/BioDynaMo.cmake index 53c4493ef..407b1a04f 100644 --- a/cmake/BioDynaMo.cmake +++ b/cmake/BioDynaMo.cmake @@ -112,7 +112,16 @@ function(build_shared_library TARGET) set(DICT_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib${TARGET}_dict") set(BDM_DICT_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib${TARGET}_bdm_dict.cc") set(module "${TARGET}") - string(REPLACE "${CMAKE_SOURCE_DIR}/src/" "" ROOT_HEADERS "${ARG_HEADERS}") + + if (runtime_cxxmodules) + set(MODULEMAP "--moduleMapFile=${CMAKE_SOURCE_DIR}/src/module.modulemap") + endif() + + if (NOT ${TARGET} STREQUAL "biodynamo") + #set(DEPENDENCY_OPTION "-m ${CMAKE_CURRENT_BINARY_DIR}/lib/biodynamo.pcm") + #set(NO_MODULE "NO_CXXMODULE") + #set(MODULEMAP) + endif() # Since the location of the CMake files differ in the build and installation # directory, we check if BDM_CMAKE_DIR is already set (in build directory @@ -120,7 +129,7 @@ function(build_shared_library TARGET) if(NOT DEFINED BDM_CMAKE_DIR) set(BDM_CMAKE_DIR $ENV{BDMSYS}/share/cmake) endif() - ROOT_GENERATE_DICTIONARY(${DICT_FILE} ${ROOT_HEADERS} MODULE ${module} LINKDEF ${BDM_CMAKE_DIR}/${ARG_SELECTION} REFLEX OPTIONS -I src --noIncludePaths --inlineInputHeader --moduleMapFile=${CMAKE_SOURCE_DIR}/src/module.modulemap) + ROOT_GENERATE_DICTIONARY(${DICT_FILE} ${ARG_HEADERS} MODULE ${module} LINKDEF ${BDM_CMAKE_DIR}/${ARG_SELECTION} REFLEX ${NO_MODULE} OPTIONS ${DEPENDENCY_OPTION} -I src --inlineInputHeader --noIncludePaths ${MODULEMAP}) if (BDM_OUT_OF_SOURCE) set(BDM_DICT_BIN_PATH "$ENV{BDMSYS}/bin") else() diff --git a/cmake/RootMacros.cmake b/cmake/RootMacros.cmake index 43e13edb8..8d223ed72 100644 --- a/cmake/RootMacros.cmake +++ b/cmake/RootMacros.cmake @@ -743,7 +743,7 @@ function(ROOT_GENERATE_DICTIONARY dictionary) # Install the C++ module if we generated one. if (cpp_module_file) install(FILES ${cpp_module_file} - DESTINATION ${shared_lib_install_dir} COMPONENT libraries) + DESTINATION ${CMAKE_BINARY_DIR}/lib COMPONENT libraries) endif() if(ARG_STAGE1) diff --git a/cmake/selection-libbiodynamo.xml b/cmake/selection-libbiodynamo.xml index 3c8aba4a7..01b08e2f1 100644 --- a/cmake/selection-libbiodynamo.xml +++ b/cmake/selection-libbiodynamo.xml @@ -149,6 +149,7 @@ + diff --git a/cmake/selection.xml b/cmake/selection.xml index c7ce6cf5b..82f08f47c 100644 --- a/cmake/selection.xml +++ b/cmake/selection.xml @@ -6,14 +6,51 @@ + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -86,7 +123,7 @@ - + @@ -184,6 +221,7 @@ + diff --git a/demo/soma_clustering/src/validation_criterion.h b/demo/soma_clustering/src/validation_criterion.h index 6684dd452..d9334a0a3 100644 --- a/demo/soma_clustering/src/validation_criterion.h +++ b/demo/soma_clustering/src/validation_criterion.h @@ -18,6 +18,11 @@ #include #include "biodynamo.h" #include "my_cell.h" +#include "core/real_t.h" +#include "core/agent/agent.h" +#include "core/simulation.h" +#include "core/container/math_array.h" +#include "core/resource_manager.h" namespace bdm { namespace soma_clustering { diff --git a/src/core/environment/uniform_grid_environment.h b/src/core/environment/uniform_grid_environment.h index e81109494..1eddcbb1d 100644 --- a/src/core/environment/uniform_grid_environment.h +++ b/src/core/environment/uniform_grid_environment.h @@ -625,6 +625,7 @@ class UniformGridEnvironment : public Environment { uint64_t start, uint64_t end, Functor*>& f) const override; + private: UniformGridEnvironment* grid_; MortonOrder mo_; ParallelResizeVector sorted_boxes_; diff --git a/src/core/gpu/mechanical_forces_op_cuda_kernel.h b/src/core/gpu/mechanical_forces_op_cuda_kernel.h index 86bcfb7a5..ea143740d 100644 --- a/src/core/gpu/mechanical_forces_op_cuda_kernel.h +++ b/src/core/gpu/mechanical_forces_op_cuda_kernel.h @@ -17,6 +17,7 @@ #include #include +#include "core/real_t.h" #include "stdio.h" #ifdef USE_CUDA diff --git a/src/core/operation/load_balancing_op.h b/src/core/operation/load_balancing_op.h index 61cf79254..70f364c0a 100644 --- a/src/core/operation/load_balancing_op.h +++ b/src/core/operation/load_balancing_op.h @@ -16,6 +16,7 @@ #define CORE_OPERATION_LOAD_BALANCING_OP_H_ #include "core/operation/operation.h" +#include "core/operation/operation_registry.h" #include "core/resource_manager.h" #include "core/simulation.h" diff --git a/src/core/util/partition.h b/src/core/util/partition.h index 9daadd5a5..249333f04 100644 --- a/src/core/util/partition.h +++ b/src/core/util/partition.h @@ -15,6 +15,7 @@ #ifndef CORE_UTIL_PARTITION_H_ #define CORE_UTIL_PARTITION_H_ +#include #include namespace bdm { diff --git a/test/unit/core/count_neighbor_functor.h b/test/unit/core/count_neighbor_functor.h index 297196762..73221ee8b 100644 --- a/test/unit/core/count_neighbor_functor.h +++ b/test/unit/core/count_neighbor_functor.h @@ -16,7 +16,9 @@ #define COUNT_NEIGHBOR_FUNCTOR_H_ #include "core/agent/agent.h" +#include "core/agent/cell.h" #include "core/functor.h" +#include "core/resource_manager.h" #include "core/simulation.h" #include "gtest/gtest.h" From a399cb5dc3b6434e607e54c486285363b6d40750 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Mon, 16 Sep 2024 12:09:02 +0200 Subject: [PATCH 32/48] Fix submission --- demo/soma_clustering/src/validation_criterion.h | 6 +++--- src/core/operation/mechanical_forces_op.h | 1 - src/neuroscience/new_agent_event/neurite_branching_event.h | 2 +- .../new_agent_event/side_neurite_extension_event.h | 2 +- test/unit/core/operation/dividing_cell_op_test.h | 2 +- test/unit/core/operation/mechanical_forces_op_test.h | 2 +- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/demo/soma_clustering/src/validation_criterion.h b/demo/soma_clustering/src/validation_criterion.h index d9334a0a3..465b64d60 100644 --- a/demo/soma_clustering/src/validation_criterion.h +++ b/demo/soma_clustering/src/validation_criterion.h @@ -17,12 +17,12 @@ #include #include "biodynamo.h" -#include "my_cell.h" -#include "core/real_t.h" #include "core/agent/agent.h" -#include "core/simulation.h" #include "core/container/math_array.h" +#include "core/real_t.h" #include "core/resource_manager.h" +#include "core/simulation.h" +#include "my_cell.h" namespace bdm { namespace soma_clustering { diff --git a/src/core/operation/mechanical_forces_op.h b/src/core/operation/mechanical_forces_op.h index 67a42da39..5136d5958 100644 --- a/src/core/operation/mechanical_forces_op.h +++ b/src/core/operation/mechanical_forces_op.h @@ -31,7 +31,6 @@ #include "core/simulation.h" #include "core/util/math.h" #include "core/util/thread_info.h" -#include "core/operation/operation_registry.h" namespace bdm { diff --git a/src/neuroscience/new_agent_event/neurite_branching_event.h b/src/neuroscience/new_agent_event/neurite_branching_event.h index 904cc5592..85dd1e26e 100644 --- a/src/neuroscience/new_agent_event/neurite_branching_event.h +++ b/src/neuroscience/new_agent_event/neurite_branching_event.h @@ -17,8 +17,8 @@ #include #include "core/agent/new_agent_event.h" -#include "core/real_t.h" #include "core/container/math_array.h" +#include "core/real_t.h" namespace bdm { namespace neuroscience { diff --git a/src/neuroscience/new_agent_event/side_neurite_extension_event.h b/src/neuroscience/new_agent_event/side_neurite_extension_event.h index 1f94055df..d4c6f802b 100644 --- a/src/neuroscience/new_agent_event/side_neurite_extension_event.h +++ b/src/neuroscience/new_agent_event/side_neurite_extension_event.h @@ -16,8 +16,8 @@ #define NEUROSCIENCE_NEW_AGENT_EVENT_SIDE_NEURITE_EXTENSION_EVENT_H_ #include "core/agent/new_agent_event.h" -#include "core/real_t.h" #include "core/container/math_array.h" +#include "core/real_t.h" namespace bdm { namespace neuroscience { diff --git a/test/unit/core/operation/dividing_cell_op_test.h b/test/unit/core/operation/dividing_cell_op_test.h index 38f45782b..417ebcfd3 100644 --- a/test/unit/core/operation/dividing_cell_op_test.h +++ b/test/unit/core/operation/dividing_cell_op_test.h @@ -21,9 +21,9 @@ #include "core/agent/cell.h" #include "core/operation/dividing_cell_op.h" +#include "core/operation/operation_registry.h" #include "core/resource_manager.h" #include "unit/test_util/test_util.h" -#include "core/operation/operation_registry.h" namespace bdm { namespace dividing_cell_op_test_internal { diff --git a/test/unit/core/operation/mechanical_forces_op_test.h b/test/unit/core/operation/mechanical_forces_op_test.h index 95fe54b43..45a60911c 100644 --- a/test/unit/core/operation/mechanical_forces_op_test.h +++ b/test/unit/core/operation/mechanical_forces_op_test.h @@ -17,8 +17,8 @@ #include "core/agent/cell.h" #include "core/operation/mechanical_forces_op.h" -#include "unit/test_util/test_util.h" #include "core/operation/operation_registry.h" +#include "unit/test_util/test_util.h" namespace bdm { namespace mechanical_forces_op_test_internal { From 43f415de09f82a8b42f3c8b45acff111b19233ef Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Tue, 17 Sep 2024 19:26:25 +0200 Subject: [PATCH 33/48] Modify modulemap path --- cmake/BioDynaMo.cmake | 8 ++++++-- cmake/RootMacros.cmake | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cmake/BioDynaMo.cmake b/cmake/BioDynaMo.cmake index 407b1a04f..b2d1f1bb7 100644 --- a/cmake/BioDynaMo.cmake +++ b/cmake/BioDynaMo.cmake @@ -112,9 +112,13 @@ function(build_shared_library TARGET) set(DICT_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib${TARGET}_dict") set(BDM_DICT_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib${TARGET}_bdm_dict.cc") set(module "${TARGET}") + set(ROOT_HEADERS) + string(REPLACE "${CMAKE_SOURCE_DIR}/src/" "" ROOT_HEADERS_TEMP "${ARG_HEADERS}") + string(REPLACE "${CMAKE_SOURCE_DIR}/test/" "" ROOT_HEADERS "${ROOT_HEADERS_TEMP}") + if (runtime_cxxmodules) - set(MODULEMAP "--moduleMapFile=${CMAKE_SOURCE_DIR}/src/module.modulemap") + set(CLING_MODULEMAP_FILES "$ENV{${CMAKE_BINARY_DIR}/include/module.modulemap}") endif() if (NOT ${TARGET} STREQUAL "biodynamo") @@ -129,7 +133,7 @@ function(build_shared_library TARGET) if(NOT DEFINED BDM_CMAKE_DIR) set(BDM_CMAKE_DIR $ENV{BDMSYS}/share/cmake) endif() - ROOT_GENERATE_DICTIONARY(${DICT_FILE} ${ARG_HEADERS} MODULE ${module} LINKDEF ${BDM_CMAKE_DIR}/${ARG_SELECTION} REFLEX ${NO_MODULE} OPTIONS ${DEPENDENCY_OPTION} -I src --inlineInputHeader --noIncludePaths ${MODULEMAP}) + ROOT_GENERATE_DICTIONARY(${DICT_FILE} ${ROOT_HEADERS} MODULE ${module} LINKDEF ${BDM_CMAKE_DIR}/${ARG_SELECTION} REFLEX ${NO_MODULE} OPTIONS ${DEPENDENCY_OPTION} -I src --inlineInputHeader --noIncludePaths ${MODULEMAP}) if (BDM_OUT_OF_SOURCE) set(BDM_DICT_BIN_PATH "$ENV{BDMSYS}/bin") else() diff --git a/cmake/RootMacros.cmake b/cmake/RootMacros.cmake index 8d223ed72..0dca9ddfc 100644 --- a/cmake/RootMacros.cmake +++ b/cmake/RootMacros.cmake @@ -844,7 +844,7 @@ function (ROOT_CXXMODULES_APPEND_TO_MODULEMAP library library_headers) # exposed via the main modulemap. This is exposed by setting the # ROOT_CXXMODULES_WRITE_TO_CURRENT_DIR. if (NOT "${CMAKE_PROJECT_NAME}" STREQUAL ROOT OR ROOT_CXXMODULES_WRITE_TO_CURRENT_DIR) - set(modulemap_output_file "${CMAKE_SOURCE_DIR}/src/module.modulemap") + set(modulemap_output_file "${CMAKE_BINARY_DIR}/include/module.modulemap") # It's possible that multiple modulemaps are needed in the current # directory and we need to merge them. As we don't want to have multiple From 189438da8ae9b6322a143074c0f4dc694839d73f Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Tue, 17 Sep 2024 19:37:35 +0200 Subject: [PATCH 34/48] Added modulemap env variable --- cmake/env/thisbdm.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/env/thisbdm.sh b/cmake/env/thisbdm.sh index 7f2db183c..3b5f11969 100755 --- a/cmake/env/thisbdm.sh +++ b/cmake/env/thisbdm.sh @@ -423,6 +423,7 @@ _source_thisbdm() fi export BDM_ROOT_DIR + export CLING_MODULEMAP_FILES=${BDMSYS}/include/module.modulemap # shellcheck disable=SC1090 . "${BDM_ROOT_DIR}"/bin/thisroot.sh || return 1 _bdm_define_command root || return 1 From 540bab0a6e2396f832cfc8207f3fdab08f86b26f Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Tue, 17 Sep 2024 20:01:42 +0200 Subject: [PATCH 35/48] Add -modulemapfile flag --- cmake/BioDynaMo.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/BioDynaMo.cmake b/cmake/BioDynaMo.cmake index b2d1f1bb7..47ceade8d 100644 --- a/cmake/BioDynaMo.cmake +++ b/cmake/BioDynaMo.cmake @@ -118,7 +118,7 @@ function(build_shared_library TARGET) if (runtime_cxxmodules) - set(CLING_MODULEMAP_FILES "$ENV{${CMAKE_BINARY_DIR}/include/module.modulemap}") + set(MODULEMAP "--moduleMapFile=${CMAKE_BINARY_DIR}/include/module.modulemap") endif() if (NOT ${TARGET} STREQUAL "biodynamo") From 51f8c0b86ecd034490070fd2ef9e6ef76cb539bf Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 18 Sep 2024 01:50:27 +0200 Subject: [PATCH 36/48] First copy the files in the include dir --- cmake/utils.cmake | 2 +- demo/soma_clustering/src/soma_clustering.h | 2 +- demo/soma_clustering/src/validation_criterion.h | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 0c797b802..086ab744f 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -401,7 +401,7 @@ function(install_inside_build) endif() add_custom_target(copy_files_bdm ALL DEPENDS ${artifact_files_builddir}) - add_dependencies(copy_files_bdm biodynamo) + add_dependencies(biodynamo copy_files_bdm) endfunction() # This function add a description to the packages which will be displayed diff --git a/demo/soma_clustering/src/soma_clustering.h b/demo/soma_clustering/src/soma_clustering.h index 0f10f652e..eaa4a41c4 100644 --- a/demo/soma_clustering/src/soma_clustering.h +++ b/demo/soma_clustering/src/soma_clustering.h @@ -93,7 +93,7 @@ inline int Simulate(int argc, const char** argv) { num_cells / 2, construct); // Run simulation for N timesteps - const uint64_t timesteps = 1000; + const uint64_t timesteps = 30000; if (timesteps < 6000) { Log::Warning("SomaClustering", "We recommend to run the simulation for roughly 6000 time " diff --git a/demo/soma_clustering/src/validation_criterion.h b/demo/soma_clustering/src/validation_criterion.h index 465b64d60..edc65423a 100644 --- a/demo/soma_clustering/src/validation_criterion.h +++ b/demo/soma_clustering/src/validation_criterion.h @@ -17,6 +17,9 @@ #include #include "biodynamo.h" +#include +#include +#include #include "core/agent/agent.h" #include "core/container/math_array.h" #include "core/real_t.h" From 5e6acc3db789532a7c02ff48db20fac31ed30efd Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Sat, 28 Sep 2024 12:03:13 +0200 Subject: [PATCH 37/48] Changed some variables --- cmake/BioDynaMo.cmake | 5 +++-- demo/soma_clustering/src/soma_clustering.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cmake/BioDynaMo.cmake b/cmake/BioDynaMo.cmake index 47ceade8d..6f91b0469 100644 --- a/cmake/BioDynaMo.cmake +++ b/cmake/BioDynaMo.cmake @@ -111,7 +111,6 @@ function(build_shared_library TARGET) # generate dictionary using rootcling reflex set(DICT_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib${TARGET}_dict") set(BDM_DICT_FILE "${CMAKE_CURRENT_BINARY_DIR}/lib${TARGET}_bdm_dict.cc") - set(module "${TARGET}") set(ROOT_HEADERS) string(REPLACE "${CMAKE_SOURCE_DIR}/src/" "" ROOT_HEADERS_TEMP "${ARG_HEADERS}") string(REPLACE "${CMAKE_SOURCE_DIR}/test/" "" ROOT_HEADERS "${ROOT_HEADERS_TEMP}") @@ -119,6 +118,8 @@ function(build_shared_library TARGET) if (runtime_cxxmodules) set(MODULEMAP "--moduleMapFile=${CMAKE_BINARY_DIR}/include/module.modulemap") + else() + set(NO_MODULE "NO_CXXMODULE") endif() if (NOT ${TARGET} STREQUAL "biodynamo") @@ -133,7 +134,7 @@ function(build_shared_library TARGET) if(NOT DEFINED BDM_CMAKE_DIR) set(BDM_CMAKE_DIR $ENV{BDMSYS}/share/cmake) endif() - ROOT_GENERATE_DICTIONARY(${DICT_FILE} ${ROOT_HEADERS} MODULE ${module} LINKDEF ${BDM_CMAKE_DIR}/${ARG_SELECTION} REFLEX ${NO_MODULE} OPTIONS ${DEPENDENCY_OPTION} -I src --inlineInputHeader --noIncludePaths ${MODULEMAP}) + ROOT_GENERATE_DICTIONARY(${DICT_FILE} ${ROOT_HEADERS} MODULE ${TARGET} LINKDEF ${BDM_CMAKE_DIR}/${ARG_SELECTION} REFLEX ${NO_MODULE} OPTIONS ${DEPENDENCY_OPTION} -I src --inlineInputHeader --noIncludePaths ${MODULEMAP}) if (BDM_OUT_OF_SOURCE) set(BDM_DICT_BIN_PATH "$ENV{BDMSYS}/bin") else() diff --git a/demo/soma_clustering/src/soma_clustering.h b/demo/soma_clustering/src/soma_clustering.h index eaa4a41c4..0f10f652e 100644 --- a/demo/soma_clustering/src/soma_clustering.h +++ b/demo/soma_clustering/src/soma_clustering.h @@ -93,7 +93,7 @@ inline int Simulate(int argc, const char** argv) { num_cells / 2, construct); // Run simulation for N timesteps - const uint64_t timesteps = 30000; + const uint64_t timesteps = 1000; if (timesteps < 6000) { Log::Warning("SomaClustering", "We recommend to run the simulation for roughly 6000 time " From e36e3f78e7d3e7105658bbf626599acd046decf9 Mon Sep 17 00:00:00 2001 From: Isaac Morales Santana <102816007+imorlxs@users.noreply.github.com> Date: Mon, 26 Aug 2024 11:02:05 +0200 Subject: [PATCH 38/48] Fix deprecated Cmake call `FetchContent_Populate` (#387) See deprecation warning documented in #386. --- cmake/utils.cmake | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 086ab744f..7cd63a6da 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -549,12 +549,9 @@ Unset the environment variable BDM_LOCAL_LFS to download the file.") DOWNLOAD_DIR ${DEST_PARENT} SOURCE_DIR ${DEST} ) - - FetchContent_GetProperties(${TAR_FILENAME}) - if (NOT ${TAR_FILENAME}_POPULATED) - FetchContent_Populate(${TAR_FILENAME}) - endif() - + + FetchContent_MakeAvailable(${TAR_FILENAME}) + # Remove subbuild files, we don't need them file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/_deps/) endif() From e67be8153d019730145f21edcaf7146a94ed6d66 Mon Sep 17 00:00:00 2001 From: Fons Rademakers Date: Wed, 18 Sep 2024 17:29:30 +0200 Subject: [PATCH 39/48] Add ROOT supporting new Xcode 16.0 on macOS 15.0 and 14.7. --- cmake/external/ROOT.cmake | 9 +++++++-- cmake/external/SHA256Digests.cmake | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/cmake/external/ROOT.cmake b/cmake/external/ROOT.cmake index f4cc74a65..53df07fc5 100644 --- a/cmake/external/ROOT.cmake +++ b/cmake/external/ROOT.cmake @@ -6,14 +6,19 @@ SET(ROOT_SOURCE_DIR "${CMAKE_THIRD_PARTY_DIR}/root") set(ROOT_TAR_FILE root_v6.30.02_cxx17_python3.9_${DETECTED_OS_VERS}.tar.gz) set(ROOT_SHA_KEY ${DETECTED_OS_VERS}-ROOT) if(APPLE) - if("${DETECTED_OS_VERS}" MATCHES "^osx-14" OR + if("${DETECTED_OS_VERS}" MATCHES "^osx-15" OR + "${DETECTED_OS_VERS}" MATCHES "^osx-14" OR "${DETECTED_OS_VERS}" MATCHES "^osx-13" OR "${DETECTED_OS_VERS}" MATCHES "^osx-12" OR "${DETECTED_OS_VERS}" MATCHES "^osx-11.6" OR "${DETECTED_OS_VERS}" MATCHES "^osx-11.7") execute_process(COMMAND bash "-c" "xcodebuild -version | sed -En 's/Xcode[[:space:]]+([0-9\.]*)/\\1/p'" OUTPUT_VARIABLE XCODE_VERS) message(STATUS "##### XCODE version: ${XCODE_VERS}") - if("${XCODE_VERS}" GREATER_EQUAL "15.4") + if("${XCODE_VERS}" GREATER_EQUAL "16.0") + message(STATUS "##### Using ROOT builds for XCODE 16.0") + set(ROOT_TAR_FILE root_v6.33.01_cxx17_python3.9_osx-xcode-16.0-${DETECTED_ARCH}.tar.gz) + set(ROOT_SHA_KEY osx-xcode-16.0-${DETECTED_ARCH}-ROOT) + elseif("${XCODE_VERS}" GREATER_EQUAL "15.4") message(STATUS "##### Using ROOT builds for XCODE 15.4") set(ROOT_TAR_FILE root_v6.30.06_cxx17_python3.9_osx-xcode-15.4-${DETECTED_ARCH}.tar.gz) set(ROOT_SHA_KEY osx-xcode-15.4-${DETECTED_ARCH}-ROOT) diff --git a/cmake/external/SHA256Digests.cmake b/cmake/external/SHA256Digests.cmake index 7d863ea96..2645e6a1b 100644 --- a/cmake/external/SHA256Digests.cmake +++ b/cmake/external/SHA256Digests.cmake @@ -64,6 +64,10 @@ SET(osx-14.5-i386-ParaView d2e89df30ab0e2729b28539de37753e09c061b4c434b0a68e8055 SET(osx-14.5-arm64-ParaView 5e89b785ac0c56bbca31e2ae101a8986953e90227fe42a1ef7adcc70a0ff6fc4) SET(osx-14.6-i386-ParaView d2e89df30ab0e2729b28539de37753e09c061b4c434b0a68e80554f7fa617ccb) SET(osx-14.6-arm64-ParaView 5e89b785ac0c56bbca31e2ae101a8986953e90227fe42a1ef7adcc70a0ff6fc4) +SET(osx-14.7-i386-ParaView d2e89df30ab0e2729b28539de37753e09c061b4c434b0a68e80554f7fa617ccb) +SET(osx-14.7-arm64-ParaView 5e89b785ac0c56bbca31e2ae101a8986953e90227fe42a1ef7adcc70a0ff6fc4) +SET(osx-15.0-i386-ParaView d2e89df30ab0e2729b28539de37753e09c061b4c434b0a68e80554f7fa617ccb) +SET(osx-15.0-arm64-ParaView 5e89b785ac0c56bbca31e2ae101a8986953e90227fe42a1ef7adcc70a0ff6fc4) SET(osx-xcode-13.1-i386-ROOT be97dd72022c8d082fbe4394f18b55c4920f20b138cfff1b5fc2b41d397ac203) SET(osx-xcode-13.1-arm64-ROOT 0a55b91c6df42d152b7943912e134f05c3872a73e73fcc129ee87fd847240ec8) SET(osx-xcode-14.1-i386-ROOT 001311608512b24535bb9710b8baf006bd00e9b0595fd6bdf900d28b1e22c395) @@ -78,6 +82,8 @@ SET(osx-xcode-15.3-i386-ROOT 52cef545acf679c3e491c9ef14e18edee454c90309b7fcf5f36 SET(osx-xcode-15.3-arm64-ROOT 3ee0885c329fab9a965c278cc491db82dcbde3999a96ac80d6f5145fb6794d1e) SET(osx-xcode-15.4-i386-ROOT 360983914520c4c9f1d3dd03c5ccdc251b9f6835cf1bcd4b5e83e2748e04811a) SET(osx-xcode-15.4-arm64-ROOT c50d3664b2eee3ed255ca3ae23f350aac0513bd740884b1133e0efb177bf1928) +SET(osx-xcode-16.0-i386-ROOT 360983914520c4c9f1d3dd03c5ccdc251b9f6835cf1bcd4b5e83e2748e04811a) +SET(osx-xcode-16.0-arm64-ROOT f48163b667df74038fd450ffa9dc96637ea535af4b9ff21f4643c121f30bdbfe) SET(ubuntu-18.04-Libroadrunner bf9293c1c95d0b65227bd7e08c0048116ba851bcec5028ef72ea13762ef79276) SET(ubuntu-18.04-ParaView e3fd74b13e9a4086988c5104c6b8d95c56365d25b491706a8e72018d0e5c76f1) From 89542869c766de2789f387f9cb9e9646c40f6050 Mon Sep 17 00:00:00 2001 From: Fons Rademakers Date: Wed, 18 Sep 2024 19:17:59 +0200 Subject: [PATCH 40/48] Update sha256 for ROOT for i386 for Xcode 16.0 on macOS 14.7 and 15.0. --- cmake/external/SHA256Digests.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/external/SHA256Digests.cmake b/cmake/external/SHA256Digests.cmake index 2645e6a1b..a5875a37d 100644 --- a/cmake/external/SHA256Digests.cmake +++ b/cmake/external/SHA256Digests.cmake @@ -82,7 +82,7 @@ SET(osx-xcode-15.3-i386-ROOT 52cef545acf679c3e491c9ef14e18edee454c90309b7fcf5f36 SET(osx-xcode-15.3-arm64-ROOT 3ee0885c329fab9a965c278cc491db82dcbde3999a96ac80d6f5145fb6794d1e) SET(osx-xcode-15.4-i386-ROOT 360983914520c4c9f1d3dd03c5ccdc251b9f6835cf1bcd4b5e83e2748e04811a) SET(osx-xcode-15.4-arm64-ROOT c50d3664b2eee3ed255ca3ae23f350aac0513bd740884b1133e0efb177bf1928) -SET(osx-xcode-16.0-i386-ROOT 360983914520c4c9f1d3dd03c5ccdc251b9f6835cf1bcd4b5e83e2748e04811a) +SET(osx-xcode-16.0-i386-ROOT cab41b0f2e45990775f8d322713fb9c7904350fdf7f057b4b3cd6e73ad654bf1) SET(osx-xcode-16.0-arm64-ROOT f48163b667df74038fd450ffa9dc96637ea535af4b9ff21f4643c121f30bdbfe) SET(ubuntu-18.04-Libroadrunner bf9293c1c95d0b65227bd7e08c0048116ba851bcec5028ef72ea13762ef79276) From ba201290bfaced0bb9e0a07bd28d0719b147c674 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Tue, 8 Oct 2024 11:06:37 +0200 Subject: [PATCH 41/48] Change bits/stdint-uintn.h for stdint.h to add macOS support --- src/core/util/partition.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/util/partition.h b/src/core/util/partition.h index 249333f04..1908a28cf 100644 --- a/src/core/util/partition.h +++ b/src/core/util/partition.h @@ -15,7 +15,7 @@ #ifndef CORE_UTIL_PARTITION_H_ #define CORE_UTIL_PARTITION_H_ -#include +#include #include namespace bdm { From e093b4c081e8a5701def91d69d73db6b663c548b Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Tue, 8 Oct 2024 11:13:23 +0200 Subject: [PATCH 42/48] Changed bits/std_function.hto functional --- demo/soma_clustering/src/validation_criterion.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/soma_clustering/src/validation_criterion.h b/demo/soma_clustering/src/validation_criterion.h index edc65423a..289512285 100644 --- a/demo/soma_clustering/src/validation_criterion.h +++ b/demo/soma_clustering/src/validation_criterion.h @@ -18,7 +18,7 @@ #include #include "biodynamo.h" #include -#include +#include #include #include "core/agent/agent.h" #include "core/container/math_array.h" From 68332b84b0f746bd1d7c30ac6a786d5909f0de47 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 16 Oct 2024 16:07:51 +0200 Subject: [PATCH 43/48] Fix missing behavior header --- demo/multiple_simulations/src/multiple_simulations.h | 1 + 1 file changed, 1 insertion(+) diff --git a/demo/multiple_simulations/src/multiple_simulations.h b/demo/multiple_simulations/src/multiple_simulations.h index 3d2b30eb1..4084679f9 100644 --- a/demo/multiple_simulations/src/multiple_simulations.h +++ b/demo/multiple_simulations/src/multiple_simulations.h @@ -17,6 +17,7 @@ #include #include "biodynamo.h" +#include "core/behavior/behavior.h" namespace bdm { From 2c4114cc41d26a9ff3dbbc53970a0abfa07582ee Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 11 Dec 2024 01:38:48 +0100 Subject: [PATCH 44/48] Added the -cxxmodules flag to bdm-dictionary. With C++ Modules, we don't need to pass the headers to the interpreter anymore. --- cmake/BioDynaMo.cmake | 4 +++- cmake/bdm-dictionary | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cmake/BioDynaMo.cmake b/cmake/BioDynaMo.cmake index 6f91b0469..37e0acd64 100644 --- a/cmake/BioDynaMo.cmake +++ b/cmake/BioDynaMo.cmake @@ -146,8 +146,10 @@ function(build_shared_library TARGET) else() set(BDM_OUT_OF_SRC_ARG --bdm-source ${CMAKE_SOURCE_DIR}) endif() + if (runtime_cxxmodules) + set(BDM_CXX_MODULES_ARG "--cxxmodules") add_custom_command(OUTPUT "${BDM_DICT_FILE}" - COMMAND ${Python_EXECUTABLE} ${BDM_DICT_BIN_PATH}/bdm-dictionary ${BDM_OUT_OF_SRC_ARG} --output ${BDM_DICT_FILE} --include-dirs ${INCLUDE_DIRS} --headers ${ARG_HEADERS} + COMMAND ${Python_EXECUTABLE} ${BDM_DICT_BIN_PATH}/bdm-dictionary ${BDM_OUT_OF_SRC_ARG} ${BDM_CXX_MODULES_ARG} --output ${BDM_DICT_FILE} --include-dirs ${INCLUDE_DIRS} --headers ${ARG_HEADERS} DEPENDS ${ARG_HEADERS} ${BDM_DICT_BIN_PATH}/bdm-dictionary) # generate shared library add_library(${TARGET} SHARED ${ARG_SOURCES} ${DICT_FILE}.cc ${BDM_DICT_FILE}) diff --git a/cmake/bdm-dictionary b/cmake/bdm-dictionary index 527b1cb5b..3c4931eb8 100755 --- a/cmake/bdm-dictionary +++ b/cmake/bdm-dictionary @@ -52,6 +52,7 @@ if __name__ == '__main__': parser.add_argument('--bdm-source', action='store', type=str, required=False, help='Source directory of BioDynaMo for bdm build.') parser.add_argument('--include-dirs', nargs='+', type=str, required=True, help='At least one directory that contains the header files.') parser.add_argument('--headers', nargs='+', type=str, required=True, help='At least one header file containing biodynamo definitions.') + parser.add_argument('--cxxmodules', action='store_true', help='Generate bdm dictionary for a C++ Modules enabled installation.') args = parser.parse_args() @@ -116,8 +117,10 @@ static struct BioDynaMoDictInit { AppendPrefix(id, prefixes) f.write(' idirs << {0} << ":";\n'.format(id_processed)) - for h in args.headers: - f.write(' bdm::JitHeaders::Register("{0}");\n'.format(RemoveLongestPrefix(h, prefixes))) + # We don't need to pass the headers to the interpreter since we use modules + if not args.modules: + for h in args.headers: + f.write(' bdm::JitHeaders::Register("{0}");\n'.format(RemoveLongestPrefix(h, prefixes))) f.write(""" AppendEnvVar(idirs, "ROOT_INCLUDE_PATH", ""); From ac5524de7af421a2c64cba4331e978a97f43fe57 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 11 Dec 2024 01:42:56 +0100 Subject: [PATCH 45/48] Add missing endif() --- cmake/BioDynaMo.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/BioDynaMo.cmake b/cmake/BioDynaMo.cmake index 37e0acd64..6d5238488 100644 --- a/cmake/BioDynaMo.cmake +++ b/cmake/BioDynaMo.cmake @@ -148,6 +148,7 @@ function(build_shared_library TARGET) endif() if (runtime_cxxmodules) set(BDM_CXX_MODULES_ARG "--cxxmodules") + endif() add_custom_command(OUTPUT "${BDM_DICT_FILE}" COMMAND ${Python_EXECUTABLE} ${BDM_DICT_BIN_PATH}/bdm-dictionary ${BDM_OUT_OF_SRC_ARG} ${BDM_CXX_MODULES_ARG} --output ${BDM_DICT_FILE} --include-dirs ${INCLUDE_DIRS} --headers ${ARG_HEADERS} DEPENDS ${ARG_HEADERS} ${BDM_DICT_BIN_PATH}/bdm-dictionary) From 7a2d6b3f0131f95fd92589bbb01c3d9509407e4b Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 11 Dec 2024 01:55:01 +0100 Subject: [PATCH 46/48] Format code and fix wrong variable name --- cmake/bdm-dictionary | 2 +- demo/soma_clustering/src/validation_criterion.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/bdm-dictionary b/cmake/bdm-dictionary index 3c4931eb8..7312cc507 100755 --- a/cmake/bdm-dictionary +++ b/cmake/bdm-dictionary @@ -118,7 +118,7 @@ static struct BioDynaMoDictInit { f.write(' idirs << {0} << ":";\n'.format(id_processed)) # We don't need to pass the headers to the interpreter since we use modules - if not args.modules: + if not args.cxxmodules: for h in args.headers: f.write(' bdm::JitHeaders::Register("{0}");\n'.format(RemoveLongestPrefix(h, prefixes))) diff --git a/demo/soma_clustering/src/validation_criterion.h b/demo/soma_clustering/src/validation_criterion.h index 289512285..5e2eef883 100644 --- a/demo/soma_clustering/src/validation_criterion.h +++ b/demo/soma_clustering/src/validation_criterion.h @@ -15,11 +15,11 @@ #ifndef VALIDATION_CRITERION_H_ #define VALIDATION_CRITERION_H_ +#include +#include +#include #include #include "biodynamo.h" -#include -#include -#include #include "core/agent/agent.h" #include "core/container/math_array.h" #include "core/real_t.h" From 1f7920285bb72d2aa874c83239e1f7d7a2b04f15 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 11 Dec 2024 02:04:14 +0100 Subject: [PATCH 47/48] Add BDM_CXXMODULES variable to track if BDM was built with cxxmodules --- cmake/BioDynaMo.cmake | 2 +- cmake/UseBioDynaMo.cmake.in | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/BioDynaMo.cmake b/cmake/BioDynaMo.cmake index 6d5238488..ab6216660 100644 --- a/cmake/BioDynaMo.cmake +++ b/cmake/BioDynaMo.cmake @@ -146,7 +146,7 @@ function(build_shared_library TARGET) else() set(BDM_OUT_OF_SRC_ARG --bdm-source ${CMAKE_SOURCE_DIR}) endif() - if (runtime_cxxmodules) + if (BDM_CXXMODULES) set(BDM_CXX_MODULES_ARG "--cxxmodules") endif() add_custom_command(OUTPUT "${BDM_DICT_FILE}" diff --git a/cmake/UseBioDynaMo.cmake.in b/cmake/UseBioDynaMo.cmake.in index 469607928..2a568f160 100644 --- a/cmake/UseBioDynaMo.cmake.in +++ b/cmake/UseBioDynaMo.cmake.in @@ -107,6 +107,7 @@ if(UNIX AND NOT APPLE) endif() set(BDM_OUT_OF_SOURCE true) +set(BDM_MODULES @runtime_cxxmodules@) if(real_t) message(STATUS "BioDynaMo real_t set to: ${real_t}") From 8c84c554384ff0b1559dc7f88260656ede290283 Mon Sep 17 00:00:00 2001 From: Isaac Morales Date: Wed, 11 Dec 2024 02:10:58 +0100 Subject: [PATCH 48/48] Fix wrong variable name --- cmake/UseBioDynaMo.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/UseBioDynaMo.cmake.in b/cmake/UseBioDynaMo.cmake.in index 2a568f160..6df6fd13f 100644 --- a/cmake/UseBioDynaMo.cmake.in +++ b/cmake/UseBioDynaMo.cmake.in @@ -107,7 +107,7 @@ if(UNIX AND NOT APPLE) endif() set(BDM_OUT_OF_SOURCE true) -set(BDM_MODULES @runtime_cxxmodules@) +set(BDM_CXXMODULES @runtime_cxxmodules@) if(real_t) message(STATUS "BioDynaMo real_t set to: ${real_t}")