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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 27 additions & 16 deletions cmake/AddRootDictionary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

include_guard()

configure_file(${CMAKE_CURRENT_LIST_DIR}/rootcling_wrapper.sh.in
${CMAKE_BINARY_DIR}/rootcling_wrapper.sh @ONLY)
set(O2_RUN_ROOTCLING_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/RunRootcling.cmake)

#
# add_root_dictionary generates one dictionary to be added to a target.
Expand Down Expand Up @@ -132,25 +131,37 @@ function(add_root_dictionary target)
set(includeDirs $<TARGET_PROPERTY:${target},INCLUDE_DIRECTORIES>)
set(includeDirs $<REMOVE_DUPLICATES:${includeDirs}>)

list(LENGTH A_EXTRA_PATCH hasExtraPatch)
# add a custom command to generate the dictionary using rootcling
# the pcm dependencies (-m) are only meaningful where the modules are actually
# loaded from disk, which is not the case on macOS
set(pcmDeps $<REMOVE_DUPLICATES:$<TARGET_PROPERTY:${target},O2_PCM_DEPS>>)
if(APPLE)
set(pcmDeps)
endif()

if(A_EXTRA_PATCH)
set(extraPatch -DPATCH=${CMAKE_CURRENT_LIST_DIR}/${A_EXTRA_PATCH})
else()
set(extraPatch)
endif()

# the arguments are joined with | so that they reach the script as a single
# argument, see RunRootcling.cmake
# cmake-format: off
set(rootclingArgs
-f|${dictionaryFile}|-inlineInputHeader|-noGlobalUsingStd|-rmf|${rootmapFile}|-rml|$<TARGET_FILE_NAME:${target}>|-I$<JOIN:${includeDirs},|-I>$<$<BOOL:${prop}>:|-D$<JOIN:${prop},|-D>>$<$<BOOL:${pcmDeps}>:|-m|$<JOIN:${pcmDeps},|-m|>>|$<JOIN:${headers},|>)

# add a custom command to generate the dictionary using rootcling
add_custom_command(
OUTPUT ${dictionaryFile} ${pcmFile} ${rootmapFile}
VERBATIM
COMMAND
${CMAKE_BINARY_DIR}/rootcling_wrapper.sh
--rootmap_file ${rootmapFile}
--dictionary_file ${dictionaryFile}
--ld_library_path ${LD_LIBRARY_PATH}
--rootmap_library_name $<TARGET_FILE_NAME:${target}>
--include_dirs -I$<JOIN:${includeDirs},$<SEMICOLON>-I>
$<$<BOOL:${prop}>:--compile_defs>
$<$<BOOL:${prop}>:-D$<JOIN:${prop},$<SEMICOLON>-D>>
$<$<BOOL:${hasExtraPatch}>:--extra-patch>
$<$<BOOL:${hasExtraPatch}>:${CMAKE_CURRENT_LIST_DIR}/${A_EXTRA_PATCH}>
--pcmdeps "$<REMOVE_DUPLICATES:$<TARGET_PROPERTY:${target},O2_PCM_DEPS>>"
--headers "${headers}"
${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
${CMAKE_COMMAND}
-DROOTCLING=${ROOT_rootcling_CMD}
-DDICTIONARY=${dictionaryFile}
${extraPatch}
"-DARGS=${rootclingArgs}"
-P ${O2_RUN_ROOTCLING_SCRIPT}
COMMAND
${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/${pcmBase} ${pcmFile}
DEPENDS ${headers} "$<REMOVE_DUPLICATES:$<TARGET_PROPERTY:${target},O2_PCM_DEPS>>" ${A_EXTRA_PATCH})
Expand Down
49 changes: 49 additions & 0 deletions cmake/RunRootcling.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2019-2020 CERN and copyright holders of ALICE O2.
# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
# All rights not expressly granted are reserved.
#
# This software is distributed under the terms of the GNU General Public
# License v3 (GPL Version 3), copied verbatim in the file "COPYING".
#
# In applying this license CERN does not waive the privileges and immunities
# granted to it by virtue of its status as an Intergovernmental Organization
# or submit itself to any jurisdiction.

# Runs rootcling, optionally appends PATCH to the generated dictionary, and
# turns the "Unused class rule" warning into an error.
#
# rootcling only offers -failOnWarnings, which is all or nothing, so the
# output still has to be inspected to single out that one warning.
#
# ARGS is separated by | rather than ; so that it survives as a single
# argument through add_custom_command.

if(NOT ROOTCLING OR NOT ARGS OR NOT DICTIONARY)
message(FATAL_ERROR "ROOTCLING, ARGS and DICTIONARY must all be given")
endif()

string(REPLACE "|" ";" rootclingArgs "${ARGS}")

execute_process(COMMAND ${ROOTCLING} ${rootclingArgs}
OUTPUT_VARIABLE output
ERROR_VARIABLE output
RESULT_VARIABLE status)

if(output)
message("${output}")
endif()

if(NOT status EQUAL 0)
file(REMOVE ${DICTIONARY})
message(FATAL_ERROR "rootcling failed for ${DICTIONARY} with error code ${status}")
endif()

if(output MATCHES "Warning: Unused class rule")
file(REMOVE ${DICTIONARY})
message(FATAL_ERROR "please fix the warnings above about unused class rule")
endif()

if(PATCH)
file(READ ${PATCH} patchContent)
file(APPEND ${DICTIONARY} "${patchContent}")
endif()
138 changes: 0 additions & 138 deletions cmake/rootcling_wrapper.sh.in

This file was deleted.

11 changes: 1 addition & 10 deletions packaging/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,7 @@ install(EXPORT O2Targets
FILE O2Targets.cmake)

install(FILES O2Config.cmake ../cmake/AddRootDictionary.cmake
../cmake/RunRootcling.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/O2)

install(FILES ../cmake/rootcling_wrapper.sh.in
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/O2
PERMISSIONS OWNER_READ
OWNER_WRITE
OWNER_EXECUTE
GROUP_READ
GROUP_EXECUTE
WORLD_READ
WORLD_EXECUTE)

install(DIRECTORY ../dependencies/ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/O2)