diff options
Diffstat (limited to 'Tests')
21 files changed, 209 insertions, 36 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index dea30e4..3aecd9b 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1247,6 +1247,9 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release if(CMake_TEST_FindGSL) add_subdirectory(FindGSL) endif() + if(CMake_TEST_FindJsonCpp) + add_subdirectory(FindJsonCpp) + endif() find_package(GTK2 QUIET) if(GTK2_FOUND) diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index 4308508..5cd0836 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -51,6 +51,25 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" ) endif() +if (CMAKE_CXX_COMPILER_ID STREQUAL SunPro) + list(REMOVE_ITEM CXX_non_features + cxx_attribute_deprecated + cxx_contextual_conversions + cxx_extended_friend_declarations + cxx_long_long_type + cxx_sizeof_member + cxx_variadic_macros + ) +endif() + +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" + AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6) + # The cxx_constexpr feature happens to work (for *this* testcase) with + # GNU 4.5, but it is first documented as available with GNU 4.6. + list(REMOVE_ITEM CXX_non_features + cxx_constexpr + ) +endif() if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) # The cxx_alignof feature happens to work (for *this* testcase) with @@ -142,20 +161,79 @@ if (CMAKE_CXX_COMPILE_FEATURES) add_executable(IfaceCompileFeatures main.cpp) target_link_libraries(IfaceCompileFeatures iface) - add_definitions(-DEXPECT_OVERRIDE_CONTROL=1) + if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) + add_definitions( + -DEXPECT_OVERRIDE_CONTROL=1 + -DEXPECT_INHERITING_CONSTRUCTORS=1 + -DEXPECT_FINAL=1 + -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=1 + ) + elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) + add_definitions( + -DEXPECT_OVERRIDE_CONTROL=1 + -DEXPECT_INHERITING_CONSTRUCTORS=0 + -DEXPECT_FINAL=1 + -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0 + ) + else() + add_definitions( + -DEXPECT_OVERRIDE_CONTROL=0 + -DEXPECT_INHERITING_CONSTRUCTORS=0 + -DEXPECT_FINAL=0 + -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0 + ) + endif() + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + add_definitions( + -DEXPECT_OVERRIDE_CONTROL=1 + -DEXPECT_INHERITING_CONSTRUCTORS=1 + -DEXPECT_FINAL=1 + -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=1 + ) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) + add_definitions( + -DEXPECT_OVERRIDE_CONTROL=1 + -DEXPECT_INHERITING_CONSTRUCTORS=1 + -DEXPECT_FINAL=1 + -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=1 + ) + else() + add_definitions( + -DEXPECT_OVERRIDE_CONTROL=1 + -DEXPECT_INHERITING_CONSTRUCTORS=0 + -DEXPECT_FINAL=1 + -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0 + ) + endif() + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro") + add_definitions( + -DEXPECT_OVERRIDE_CONTROL=1 + -DEXPECT_INHERITING_CONSTRUCTORS=1 + -DEXPECT_FINAL=1 + -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=1 + ) + endif() add_executable(CompileFeaturesGenex genex_test.cpp) set_property(TARGET CompileFeaturesGenex PROPERTY CXX_STANDARD 11) target_compile_definitions(CompileFeaturesGenex PRIVATE HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override> - HAVE_NULLPTR=$<COMPILE_FEATURES:cxx_nullptr> + HAVE_AUTO_TYPE=$<COMPILE_FEATURES:cxx_auto_type> + HAVE_INHERITING_CONSTRUCTORS=$<COMPILE_FEATURES:cxx_inheriting_constructors> + HAVE_FINAL=$<COMPILE_FEATURES:cxx_final> + HAVE_INHERITING_CONSTRUCTORS_AND_FINAL=$<COMPILE_FEATURES:cxx_inheriting_constructors,cxx_final> ) add_executable(CompileFeaturesGenex2 genex_test.cpp) target_compile_features(CompileFeaturesGenex2 PRIVATE cxx_static_assert) target_compile_definitions(CompileFeaturesGenex2 PRIVATE HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override> - HAVE_NULLPTR=$<COMPILE_FEATURES:cxx_nullptr> + HAVE_AUTO_TYPE=$<COMPILE_FEATURES:cxx_auto_type> + HAVE_INHERITING_CONSTRUCTORS=$<COMPILE_FEATURES:cxx_inheriting_constructors> + HAVE_FINAL=$<COMPILE_FEATURES:cxx_final> + HAVE_INHERITING_CONSTRUCTORS_AND_FINAL=$<COMPILE_FEATURES:cxx_inheriting_constructors,cxx_final> ) add_library(static_assert_iface INTERFACE) @@ -164,6 +242,9 @@ if (CMAKE_CXX_COMPILE_FEATURES) target_link_libraries(CompileFeaturesGenex3 PRIVATE static_assert_iface) target_compile_definitions(CompileFeaturesGenex3 PRIVATE HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override> - HAVE_NULLPTR=$<COMPILE_FEATURES:cxx_nullptr> + HAVE_AUTO_TYPE=$<COMPILE_FEATURES:cxx_auto_type> + HAVE_INHERITING_CONSTRUCTORS=$<COMPILE_FEATURES:cxx_inheriting_constructors> + HAVE_FINAL=$<COMPILE_FEATURES:cxx_final> + HAVE_INHERITING_CONSTRUCTORS_AND_FINAL=$<COMPILE_FEATURES:cxx_inheriting_constructors,cxx_final> ) endif() diff --git a/Tests/CompileFeatures/cxx_auto_type.cpp b/Tests/CompileFeatures/cxx_auto_type.cpp index 7dbf04f..1f36a79 100644 --- a/Tests/CompileFeatures/cxx_auto_type.cpp +++ b/Tests/CompileFeatures/cxx_auto_type.cpp @@ -1,5 +1,12 @@ +double foo_ = 3.14; + +double& foo() +{ + return foo_; +} + void someFunc() { - auto x = 3.14; + auto& x = foo(); } diff --git a/Tests/CompileFeatures/cxx_generalized_initializers.cpp b/Tests/CompileFeatures/cxx_generalized_initializers.cpp index 8013ef5..7bf356b 100644 --- a/Tests/CompileFeatures/cxx_generalized_initializers.cpp +++ b/Tests/CompileFeatures/cxx_generalized_initializers.cpp @@ -8,6 +8,7 @@ namespace std { const _E* __begin_; size_t __size_; + initializer_list(const int*, long unsigned int) {} }; } diff --git a/Tests/CompileFeatures/cxx_inheriting_constructors.cpp b/Tests/CompileFeatures/cxx_inheriting_constructors.cpp index a83b624..cfce880 100644 --- a/Tests/CompileFeatures/cxx_inheriting_constructors.cpp +++ b/Tests/CompileFeatures/cxx_inheriting_constructors.cpp @@ -13,6 +13,6 @@ struct B : public A void someFunc() { - int i; + int i = 0; B b(i); } diff --git a/Tests/CompileFeatures/cxx_variadic_templates.cpp b/Tests/CompileFeatures/cxx_variadic_templates.cpp index 1d5a706..e1f641b 100644 --- a/Tests/CompileFeatures/cxx_variadic_templates.cpp +++ b/Tests/CompileFeatures/cxx_variadic_templates.cpp @@ -1,21 +1,30 @@ -template<int I, int... Is> +#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) < 407) +#define OLD_GNU +#endif + +#ifdef OLD_GNU +template<int... Is> struct Interface; +#endif -template<int I> -struct Interface<I> +template<int I, int... Is> +struct Interface +#ifdef OLD_GNU + <I, Is...> +#endif { static int accumulate() { - return I; + return I + Interface<Is...>::accumulate(); } }; -template<int I, int... Is> -struct Interface +template<int I> +struct Interface<I> { static int accumulate() { - return I + Interface<Is...>::accumulate(); + return I; } }; diff --git a/Tests/CompileFeatures/default_dialect.cpp b/Tests/CompileFeatures/default_dialect.cpp index 8d97926..a2ca268 100644 --- a/Tests/CompileFeatures/default_dialect.cpp +++ b/Tests/CompileFeatures/default_dialect.cpp @@ -14,7 +14,7 @@ Outputter<__cplusplus> o; # if !DEFAULT_CXX98 # error Buildsystem error # endif -# if __cplusplus != 199711L +# if __cplusplus != 199711L && __cplusplus != 1 && !defined(__GXX_EXPERIMENTAL_CXX0X__) Outputter<__cplusplus> o; # endif #endif diff --git a/Tests/CompileFeatures/genex_test.cpp b/Tests/CompileFeatures/genex_test.cpp index f667cc4..d9c8eec 100644 --- a/Tests/CompileFeatures/genex_test.cpp +++ b/Tests/CompileFeatures/genex_test.cpp @@ -17,15 +17,38 @@ struct B final : A #endif -#if !HAVE_NULLPTR -#error "Expect nullptr feature" +#if !HAVE_AUTO_TYPE +# error Expect cxx_auto_type support +#endif + +#if !HAVE_INHERITING_CONSTRUCTORS +# if EXPECT_INHERITING_CONSTRUCTORS +# error Expect cxx_inheriting_constructors support +# endif #else +# if !EXPECT_INHERITING_CONSTRUCTORS +# error Expect no cxx_inheriting_constructors support +# endif +#endif -const char* getString() -{ - return nullptr; -} +#if !HAVE_FINAL +# if EXPECT_FINAL +# error Expect cxx_final support +# endif +#else +# if !EXPECT_FINAL +# error Expect no cxx_final support +# endif +#endif +#if !HAVE_INHERITING_CONSTRUCTORS_AND_FINAL +# if EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL +# error Expect cxx_inheriting_constructors and cxx_final support +# endif +#else +# if !EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL +# error Expect no combined cxx_inheriting_constructors and cxx_final support +# endif #endif int main() diff --git a/Tests/FindJsonCpp/CMakeLists.txt b/Tests/FindJsonCpp/CMakeLists.txt new file mode 100644 index 0000000..9a1fa38 --- /dev/null +++ b/Tests/FindJsonCpp/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindJsonCpp.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindJsonCpp/Test" + "${CMake_BINARY_DIR}/Tests/FindJsonCpp/Test" + ${build_generator_args} + --build-project TestFindJsonCpp + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindJsonCpp/Test/CMakeLists.txt b/Tests/FindJsonCpp/Test/CMakeLists.txt new file mode 100644 index 0000000..4e1e271 --- /dev/null +++ b/Tests/FindJsonCpp/Test/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.1) +project(TestFindJsonCpp CXX) +include(CTest) + +find_package(JsonCpp REQUIRED) + +add_executable(test_jsoncpp_tgt main.cxx) +target_link_libraries(test_jsoncpp_tgt JsonCpp::JsonCpp) +add_test(NAME test_jsoncpp_tgt COMMAND test_jsoncpp_tgt) + +add_executable(test_jsoncpp_var main.cxx) +target_include_directories(test_jsoncpp_var PRIVATE ${JsonCpp_INCLUDE_DIRS}) +target_link_libraries(test_jsoncpp_var PRIVATE ${JsonCpp_LIBRARIES}) +add_test(NAME test_jsoncpp_var COMMAND test_jsoncpp_var) diff --git a/Tests/FindJsonCpp/Test/main.cxx b/Tests/FindJsonCpp/Test/main.cxx new file mode 100644 index 0000000..0fefe32 --- /dev/null +++ b/Tests/FindJsonCpp/Test/main.cxx @@ -0,0 +1,8 @@ +#include <json/json.h> + +int main() +{ + int zero = 0; + Json::Value value(zero); + return value.asInt(); +} diff --git a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt index 401de95..b5e46c0 100644 --- a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt +++ b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt @@ -11,7 +11,7 @@ get_property(c_known_features GLOBAL PROPERTY CMAKE_C_KNOWN_FEATURES) write_compiler_detection_header( FILE "${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection.h" PREFIX TEST - COMPILERS GNU Clang AppleClang + COMPILERS GNU Clang AppleClang SunPro VERSION 3.1 PROLOG "// something" EPILOG "// more" @@ -25,12 +25,14 @@ if (NOT CMAKE_CXX_COMPILE_FEATURES AND NOT CMAKE_C_COMPILE_FEATURES) ) add_executable(WriteCompilerDetectionHeader "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp") - include(CheckCXXSourceCompiles) - check_cxx_source_compiles("#include \"${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection.h\"\nint main() { return 0; }\n" - file_include_works - ) - if (file_include_works) - message(SEND_ERROR "Inclusion of ${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection.h was expected to cause an error, but did not.") + if(UNIX OR NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + include(CheckCXXSourceCompiles) + check_cxx_source_compiles("#include \"${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection.h\"\nint main() { return 0; }\n" + file_include_works + ) + if (file_include_works) + message(SEND_ERROR "Inclusion of ${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection.h was expected to cause an error, but did not.") + endif() endif() return() endif() @@ -58,7 +60,8 @@ endmacro() if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" - OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" + OR CMAKE_CXX_COMPILER_ID STREQUAL "SunPro") # False for C++98 mode. list(APPEND false_defs EXPECTED_COMPILER_CXX_DELEGATING_CONSTRUCTORS) list(APPEND false_defs EXPECTED_COMPILER_CXX_VARIADIC_TEMPLATES) @@ -81,7 +84,7 @@ write_compiler_detection_header( PREFIX MULTI OUTPUT_FILES_VAR multi_files OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/compiler_multi_files/compiler_support" - COMPILERS GNU Clang AppleClang + COMPILERS GNU Clang AppleClang SunPro VERSION 3.1 FEATURES ${cxx_known_features} ${c_known_features} diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-mtime1-result.txt b/Tests/RunCMake/CommandLine/E_tar-bad-mtime1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_tar-bad-mtime1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-mtime1-stderr.txt b/Tests/RunCMake/CommandLine/E_tar-bad-mtime1-stderr.txt new file mode 100644 index 0000000..ca925f1 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_tar-bad-mtime1-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: unable to parse mtime 'bad' +CMake Error: Problem creating tar: bad.tar$ diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-opt1-result.txt b/Tests/RunCMake/CommandLine/E_tar-bad-opt1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_tar-bad-opt1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_tar-bad-opt1-stderr.txt b/Tests/RunCMake/CommandLine/E_tar-bad-opt1-stderr.txt new file mode 100644 index 0000000..35133c8 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_tar-bad-opt1-stderr.txt @@ -0,0 +1 @@ +^CMake Error: Unknown option to -E tar: --bad$ diff --git a/Tests/RunCMake/CommandLine/E_tar-end-opt1-result.txt b/Tests/RunCMake/CommandLine/E_tar-end-opt1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_tar-end-opt1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_tar-end-opt1-stderr.txt b/Tests/RunCMake/CommandLine/E_tar-end-opt1-stderr.txt new file mode 100644 index 0000000..1fddf6d --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_tar-end-opt1-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: archive_read_disk_entry_from_file '--bad':.* +CMake Error: Problem creating tar: bad.tar$ diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index 0c43c20..2994f16 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -1,5 +1,11 @@ include(RunCMake) +run_cmake_command(E_tar-bad-opt1 ${CMAKE_COMMAND} -E tar cvf bad.tar --bad) +run_cmake_command(E_tar-bad-mtime1 ${CMAKE_COMMAND} -E tar cvf bad.tar --mtime=bad .) +run_cmake_command(E_tar-end-opt1 ${CMAKE_COMMAND} -E tar cvf bad.tar -- --bad) +run_cmake_command(E_tar-end-opt2 ${CMAKE_COMMAND} -E tar cvf bad.tar --) +run_cmake_command(E_tar-mtime ${CMAKE_COMMAND} -E tar cvf bad.tar "--mtime=1970-01-01 00:00:00 UTC") + run_cmake_command(build-no-cache ${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}) run_cmake_command(build-no-generator diff --git a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake index 9d56bc0..09594bd 100644 --- a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake +++ b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake @@ -3,13 +3,13 @@ add_library(empty1 empty.cpp) add_library(empty2 INTERFACE) add_library(empty3 INTERFACE) -target_compile_features(empty3 INTERFACE cxx_constexpr) +target_compile_features(empty3 INTERFACE cxx_static_assert) target_link_libraries(empty1 - # When starting, $<COMPILE_FEATURES:cxx_final> is '0', so 'freeze' the + # When starting, $<COMPILE_FEATURES:cxx_auto_type> is '0', so 'freeze' the # CXX_STANDARD at 98 during computation. - $<$<COMPILE_FEATURES:cxx_final>:empty2> - # This would add cxx_constexpr, but that would require CXX_STANDARD = 11, + $<$<COMPILE_FEATURES:cxx_auto_type>:empty2> + # This would add cxx_static_assert, but that would require CXX_STANDARD = 11, # which is not allowed after freeze. Report an error. empty3 ) diff --git a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved.cmake b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved.cmake index 0df548b..bbcf4e0 100644 --- a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved.cmake +++ b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved.cmake @@ -3,12 +3,12 @@ add_library(empty1 empty.cpp) add_library(empty2 INTERFACE) add_library(empty3 INTERFACE) -target_compile_features(empty3 INTERFACE cxx_constexpr) +target_compile_features(empty3 INTERFACE cxx_static_assert) target_link_libraries(empty1 - $<$<COMPILE_FEATURES:cxx_final>:empty2> + $<$<COMPILE_FEATURES:cxx_nullptr>:empty2> empty3 ) # This, or populating the COMPILE_FEATURES property with a feature in the -# same standard as cxx_final, solves the cycle above. +# same standard as cxx_nullptr, solves the cycle above. set_property(TARGET empty1 PROPERTY CXX_STANDARD 11) |