Skip to content

Commit 2d00683

Browse files
committed
Fix bug where ${PREFIX}_CONFIG_VARS in yggdrasil_rapidjson_config_vars was not forwarded to caller of yggdrasil_rapidjson_config_init
Ensure that ASAN/UBSAN compilation/linking flags are only set for C/CXX (clang & GNU Fortran not compatible)
1 parent 799072b commit 2d00683

2 files changed

Lines changed: 28 additions & 10 deletions

File tree

YggdrasilRapidJSONMacros.cmake

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ function(yggdrasil_rapidjson_config_vars PREFIX)
6666
${PREFIX}_PUBLIC_${tool}_${suffix_lang}
6767
${PREFIX}_PRIVATE_${tool}_${suffix_lang}
6868
)
69+
set(langlist C CXX)
70+
if(tool STREQUAL "GNU")
71+
list(APPEND langlist Fortran)
72+
endif()
73+
foreach(lang IN LISTS langlist)
74+
list(
75+
APPEND ${PREFIX}_CONFIG_VARS
76+
${PREFIX}_PUBLIC_${tool}_${lang}_${suffix_lang}
77+
${PREFIX}_PRIVATE_${tool}_${lang}_${suffix_lang}
78+
)
79+
endforeach()
6980
endforeach()
7081
endforeach()
7182
foreach(suffix LIBRARIES INCLUDE_DIRS COMPILE_FLAGS LINK_FLAGS)
@@ -83,6 +94,7 @@ function(yggdrasil_rapidjson_config_init PREFIX)
8394
foreach(var IN LISTS ${PREFIX}_CONFIG_VARS)
8495
set(${var} "" PARENT_SCOPE)
8596
endforeach()
97+
set(${PREFIX}_CONFIG_VARS ${${PREFIX}_CONFIG_VARS} PARENT_SCOPE)
8698
endfunction()
8799

88100
function(yggdrasil_rapidjson_config_cleanup PREFIX)
@@ -132,19 +144,24 @@ function(yggdrasil_rapidjson_config_accum PREFIX)
132144
endforeach()
133145
foreach(tool GNU Clang AppleClang MSVC)
134146
set(k ${PREFIX}_PUBLIC_${tool}_${suffix_lang})
135-
if(NOT ${k})
136-
continue()
137-
endif()
138147
set(langlist C CXX)
139-
set(toollist ${tool})
140148
if(tool STREQUAL "GNU")
141149
list(APPEND langlist Fortran)
142150
endif()
143151
foreach(lang IN LISTS langlist)
144-
list(
145-
APPEND ${PREFIX}_ALL_PUBLIC_${suffix}
146-
$<$<${gentype}_LANG_AND_ID:${lang},${tool}>:${${k}}>
147-
)
152+
set(klang ${PREFIX}_PUBLIC_${tool}_${lang}_${suffix_lang})
153+
if(${k})
154+
list(
155+
APPEND ${PREFIX}_ALL_PUBLIC_${suffix}
156+
$<$<${gentype}_LANG_AND_ID:${lang},${tool}>:${${k}}>
157+
)
158+
endif()
159+
if(${klang})
160+
list(
161+
APPEND ${PREFIX}_ALL_PUBLIC_${suffix}
162+
$<$<${gentype}_LANG_AND_ID:${lang},${tool}>:${${klang}}>
163+
)
164+
endif()
148165
endforeach()
149166
endforeach()
150167
message(DEBUG "${PREFIX}_ALL_PUBLIC_${suffix} = ${${PREFIX}_ALL_PUBLIC_${suffix}}")
@@ -414,7 +431,8 @@ macro(yggdrasil_rapidjson_options_config OUTPUT_PREFIX)
414431
set(k ${OUTPUT_PREFIX}_${_yggdrasil_rapidjson_asan_tool}_ASAN_COMPILE_FLAGS)
415432
if(${k})
416433
foreach(_yggdrasil_rapidjson_asan_suffix COMPILE_FLAGS LINK_FLAGS)
417-
list(APPEND ${OUTPUT_PREFIX}_PUBLIC_${_yggdrasil_rapidjson_asan_tool}_${_yggdrasil_rapidjson_asan_suffix} ${${k}})
434+
list(APPEND ${OUTPUT_PREFIX}_PUBLIC_${_yggdrasil_rapidjson_asan_tool}_C_${_yggdrasil_rapidjson_asan_suffix} ${${k}})
435+
list(APPEND ${OUTPUT_PREFIX}_PUBLIC_${_yggdrasil_rapidjson_asan_tool}_CXX_${_yggdrasil_rapidjson_asan_suffix} ${${k}})
418436
endforeach()
419437
endif()
420438
endforeach()

run_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ if [ ! -d ${INSTALL_DIR} ]; then
3838
mkdir ${INSTALL_DIR}
3939
fi
4040

41-
cmake -B ${BUILD_DIR} -S $(pwd) \
41+
cmake -G Ninja -B ${BUILD_DIR} -S $(pwd) \
4242
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
4343
-DYGGDRASIL_RAPIDJSON_SKIP_VALGRIND_TESTS:BOOL=ON \
4444
-DYGGDRASIL_RAPIDJSON_CREATE_METASCHEMA_FULL:BOOL=ON \

0 commit comments

Comments
 (0)