From 23c7c06e432ef92d2f34705d39fac3f3081d7cf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6ller?= Date: Mon, 6 Nov 2023 19:46:30 +0100 Subject: [PATCH] Fix potentially invalid macro name in generated version header 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 "_". --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b42200..6e25a0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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