summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/Compiler/Clang-C-FeatureTests.cmake4
-rw-r--r--Modules/Compiler/GNU-C-FeatureTests.cmake4
-rw-r--r--Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt7
-rw-r--r--Tests/Module/WriteCompilerDetectionHeader/c_undefined.c7
4 files changed, 18 insertions, 4 deletions
diff --git a/Modules/Compiler/Clang-C-FeatureTests.cmake b/Modules/Compiler/Clang-C-FeatureTests.cmake
index 4a72e87..2d8673d 100644
--- a/Modules/Compiler/Clang-C-FeatureTests.cmake
+++ b/Modules/Compiler/Clang-C-FeatureTests.cmake
@@ -1,9 +1,9 @@
set(_cmake_oldestSupported "((__clang_major__ * 100) + __clang_minor__) >= 304")
-set(Clang_C11 "${_cmake_oldestSupported} && __STDC_VERSION__ >= 201112L")
+set(Clang_C11 "${_cmake_oldestSupported} && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L")
set(_cmake_feature_test_c_static_assert "${Clang_C11}")
-set(Clang_C99 "${_cmake_oldestSupported} && __STDC_VERSION__ >= 199901L")
+set(Clang_C99 "${_cmake_oldestSupported} && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L")
set(_cmake_feature_test_c_restrict "${Clang_C99}")
set(_cmake_feature_test_c_variadic_macros "${Clang_C99}")
diff --git a/Modules/Compiler/GNU-C-FeatureTests.cmake b/Modules/Compiler/GNU-C-FeatureTests.cmake
index dc1695c..dfaeebf 100644
--- a/Modules/Compiler/GNU-C-FeatureTests.cmake
+++ b/Modules/Compiler/GNU-C-FeatureTests.cmake
@@ -1,10 +1,10 @@
set(_cmake_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 407")
-set(GNU46_C11 "${_cmake_oldestSupported} && __STDC_VERSION__ >= 201112L")
+set(GNU46_C11 "${_cmake_oldestSupported} && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L")
set(_cmake_feature_test_c_static_assert "${GNU46_C11}")
# Since 4.4 at least:
-set(GNU44_C99 "${_cmake_oldestSupported} && __STDC_VERSION__ >= 199901L")
+set(GNU44_C99 "${_cmake_oldestSupported} && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L")
set(_cmake_feature_test_c_restrict "${GNU44_C99}")
set(_cmake_feature_test_c_variadic_macros "${GNU44_C99}")
diff --git a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
index 645cc65..7bf9f28 100644
--- a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
+++ b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
@@ -63,6 +63,13 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL GNU
list(APPEND false_defs EXPECTED_COMPILER_CXX_VARIADIC_TEMPLATES)
endif()
+if (CMAKE_C_COMPILER_ID STREQUAL GNU
+ OR CMAKE_C_COMPILER_ID STREQUAL Clang)
+ add_executable(C_undefined c_undefined.c)
+ set_property(TARGET C_undefined PROPERTY CXX_STANDARD 90)
+ target_compile_options(C_undefined PRIVATE -Werror=undef)
+endif()
+
add_executable(WriteCompilerDetectionHeader main.cpp)
set_property(TARGET WriteCompilerDetectionHeader PROPERTY CXX_STANDARD 98)
set_defines(WriteCompilerDetectionHeader "${true_defs}" "${false_defs}")
diff --git a/Tests/Module/WriteCompilerDetectionHeader/c_undefined.c b/Tests/Module/WriteCompilerDetectionHeader/c_undefined.c
new file mode 100644
index 0000000..487e66d
--- /dev/null
+++ b/Tests/Module/WriteCompilerDetectionHeader/c_undefined.c
@@ -0,0 +1,7 @@
+
+#include "test_compiler_detection.h"
+
+int main()
+{
+ return 0;
+}