diff options
author | Stephen Kelly <steveire@gmail.com> | 2014-11-24 20:47:48 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2014-11-25 13:44:21 (GMT) |
commit | d0af0faefbeca4f2821ddafe34a0b52032ee01a7 (patch) | |
tree | bf1763623e68b6c44c6f6f5c55a629c17753d340 /Tests/Module/WriteCompilerDetectionHeader | |
parent | 598a316154922f27f987d0f7a78b28ab78a85be6 (diff) | |
download | CMake-d0af0faefbeca4f2821ddafe34a0b52032ee01a7.zip CMake-d0af0faefbeca4f2821ddafe34a0b52032ee01a7.tar.gz CMake-d0af0faefbeca4f2821ddafe34a0b52032ee01a7.tar.bz2 |
WCDH: Make the header -Wundef safe for the C language.
The __STDC_VERSION__ macro may be defined or not depending on the
implementation dialect of C. Test that it is defined before testing
its value.
The CXX tests do not need such a change because they define __cplusplus
in all dialects.
Diffstat (limited to 'Tests/Module/WriteCompilerDetectionHeader')
-rw-r--r-- | Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt | 7 | ||||
-rw-r--r-- | Tests/Module/WriteCompilerDetectionHeader/c_undefined.c | 7 |
2 files changed, 14 insertions, 0 deletions
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; +} |