mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 02:39:48 -06:00
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.
This commit is contained in:
@@ -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}")
|
||||
|
||||
7
Tests/Module/WriteCompilerDetectionHeader/c_undefined.c
Normal file
7
Tests/Module/WriteCompilerDetectionHeader/c_undefined.c
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
#include "test_compiler_detection.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user