Skip to content

Commit c8c068f

Browse files
committed
Get rid of wrapper script for creating ROOT dictionaries
The sole need for the wrapper was to properly handle warnings and complain on missing options. Since long rootcling is now gracefully handling both, so we remove the wrapper.
1 parent 5b009ee commit c8c068f

4 files changed

Lines changed: 88 additions & 165 deletions

File tree

cmake/AddRootDictionary.cmake

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212
include_guard()
1313

14-
configure_file(${CMAKE_CURRENT_LIST_DIR}/rootcling_wrapper.sh.in
15-
${CMAKE_BINARY_DIR}/rootcling_wrapper.sh @ONLY)
14+
set(O2_RUN_ROOTCLING_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/RunRootcling.cmake)
1615

1716
#
1817
# add_root_dictionary generates one dictionary to be added to a target.
@@ -119,7 +118,9 @@ function(add_root_dictionary target)
119118
# get the list of compile_definitions
120119
set(prop $<TARGET_PROPERTY:${target},COMPILE_DEFINITIONS>)
121120

122-
# Build the LD_LIBRARY_PATH required to get rootcling running fine
121+
# Build the LD_LIBRARY_PATH required to get rootcling running fine. It
122+
# REPLACES the inherited value, so RunRootcling.cmake applies it to rootcling
123+
# only: putting it on cmake itself hides cmake's own OpenSSL (see #12683).
123124
#
124125
# Need at least root core library
125126
get_filename_component(LD_LIBRARY_PATH ${ROOT_Core_LIBRARY} DIRECTORY)
@@ -132,25 +133,37 @@ function(add_root_dictionary target)
132133
set(includeDirs $<TARGET_PROPERTY:${target},INCLUDE_DIRECTORIES>)
133134
set(includeDirs $<REMOVE_DUPLICATES:${includeDirs}>)
134135

135-
list(LENGTH A_EXTRA_PATCH hasExtraPatch)
136-
# add a custom command to generate the dictionary using rootcling
136+
# the pcm dependencies (-m) are only meaningful where the modules are actually
137+
# loaded from disk, which is not the case on macOS
138+
set(pcmDeps $<REMOVE_DUPLICATES:$<TARGET_PROPERTY:${target},O2_PCM_DEPS>>)
139+
if(APPLE)
140+
set(pcmDeps)
141+
endif()
142+
143+
if(A_EXTRA_PATCH)
144+
set(extraPatch -DPATCH=${CMAKE_CURRENT_LIST_DIR}/${A_EXTRA_PATCH})
145+
else()
146+
set(extraPatch)
147+
endif()
148+
149+
# the arguments are joined with | so that they reach the script as a single
150+
# argument, see RunRootcling.cmake
137151
# cmake-format: off
152+
set(rootclingArgs
153+
-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},|>)
154+
155+
# add a custom command to generate the dictionary using rootcling
138156
add_custom_command(
139157
OUTPUT ${dictionaryFile} ${pcmFile} ${rootmapFile}
140158
VERBATIM
141159
COMMAND
142-
${CMAKE_BINARY_DIR}/rootcling_wrapper.sh
143-
--rootmap_file ${rootmapFile}
144-
--dictionary_file ${dictionaryFile}
145-
--ld_library_path ${LD_LIBRARY_PATH}
146-
--rootmap_library_name $<TARGET_FILE_NAME:${target}>
147-
--include_dirs -I$<JOIN:${includeDirs},$<SEMICOLON>-I>
148-
$<$<BOOL:${prop}>:--compile_defs>
149-
$<$<BOOL:${prop}>:-D$<JOIN:${prop},$<SEMICOLON>-D>>
150-
$<$<BOOL:${hasExtraPatch}>:--extra-patch>
151-
$<$<BOOL:${hasExtraPatch}>:${CMAKE_CURRENT_LIST_DIR}/${A_EXTRA_PATCH}>
152-
--pcmdeps "$<REMOVE_DUPLICATES:$<TARGET_PROPERTY:${target},O2_PCM_DEPS>>"
153-
--headers "${headers}"
160+
${CMAKE_COMMAND}
161+
-DROOTCLING=${ROOT_rootcling_CMD}
162+
-DDICTIONARY=${dictionaryFile}
163+
"-DLD_LIBRARY_PATH=${LD_LIBRARY_PATH}"
164+
${extraPatch}
165+
"-DARGS=${rootclingArgs}"
166+
-P ${O2_RUN_ROOTCLING_SCRIPT}
154167
COMMAND
155168
${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/${pcmBase} ${pcmFile}
156169
DEPENDS ${headers} "$<REMOVE_DUPLICATES:$<TARGET_PROPERTY:${target},O2_PCM_DEPS>>" ${A_EXTRA_PATCH})

cmake/RunRootcling.cmake

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
# All rights not expressly granted are reserved.
4+
#
5+
# This software is distributed under the terms of the GNU General Public
6+
# License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
#
8+
# In applying this license CERN does not waive the privileges and immunities
9+
# granted to it by virtue of its status as an Intergovernmental Organization
10+
# or submit itself to any jurisdiction.
11+
12+
# Runs rootcling, optionally appends PATCH to the generated dictionary, and
13+
# turns the "Unused class rule" warning into an error.
14+
#
15+
# rootcling only offers -failOnWarnings, which is all or nothing, so the
16+
# output still has to be inspected to single out that one warning.
17+
#
18+
# ARGS is separated by | rather than ; so that it survives as a single
19+
# argument through add_custom_command.
20+
21+
if(NOT ROOTCLING OR NOT ARGS OR NOT DICTIONARY)
22+
message(FATAL_ERROR "ROOTCLING, ARGS and DICTIONARY must all be given")
23+
endif()
24+
25+
# Applied to rootcling only: it replaces rather than extends the inherited
26+
# value, and cmake itself needs libraries it does not list.
27+
if(LD_LIBRARY_PATH)
28+
set(rootclingCmd ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${LD_LIBRARY_PATH} ${ROOTCLING})
29+
else()
30+
set(rootclingCmd ${ROOTCLING})
31+
endif()
32+
33+
string(REPLACE "|" ";" rootclingArgs "${ARGS}")
34+
35+
execute_process(COMMAND ${rootclingCmd} ${rootclingArgs}
36+
OUTPUT_VARIABLE output
37+
ERROR_VARIABLE output
38+
RESULT_VARIABLE status)
39+
40+
if(output)
41+
message("${output}")
42+
endif()
43+
44+
if(NOT status EQUAL 0)
45+
file(REMOVE ${DICTIONARY})
46+
message(FATAL_ERROR "rootcling failed for ${DICTIONARY} with error code ${status}")
47+
endif()
48+
49+
if(output MATCHES "Warning: Unused class rule")
50+
file(REMOVE ${DICTIONARY})
51+
message(FATAL_ERROR "please fix the warnings above about unused class rule")
52+
endif()
53+
54+
if(PATCH)
55+
file(READ ${PATCH} patchContent)
56+
file(APPEND ${DICTIONARY} "${patchContent}")
57+
endif()

cmake/rootcling_wrapper.sh.in

Lines changed: 0 additions & 138 deletions
This file was deleted.

packaging/CMakeLists.txt

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,7 @@ install(EXPORT O2Targets
1717
FILE O2Targets.cmake)
1818

1919
install(FILES O2Config.cmake ../cmake/AddRootDictionary.cmake
20+
../cmake/RunRootcling.cmake
2021
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/O2)
2122

22-
install(FILES ../cmake/rootcling_wrapper.sh.in
23-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/O2
24-
PERMISSIONS OWNER_READ
25-
OWNER_WRITE
26-
OWNER_EXECUTE
27-
GROUP_READ
28-
GROUP_EXECUTE
29-
WORLD_READ
30-
WORLD_EXECUTE)
31-
3223
install(DIRECTORY ../dependencies/ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/O2)

0 commit comments

Comments
 (0)