Skip to content

Commit

Permalink
Fix potentially invalid macro name in generated version header
Browse files Browse the repository at this point in the history
The generated name could be invalid if the target name contains
characters that are not legal macro identifiers. This commit changes
replaces all illegal characters with the underscore "_".
  • Loading branch information
jan-moeller committed Nov 6, 2023
1 parent 28f6118 commit 23c7c06
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ function(packageProject)
endif()

string(TOUPPER ${PROJECT_NAME} UPPERCASE_PROJECT_NAME)
string(REGEX REPLACE [^a-zA-Z0-9] _ UPPERCASE_PROJECT_NAME ${UPPERCASE_PROJECT_NAME})
configure_file(
${PACKAGE_PROJECT_ROOT_PATH}/version.h.in
${PROJECT_VERSION_INCLUDE_DIR}/${PROJECT_VERSION_HEADER} @ONLY
Expand Down

0 comments on commit 23c7c06

Please sign in to comment.