Skip to content

Commit ac46aef

Browse files
Fix potentially invalid macro name in generated version header (#38)
* Fix potentially invalid macro name in generated version header The generated name was invalid if the target name contained characters that are not legal in macro identifiers. This commit replaces all illegal characters with the underscore "_". * Update CMakeLists.txt --------- Co-authored-by: Lars Melchior <[email protected]>
1 parent 28f6118 commit ac46aef

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ function(packageProject)
8181
endif()
8282

8383
string(TOUPPER ${PROJECT_NAME} UPPERCASE_PROJECT_NAME)
84+
# ensure that the generated macro does not include invalid characters
85+
string(REGEX REPLACE [^a-zA-Z0-9] _ UPPERCASE_PROJECT_NAME ${UPPERCASE_PROJECT_NAME})
8486
configure_file(
8587
${PACKAGE_PROJECT_ROOT_PATH}/version.h.in
8688
${PROJECT_VERSION_INCLUDE_DIR}/${PROJECT_VERSION_HEADER} @ONLY

0 commit comments

Comments
 (0)