summaryrefslogtreecommitdiff
path: root/Modules/WriteCompilerDetectionHeader.cmake
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-06-13 11:39:47 +0200
committerStephen Kelly <steveire@gmail.com>2014-07-02 19:37:04 +0200
commitb47c125ff7f088c87183e6ad60850aefdaf43757 (patch)
tree7ac75263740e5490a2feb408bded3440ac9bfb00 /Modules/WriteCompilerDetectionHeader.cmake
parent477b07213a806c825f95fdfacd444028e1783dc2 (diff)
downloadcmake-b47c125ff7f088c87183e6ad60850aefdaf43757.tar.gz
WCDH: Ensure that the prefix argument to the macro is valid.
The prefix must be a C-identifier because it is written as the prefix of preprocessor macros and possibly structs.
Diffstat (limited to 'Modules/WriteCompilerDetectionHeader.cmake')
-rw-r--r--Modules/WriteCompilerDetectionHeader.cmake8
1 files changed, 8 insertions, 0 deletions
diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake
index 593176c91b..86137e2d68 100644
--- a/Modules/WriteCompilerDetectionHeader.cmake
+++ b/Modules/WriteCompilerDetectionHeader.cmake
@@ -235,6 +235,14 @@ function(write_compiler_detection_header
message(FATAL_ERROR "Unparsed arguments: ${_WCD_UNPARSED_ARGUMENTS}")
endif()
+ if (prefix_arg STREQUAL "")
+ message(FATAL_ERROR "A prefix must be specified")
+ endif()
+ string(MAKE_C_IDENTIFIER ${prefix_arg} cleaned_prefix)
+ if (NOT prefix_arg STREQUAL cleaned_prefix)
+ message(FATAL_ERROR "The prefix must be a valid C identifier.")
+ endif()
+
if(NOT _WCD_VERSION)
set(_WCD_VERSION ${CMAKE_MINIMUM_REQUIRED_VERSION})
endif()