Skip to content

Commit 76ae281

Browse files
committed
Add support for EXTRA_PATCH in root dictionary generation
1 parent e962d83 commit 76ae281

File tree

3 files changed

+38
-10
lines changed

3 files changed

+38
-10
lines changed

cmake/AddRootDictionary.cmake

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function(add_root_dictionary target)
5151
1
5252
A
5353
""
54-
"LINKDEF"
54+
"LINKDEF;EXTRA_PATCH"
5555
"HEADERS;BASENAME")
5656
if(A_UNPARSED_ARGUMENTS)
5757
message(
@@ -112,7 +112,7 @@ function(add_root_dictionary target)
112112
set(pcmBase ${dictionary}_rdict.pcm)
113113
set(pcmFile ${lib_output_dir}/${pcmBase})
114114
set(rootmapFile ${lib_output_dir}/lib${basename}.rootmap)
115-
115+
116116
set(O2_TARGETPCMMAP_TARGET "${O2_TARGETPCMMAP_TARGET};${target}" CACHE INTERNAL "target/PCM map (target)")
117117
set(O2_TARGETPCMMAP_PCM "${O2_TARGETPCMMAP_PCM};${pcmFile}" CACHE INTERNAL "target/PCM map (pcm)")
118118

@@ -132,6 +132,7 @@ function(add_root_dictionary target)
132132
set(includeDirs $<TARGET_PROPERTY:${target},INCLUDE_DIRECTORIES>)
133133
set(includeDirs $<REMOVE_DUPLICATES:${includeDirs}>)
134134

135+
list(LENGTH A_EXTRA_PATCH hasExtraPatch)
135136
# add a custom command to generate the dictionary using rootcling
136137
# cmake-format: off
137138
add_custom_command(
@@ -146,11 +147,13 @@ function(add_root_dictionary target)
146147
--include_dirs -I$<JOIN:${includeDirs},$<SEMICOLON>-I>
147148
$<$<BOOL:${prop}>:--compile_defs>
148149
$<$<BOOL:${prop}>:-D$<JOIN:${prop},$<SEMICOLON>-D>>
150+
$<$<BOOL:${hasExtraPatch}>:--extra-patch>
151+
$<$<BOOL:${hasExtraPatch}>:${CMAKE_CURRENT_LIST_DIR}/${A_EXTRA_PATCH}>
149152
--pcmdeps "$<REMOVE_DUPLICATES:${list_pcm_deps_${target}}>"
150153
--headers "${headers}"
151154
COMMAND
152155
${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/${pcmBase} ${pcmFile}
153-
DEPENDS ${headers} "$<REMOVE_DUPLICATES:${list_pcm_deps_${target}}>")
156+
DEPENDS ${headers} "$<REMOVE_DUPLICATES:${list_pcm_deps_${target}}>" ${A_EXTRA_PATCH})
154157
# cmake-format: on
155158

156159
# add dictionary source to the target sources

cmake/O2TargetRootDictionary.cmake

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,9 @@ function(o2_target_root_dictionary baseTargetName)
5555
1
5656
A
5757
""
58-
"LINKDEF"
58+
"LINKDEF;EXTRA_PATCH"
5959
"HEADERS")
6060

61-
if(A_UNPARSED_ARGUMENTS)
62-
message(
63-
FATAL_ERROR "Unexpected unparsed arguments: ${A_UNPARSED_ARGUMENTS}")
64-
endif()
65-
6661
if(${ARGC} LESS 1)
6762
message(
6863
FATAL_ERROR
@@ -96,6 +91,13 @@ function(o2_target_root_dictionary baseTargetName)
9691

9792
# now that we have the O2 specific stuff computed, delegate the actual work to
9893
# the add_root_dictionary function
99-
add_root_dictionary(${target} HEADERS ${A_HEADERS} LINKDEF ${A_LINKDEF})
94+
if(NOT A_EXTRA_PATCH)
95+
add_root_dictionary(${target} HEADERS ${A_HEADERS} LINKDEF ${A_LINKDEF})
96+
else()
97+
add_root_dictionary(${target}
98+
EXTRA_PATCH ${A_EXTRA_PATCH}
99+
HEADERS ${A_HEADERS}
100+
LINKDEF ${A_LINKDEF})
101+
endif()
100102

101103
endfunction()

cmake/rootcling_wrapper.sh.in

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ while [[ $# -gt 0 ]]; do
4141
PCMDEPS="$2"
4242
shift 2
4343
;;
44+
--extra-patch)
45+
EXTRA_PATCH="$2"
46+
shift 2
47+
;;
4448
*)
4549
if [[ -z "$1" ]]; then
4650
shift
@@ -82,6 +86,18 @@ esac
8286

8387
LOGFILE=${DICTIONARY_FILE}.log
8488

89+
echo @CMAKE_COMMAND@ -E env "LD_LIBRARY_PATH=$libpath" @ROOT_rootcling_CMD@ \
90+
-f $DICTIONARY_FILE \
91+
-inlineInputHeader \
92+
-noGlobalUsingStd \
93+
-rmf ${ROOTMAP_FILE} \
94+
-rml ${ROOTMAP_LIBRARY_NAME} \
95+
${INCLUDE_DIRS//;/ } \
96+
${COMPILE_DEFINITIONS//;/ } \
97+
${PCMDEPS:+-m }${PCMDEPS//;/ -m } \
98+
${HEADERS//;/ } \
99+
> ${LOGFILE} 2>&1 || ROOTCLINGRETVAL=$?
100+
85101
@CMAKE_COMMAND@ -E env "LD_LIBRARY_PATH=$libpath" @ROOT_rootcling_CMD@ \
86102
-f $DICTIONARY_FILE \
87103
-inlineInputHeader \
@@ -94,6 +110,13 @@ LOGFILE=${DICTIONARY_FILE}.log
94110
${HEADERS//;/ } \
95111
> ${LOGFILE} 2>&1 || ROOTCLINGRETVAL=$?
96112

113+
# Add the extra patch file at the end of the generated dictionary.
114+
# This is needed to inject custom streamers (e.g. for std::vector<PadFlags>)
115+
# to our dictionary.
116+
if [ ! X"${EXTRA_PATCH}" = X ]; then
117+
cat $EXTRA_PATCH >> ${DICTIONARY_FILE}
118+
fi
119+
97120
if [[ ${ROOTCLINGRETVAL:-0} != "0" ]]; then
98121
cat ${LOGFILE} >&2
99122
rm -f $DICTIONARY_FILE

0 commit comments

Comments
 (0)