diff options
author | Stephen Kelly <steveire@gmail.com> | 2013-11-04 00:15:43 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2014-05-14 22:15:18 (GMT) |
commit | e0890d03a48d12904ffe24aa94fb2847d8d5f4e7 (patch) | |
tree | 820631dcc5cd8c95111dbfa7d33e1a59d554f8a4 /Tests/RunCMake | |
parent | 775458dede98d28fe81ac878541a6ead735443fc (diff) | |
download | CMake-e0890d03a48d12904ffe24aa94fb2847d8d5f4e7.zip CMake-e0890d03a48d12904ffe24aa94fb2847d8d5f4e7.tar.gz CMake-e0890d03a48d12904ffe24aa94fb2847d8d5f4e7.tar.bz2 |
Features: Extend concept to C language.
Add properties and variables corresponding to CXX equivalents.
Add features for c_function_prototypes (C90), c_restrict (C99),
c_variadic_macros (C99) and c_static_assert (C11). This feature
set can be extended later.
Add a <PREFIX>_RESTRICT symbol define to WriteCompilerDetectionHeader
to conditionally represent the c_restrict feature.
Diffstat (limited to 'Tests/RunCMake')
18 files changed, 94 insertions, 1 deletions
diff --git a/Tests/RunCMake/CompileFeatures/NoSupportedCFeatures-result.txt b/Tests/RunCMake/CompileFeatures/NoSupportedCFeatures-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NoSupportedCFeatures-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompileFeatures/NoSupportedCFeatures-stderr.txt b/Tests/RunCMake/CompileFeatures/NoSupportedCFeatures-stderr.txt new file mode 100644 index 0000000..fd18c88 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NoSupportedCFeatures-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at NoSupportedCFeatures.cmake:[0-9]+ \(target_compile_features\): + target_compile_features no known features for C compiler + + "[^"]*" + + version *[.0-9]+\. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CompileFeatures/NoSupportedCFeatures.cmake b/Tests/RunCMake/CompileFeatures/NoSupportedCFeatures.cmake new file mode 100644 index 0000000..3624d4b --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NoSupportedCFeatures.cmake @@ -0,0 +1,5 @@ + +enable_language(C) + +add_library(no_features empty.c) +target_compile_features(no_features PRIVATE c_static_assert) diff --git a/Tests/RunCMake/CompileFeatures/NoSupportedCFeaturesGenex-result.txt b/Tests/RunCMake/CompileFeatures/NoSupportedCFeaturesGenex-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NoSupportedCFeaturesGenex-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompileFeatures/NoSupportedCFeaturesGenex-stderr.txt b/Tests/RunCMake/CompileFeatures/NoSupportedCFeaturesGenex-stderr.txt new file mode 100644 index 0000000..df647e8 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NoSupportedCFeaturesGenex-stderr.txt @@ -0,0 +1,6 @@ +CMake Error in CMakeLists.txt: + No known features for C compiler + + "[^"]*" + + version *[.0-9]+\. diff --git a/Tests/RunCMake/CompileFeatures/NoSupportedCFeaturesGenex.cmake b/Tests/RunCMake/CompileFeatures/NoSupportedCFeaturesGenex.cmake new file mode 100644 index 0000000..b6053aa --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NoSupportedCFeaturesGenex.cmake @@ -0,0 +1,5 @@ + +enable_language(C) + +add_library(no_features empty.c) +target_compile_features(no_features PRIVATE $<1:c_static_assert>) diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake index bb4e0f9..a23d44f 100644 --- a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake @@ -10,10 +10,19 @@ run_cmake(NotAFeature_OriginDebug_target_compile_features) run_cmake(generate_feature_list) file(READ + "${RunCMake_BINARY_DIR}/generate_feature_list-build/c_features.txt" + C_FEATURES +) +file(READ "${RunCMake_BINARY_DIR}/generate_feature_list-build/cxx_features.txt" CXX_FEATURES ) +if (NOT C_FEATURES) + run_cmake(NoSupportedCFeatures) + run_cmake(NoSupportedCFeaturesGenex) +endif() + if (NOT CXX_FEATURES) run_cmake(NoSupportedCxxFeatures) run_cmake(NoSupportedCxxFeaturesGenex) diff --git a/Tests/RunCMake/CompileFeatures/empty.c b/Tests/RunCMake/CompileFeatures/empty.c new file mode 100644 index 0000000..bfbbdde --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/empty.c @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake b/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake index beb15fc..09e17b1 100644 --- a/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake +++ b/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake @@ -1,4 +1,10 @@ +enable_language(C) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/c_features.txt" + "${CMAKE_C_COMPILE_FEATURES}" +) + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cxx_features.txt" "${CMAKE_CXX_COMPILE_FEATURES}" ) diff --git a/Tests/RunCMake/Configure/FailCopyFileABI-stdout.txt b/Tests/RunCMake/Configure/FailCopyFileABI-stdout.txt index bb87f4c..92fe233 100644 --- a/Tests/RunCMake/Configure/FailCopyFileABI-stdout.txt +++ b/Tests/RunCMake/Configure/FailCopyFileABI-stdout.txt @@ -1,4 +1,4 @@ -- Detecting C compiler ABI info --- Detecting C compiler ABI info - failed +-- Detecting C compiler ABI info - failed.* -- Configuring done -- Generating done diff --git a/Tests/RunCMake/target_compile_features/RunCMakeTest.cmake b/Tests/RunCMake/target_compile_features/RunCMakeTest.cmake index f2abef7..33faf2b 100644 --- a/Tests/RunCMake/target_compile_features/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_compile_features/RunCMakeTest.cmake @@ -9,3 +9,5 @@ run_cmake(imported_target) run_cmake(no_target) run_cmake(not_a_cxx_feature) run_cmake(no_matching_cxx_feature) +run_cmake(not_a_c_feature) +run_cmake(no_matching_c_feature) diff --git a/Tests/RunCMake/target_compile_features/empty.c b/Tests/RunCMake/target_compile_features/empty.c new file mode 100644 index 0000000..bfbbdde --- /dev/null +++ b/Tests/RunCMake/target_compile_features/empty.c @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/target_compile_features/no_matching_c_feature-result.txt b/Tests/RunCMake/target_compile_features/no_matching_c_feature-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_compile_features/no_matching_c_feature-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_compile_features/no_matching_c_feature-stderr.txt b/Tests/RunCMake/target_compile_features/no_matching_c_feature-stderr.txt new file mode 100644 index 0000000..96b959c --- /dev/null +++ b/Tests/RunCMake/target_compile_features/no_matching_c_feature-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at no_matching_c_feature.cmake:[0-9][0-9]? \((target_compile_features|message)\): + The compiler feature "gnu_c_dummy" is not known to C compiler + + "GNU" + + version 4.8.1. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_compile_features/no_matching_c_feature.cmake b/Tests/RunCMake/target_compile_features/no_matching_c_feature.cmake new file mode 100644 index 0000000..a44caf2 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/no_matching_c_feature.cmake @@ -0,0 +1,15 @@ + +if (NOT ";${CMAKE_C_COMPILE_FEATURES};" MATCHES ";gnu_c_typeof;") + # Simulate passing the test. + message(SEND_ERROR + "The compiler feature \"gnu_c_dummy\" is not known to C compiler\n\"GNU\"\nversion 4.8.1." + ) + return() +endif() + +add_executable(main empty.c) + +target_compile_features(main + PRIVATE + gnu_c_typeof +) diff --git a/Tests/RunCMake/target_compile_features/not_a_c_feature-result.txt b/Tests/RunCMake/target_compile_features/not_a_c_feature-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_compile_features/not_a_c_feature-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_compile_features/not_a_c_feature-stderr.txt b/Tests/RunCMake/target_compile_features/not_a_c_feature-stderr.txt new file mode 100644 index 0000000..6dd00f3 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/not_a_c_feature-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at not_a_c_feature.cmake:3 \(target_compile_features\): + target_compile_features specified unknown feature "c_not_a_feature" for + target "main". +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_compile_features/not_a_c_feature.cmake b/Tests/RunCMake/target_compile_features/not_a_c_feature.cmake new file mode 100644 index 0000000..0420698 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/not_a_c_feature.cmake @@ -0,0 +1,6 @@ + +add_executable(main empty.c) +target_compile_features(main + PRIVATE + c_not_a_feature +) |