diff options
Diffstat (limited to 'Tests/RunCMake/target_compile_features')
41 files changed, 203 insertions, 0 deletions
diff --git a/Tests/RunCMake/target_compile_features/CMakeLists.txt b/Tests/RunCMake/target_compile_features/CMakeLists.txt new file mode 100644 index 0000000..2897109 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.0) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/target_compile_features/RunCMakeTest.cmake b/Tests/RunCMake/target_compile_features/RunCMakeTest.cmake new file mode 100644 index 0000000..f8b0809 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/RunCMakeTest.cmake @@ -0,0 +1,15 @@ +include(RunCMake) + +run_cmake(not_enough_args) +run_cmake(alias_target) +run_cmake(utility_target) +run_cmake(invalid_args) +run_cmake(invalid_args_on_interface) +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) +run_cmake(cxx_not_enabled) +run_cmake(empty_keyword_args) diff --git a/Tests/RunCMake/target_compile_features/alias_target-result.txt b/Tests/RunCMake/target_compile_features/alias_target-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_compile_features/alias_target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_compile_features/alias_target-stderr.txt b/Tests/RunCMake/target_compile_features/alias_target-stderr.txt new file mode 100644 index 0000000..1658f58 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/alias_target-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at alias_target.cmake:[0-9]+ \(target_compile_features\): + target_compile_features can not be used on an ALIAS target. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_compile_features/alias_target.cmake b/Tests/RunCMake/target_compile_features/alias_target.cmake new file mode 100644 index 0000000..6fcdada --- /dev/null +++ b/Tests/RunCMake/target_compile_features/alias_target.cmake @@ -0,0 +1,5 @@ +enable_language(CXX) + +add_executable(main empty.cpp) +add_executable(Alias::Main ALIAS main) +target_compile_features(Alias::Main PRIVATE cxx_delegating_constructors) diff --git a/Tests/RunCMake/target_compile_features/cxx_not_enabled-result.txt b/Tests/RunCMake/target_compile_features/cxx_not_enabled-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_compile_features/cxx_not_enabled-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_compile_features/cxx_not_enabled-stderr.txt b/Tests/RunCMake/target_compile_features/cxx_not_enabled-stderr.txt new file mode 100644 index 0000000..5b4761c --- /dev/null +++ b/Tests/RunCMake/target_compile_features/cxx_not_enabled-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at cxx_not_enabled.cmake:[0-9]+ \(target_compile_features\): + target_compile_features cannot use features from non-enabled language CXX +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_compile_features/cxx_not_enabled.cmake b/Tests/RunCMake/target_compile_features/cxx_not_enabled.cmake new file mode 100644 index 0000000..b7e9119 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/cxx_not_enabled.cmake @@ -0,0 +1,2 @@ +add_executable(main empty.c) +target_compile_features(main PRIVATE cxx_decltype) diff --git a/Tests/RunCMake/target_compile_features/empty.c b/Tests/RunCMake/target_compile_features/empty.c new file mode 100644 index 0000000..11ec041 --- /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/empty.cpp b/Tests/RunCMake/target_compile_features/empty.cpp new file mode 100644 index 0000000..11ec041 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/empty.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/target_compile_features/empty_keyword_args.cmake b/Tests/RunCMake/target_compile_features/empty_keyword_args.cmake new file mode 100644 index 0000000..8d57c1c --- /dev/null +++ b/Tests/RunCMake/target_compile_features/empty_keyword_args.cmake @@ -0,0 +1,5 @@ +add_library(iface INTERFACE) +target_compile_features(iface PUBLIC PRIVATE INTERFACE) +# Cannot be called with non-compilable targets. +#add_library(imported UNKNOWN IMPORTED) +#target_compile_features(imported PUBLIC PRIVATE INTERFACE) diff --git a/Tests/RunCMake/target_compile_features/imported_target-result.txt b/Tests/RunCMake/target_compile_features/imported_target-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_compile_features/imported_target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_compile_features/imported_target-stderr.txt b/Tests/RunCMake/target_compile_features/imported_target-stderr.txt new file mode 100644 index 0000000..f2a1aba --- /dev/null +++ b/Tests/RunCMake/target_compile_features/imported_target-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at imported_target.cmake:[0-9]+ \(target_compile_features\): + target_compile_features may only set INTERFACE properties on INTERFACE + targets +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_compile_features/imported_target.cmake b/Tests/RunCMake/target_compile_features/imported_target.cmake new file mode 100644 index 0000000..e410ace --- /dev/null +++ b/Tests/RunCMake/target_compile_features/imported_target.cmake @@ -0,0 +1,10 @@ +enable_language(CXX) + +add_library(lib1-interface INTERFACE IMPORTED) +target_compile_features(lib1-interface INTERFACE cxx_delegating_constructors) + +add_library(lib2-interface INTERFACE IMPORTED) +target_compile_features(lib2-interface PUBLIC cxx_delegating_constructors) + +add_library(lib-shared SHARED IMPORTED) +target_compile_features(lib-shared INTERFACE cxx_delegating_constructors) diff --git a/Tests/RunCMake/target_compile_features/invalid_args-result.txt b/Tests/RunCMake/target_compile_features/invalid_args-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_compile_features/invalid_args-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_compile_features/invalid_args-stderr.txt b/Tests/RunCMake/target_compile_features/invalid_args-stderr.txt new file mode 100644 index 0000000..ee57b54 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/invalid_args-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at invalid_args.cmake:[0-9]+ \(target_compile_features\): + target_compile_features called with invalid arguments +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_compile_features/invalid_args.cmake b/Tests/RunCMake/target_compile_features/invalid_args.cmake new file mode 100644 index 0000000..cc051a4 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/invalid_args.cmake @@ -0,0 +1,4 @@ +enable_language(CXX) + +add_executable(main empty.cpp) +target_compile_features(main INVALID cxx_delegating_constructors) diff --git a/Tests/RunCMake/target_compile_features/invalid_args_on_interface-result.txt b/Tests/RunCMake/target_compile_features/invalid_args_on_interface-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_compile_features/invalid_args_on_interface-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_compile_features/invalid_args_on_interface-stderr.txt b/Tests/RunCMake/target_compile_features/invalid_args_on_interface-stderr.txt new file mode 100644 index 0000000..d6564f4 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/invalid_args_on_interface-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at invalid_args_on_interface.cmake:[0-9]+ \(target_compile_features\): + target_compile_features may only set INTERFACE properties on INTERFACE + targets +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_compile_features/invalid_args_on_interface.cmake b/Tests/RunCMake/target_compile_features/invalid_args_on_interface.cmake new file mode 100644 index 0000000..49d2d82 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/invalid_args_on_interface.cmake @@ -0,0 +1,4 @@ +enable_language(CXX) + +add_library(main INTERFACE) +target_compile_features(main PRIVATE cxx_delegating_constructors) 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..07ddd6a --- /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]+ \((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:[0-9]+ \(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..0e93b41 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/no_matching_c_feature.cmake @@ -0,0 +1,16 @@ +enable_language(CXX) + +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/no_matching_cxx_feature-result.txt b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-stderr.txt b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-stderr.txt new file mode 100644 index 0000000..9392f4b --- /dev/null +++ b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at no_matching_cxx_feature.cmake:[0-9]+ \((target_compile_features|message)\): + The compiler feature "[^"]+" is not known to CXX compiler + + "[^"]*" + + version *[.0-9]+\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_compile_features/no_matching_cxx_feature.cmake b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature.cmake new file mode 100644 index 0000000..4ee3445 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature.cmake @@ -0,0 +1,27 @@ +enable_language(CXX) + +if (NOT ";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";gnu_cxx_typeof;" + AND NOT ";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";msvc_cxx_sealed;" ) + # Simulate passing the test. + message(SEND_ERROR + "The compiler feature \"gnu_cxx_dummy\" is not known to CXX compiler\n\"GNU\"\nversion 4.8.1." + ) + return() +endif() + +if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";gnu_cxx_typeof;") + set(feature msvc_cxx_sealed) + if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";msvc_cxx_sealed;") + # If a compiler supports both extensions, remove one of them. + list(REMOVE_ITEM CMAKE_CXX_COMPILE_FEATURES msvc_cxx_sealed) + endif() +else() + set(feature gnu_cxx_typeof) +endif() + +add_executable(main empty.cpp) + +target_compile_features(main + PRIVATE + ${feature} +) diff --git a/Tests/RunCMake/target_compile_features/no_target-result.txt b/Tests/RunCMake/target_compile_features/no_target-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_compile_features/no_target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_compile_features/no_target-stderr.txt b/Tests/RunCMake/target_compile_features/no_target-stderr.txt new file mode 100644 index 0000000..7b62c94 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/no_target-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at no_target.cmake:[0-9]+ \(target_compile_features\): + Cannot specify compile features for target "main" which is not built by + this project. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_compile_features/no_target.cmake b/Tests/RunCMake/target_compile_features/no_target.cmake new file mode 100644 index 0000000..a514de8 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/no_target.cmake @@ -0,0 +1,3 @@ +enable_language(CXX) + +target_compile_features(main INTERFACE cxx_delegating_constructors) 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..8a4055d --- /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:[0-9]+ \(target_compile_features\): + target_compile_features specified unknown feature "c_not_a_feature" for + target "main". +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(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..f5d70d0 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/not_a_c_feature.cmake @@ -0,0 +1,7 @@ +enable_language(C) + +add_executable(main empty.c) +target_compile_features(main + PRIVATE + c_not_a_feature +) diff --git a/Tests/RunCMake/target_compile_features/not_a_cxx_feature-result.txt b/Tests/RunCMake/target_compile_features/not_a_cxx_feature-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_compile_features/not_a_cxx_feature-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_compile_features/not_a_cxx_feature-stderr.txt b/Tests/RunCMake/target_compile_features/not_a_cxx_feature-stderr.txt new file mode 100644 index 0000000..bd7f2c6 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/not_a_cxx_feature-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at not_a_cxx_feature.cmake:[0-9]+ \(target_compile_features\): + target_compile_features specified unknown feature "cxx_not_a_feature" for + target "main". +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_compile_features/not_a_cxx_feature.cmake b/Tests/RunCMake/target_compile_features/not_a_cxx_feature.cmake new file mode 100644 index 0000000..bc3a8c4 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/not_a_cxx_feature.cmake @@ -0,0 +1,7 @@ +enable_language(CXX) + +add_executable(main empty.cpp) +target_compile_features(main + PRIVATE + cxx_not_a_feature +) diff --git a/Tests/RunCMake/target_compile_features/not_enough_args-result.txt b/Tests/RunCMake/target_compile_features/not_enough_args-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_compile_features/not_enough_args-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_compile_features/not_enough_args-stderr.txt b/Tests/RunCMake/target_compile_features/not_enough_args-stderr.txt new file mode 100644 index 0000000..34f1ce2 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/not_enough_args-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at not_enough_args.cmake:[0-9]+ \(target_compile_features\): + target_compile_features called with incorrect number of arguments +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_compile_features/not_enough_args.cmake b/Tests/RunCMake/target_compile_features/not_enough_args.cmake new file mode 100644 index 0000000..f5b7198 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/not_enough_args.cmake @@ -0,0 +1,4 @@ +enable_language(CXX) + +add_executable(main empty.cpp) +target_compile_features(main) diff --git a/Tests/RunCMake/target_compile_features/utility_target-result.txt b/Tests/RunCMake/target_compile_features/utility_target-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_compile_features/utility_target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_compile_features/utility_target-stderr.txt b/Tests/RunCMake/target_compile_features/utility_target-stderr.txt new file mode 100644 index 0000000..0c01377 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/utility_target-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at utility_target.cmake:[0-9]+ \(target_compile_features\): + target_compile_features called with non-compilable target type +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_compile_features/utility_target.cmake b/Tests/RunCMake/target_compile_features/utility_target.cmake new file mode 100644 index 0000000..8919056 --- /dev/null +++ b/Tests/RunCMake/target_compile_features/utility_target.cmake @@ -0,0 +1,4 @@ + +add_custom_target(utility) + +target_compile_features(utility PRIVATE cxx_delegating_constructors) |