mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 13:51:33 -06:00
Tests/CompileFeatures: Cover c_std_## and cxx_std_## meta-features
This commit is contained in:
@@ -6,6 +6,18 @@ project(CompileFeatures)
|
||||
|
||||
set(ext_C c)
|
||||
set(ext_CXX cpp)
|
||||
set(std_C 90 99 11 17 23)
|
||||
set(std_CXX 98 11 14 17 20 23)
|
||||
|
||||
foreach(lang C CXX)
|
||||
foreach(std IN LISTS std_${lang})
|
||||
string(TOLOWER "${lang}_std_${std}" feature)
|
||||
if(CMAKE_${lang}${std}_STANDARD_COMPILE_OPTION)
|
||||
add_library(test_${feature} OBJECT ${feature}.${ext_${lang}})
|
||||
target_compile_features(test_${feature} PRIVATE ${feature})
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
macro(run_test feature lang)
|
||||
if (${feature} IN_LIST CMAKE_${lang}_COMPILE_FEATURES)
|
||||
|
||||
5
Tests/CompileFeatures/c_std_11.c
Normal file
5
Tests/CompileFeatures/c_std_11.c
Normal file
@@ -0,0 +1,5 @@
|
||||
#include "c_std.h"
|
||||
#if defined(C_STD) && C_STD <= C_STD_99 && \
|
||||
!(defined(__SUNPRO_C) && __SUNPRO_C < 0x5140 && C_STD == C_STD_99)
|
||||
# error "c_std_11 not honored"
|
||||
#endif
|
||||
4
Tests/CompileFeatures/c_std_17.c
Normal file
4
Tests/CompileFeatures/c_std_17.c
Normal file
@@ -0,0 +1,4 @@
|
||||
#include "c_std.h"
|
||||
#if defined(C_STD) && C_STD <= C_STD_11
|
||||
# error "c_std_17 not honored"
|
||||
#endif
|
||||
6
Tests/CompileFeatures/c_std_23.c
Normal file
6
Tests/CompileFeatures/c_std_23.c
Normal file
@@ -0,0 +1,6 @@
|
||||
#include "c_std.h"
|
||||
#if defined(C_STD) && C_STD <= C_STD_17 && \
|
||||
!(C_STD == C_STD_17 && defined(__apple_build_version__) && \
|
||||
defined(__clang_major__) && __clang_major__ < 14)
|
||||
# error "c_std_23 not honored"
|
||||
#endif
|
||||
0
Tests/CompileFeatures/c_std_90.c
Normal file
0
Tests/CompileFeatures/c_std_90.c
Normal file
4
Tests/CompileFeatures/c_std_99.c
Normal file
4
Tests/CompileFeatures/c_std_99.c
Normal file
@@ -0,0 +1,4 @@
|
||||
#include "c_std.h"
|
||||
#if defined(C_STD) && C_STD < C_STD_99
|
||||
# error "c_std_99 not honored"
|
||||
#endif
|
||||
6
Tests/CompileFeatures/cxx_std_11.cpp
Normal file
6
Tests/CompileFeatures/cxx_std_11.cpp
Normal file
@@ -0,0 +1,6 @@
|
||||
#include "cxx_std.h"
|
||||
#if defined(CXX_STD) && CXX_STD < CXX_STD_11 && \
|
||||
!(CXX_STD == CXX_STD_98 && \
|
||||
(defined(__IBMCPP__) && defined(_AIX) && __IBMCPP__ == 1610))
|
||||
# error "cxx_std_11 not honored"
|
||||
#endif
|
||||
9
Tests/CompileFeatures/cxx_std_14.cpp
Normal file
9
Tests/CompileFeatures/cxx_std_14.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "cxx_std.h"
|
||||
#if defined(CXX_STD) && CXX_STD <= CXX_STD_11 && \
|
||||
!(CXX_STD == CXX_STD_11 && \
|
||||
((defined(__GNUC__) && defined(__GNUC_MINOR__) && __GNUC__ == 4 && \
|
||||
__GNUC_MINOR__ <= 8 && !defined(__clang__) && \
|
||||
!defined(__INTEL_COMPILER) && !defined(__PGI)) || \
|
||||
(defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5150)))
|
||||
# error "cxx_std_14 not honored"
|
||||
#endif
|
||||
4
Tests/CompileFeatures/cxx_std_17.cpp
Normal file
4
Tests/CompileFeatures/cxx_std_17.cpp
Normal file
@@ -0,0 +1,4 @@
|
||||
#include "cxx_std.h"
|
||||
#if defined(CXX_STD) && CXX_STD <= CXX_STD_14
|
||||
# error "cxx_std_17 not honored"
|
||||
#endif
|
||||
4
Tests/CompileFeatures/cxx_std_20.cpp
Normal file
4
Tests/CompileFeatures/cxx_std_20.cpp
Normal file
@@ -0,0 +1,4 @@
|
||||
#include "cxx_std.h"
|
||||
#if defined(CXX_STD) && CXX_STD <= CXX_STD_17
|
||||
# error "cxx_std_20 not honored"
|
||||
#endif
|
||||
4
Tests/CompileFeatures/cxx_std_23.cpp
Normal file
4
Tests/CompileFeatures/cxx_std_23.cpp
Normal file
@@ -0,0 +1,4 @@
|
||||
#include "cxx_std.h"
|
||||
#if defined(CXX_STD) && CXX_STD <= CXX_STD_20
|
||||
# error "cxx_std_23 not honored"
|
||||
#endif
|
||||
0
Tests/CompileFeatures/cxx_std_98.cpp
Normal file
0
Tests/CompileFeatures/cxx_std_98.cpp
Normal file
Reference in New Issue
Block a user