diff options
Diffstat (limited to 'Tests')
31 files changed, 300 insertions, 70 deletions
diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index ff5d745..9fb8d1b 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.1) project(CompileFeatures) @@ -26,18 +26,31 @@ get_property(c_features GLOBAL PROPERTY CMAKE_C_KNOWN_FEATURES) foreach(feature ${c_features}) run_test(${feature} C) endforeach() + get_property(cxx_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES) + +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + list(REMOVE_ITEM cxx_features + # This test requires auto return type deduction to work properly, but + # that is not supported by all versions of MSVC that support decltype + # incomplete return types. + cxx_decltype_incomplete_return_types + ) +endif() + foreach(feature ${cxx_features}) run_test(${feature} CXX) endforeach() -if (CMAKE_CXX_COMPILER_ID STREQUAL GNU +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 + # GNU 4.7, but it is first documented as available with GNU 4.8. list(REMOVE_ITEM CXX_non_features cxx_alignof ) endif() -if (CMAKE_CXX_COMPILER_ID STREQUAL GNU +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9) # GNU prior to 4.9 does not set any preprocessor define to distinguish # c++1y from c++11, so CMake does not support c++1y features before GNU 4.9. @@ -51,6 +64,17 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL GNU ) endif() +set(MSVC_) +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND + MSVC_VERSION LESS 1800) + list(REMOVE_ITEM CXX_non_features + # Microsoft only officially supports this feature in VS2013 and above, due + # to new wording of the proposal. We don't test for this with MSVC because + # older compiler pass the test but might not actually conform + cxx_contextual_conversions + ) +endif() + set(C_ext c) set(C_standard_flag 11) set(CXX_ext cpp) @@ -120,17 +144,29 @@ if (CMAKE_CXX_COMPILE_FEATURES) add_executable(IfaceCompileFeatures main.cpp) target_link_libraries(IfaceCompileFeatures iface) + add_definitions(-DEXPECT_OVERRIDE_CONTROL=1) + 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>) + + target_compile_definitions(CompileFeaturesGenex PRIVATE + HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override> + HAVE_NULLPTR=$<COMPILE_FEATURES:cxx_nullptr> + ) add_executable(CompileFeaturesGenex2 genex_test.cpp) - target_compile_features(CompileFeaturesGenex2 PRIVATE cxx_constexpr) - target_compile_definitions(CompileFeaturesGenex2 PRIVATE HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>) + 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> + ) - add_library(noexcept_iface INTERFACE) - target_compile_features(noexcept_iface INTERFACE cxx_noexcept) + add_library(static_assert_iface INTERFACE) + target_compile_features(static_assert_iface INTERFACE cxx_static_assert) add_executable(CompileFeaturesGenex3 genex_test.cpp) - target_link_libraries(CompileFeaturesGenex3 PRIVATE noexcept_iface) - target_compile_definitions(CompileFeaturesGenex3 PRIVATE HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>) + 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> + ) endif() diff --git a/Tests/CompileFeatures/genex_test.cpp b/Tests/CompileFeatures/genex_test.cpp index ca38883..4412569 100644 --- a/Tests/CompileFeatures/genex_test.cpp +++ b/Tests/CompileFeatures/genex_test.cpp @@ -1,6 +1,8 @@ #if !HAVE_OVERRIDE_CONTROL +#if EXPECT_OVERRIDE_CONTROL #error "Expect override control feature" +#endif #else struct A @@ -8,13 +10,24 @@ struct A virtual int getA() { return 7; } }; -struct B final : A +struct B : A { int getA() override { return 42; } }; #endif +#if !HAVE_NULLPTR +#error "Expect nullptr feature" +#else + +const char* getString() +{ + return nullptr; +} + +#endif + int main() { diff --git a/Tests/Complex/Executable/CMakeLists.txt b/Tests/Complex/Executable/CMakeLists.txt index bf23d4a..508221c 100644 --- a/Tests/Complex/Executable/CMakeLists.txt +++ b/Tests/Complex/Executable/CMakeLists.txt @@ -89,18 +89,22 @@ remove_definitions(-DCOMPLEX_DEFINED) # Test pre-build/pre-link/post-build rules for an executable. add_custom_command(TARGET complex PRE_BUILD COMMAND ${CREATE_FILE_EXE} - ARGS "${Complex_BINARY_DIR}/Executable/prebuild.txt") + ARGS "Executable/prebuild.txt" + WORKING_DIRECTORY "${Complex_BINARY_DIR}") add_custom_command(TARGET complex PRE_LINK COMMAND ${CREATE_FILE_EXE} - ARGS "${Complex_BINARY_DIR}/Executable/prelink.txt") + ARGS "Executable/prelink.txt" + WORKING_DIRECTORY "${Complex_BINARY_DIR}") add_custom_command(TARGET complex POST_BUILD COMMAND ${CREATE_FILE_EXE} - ARGS "${Complex_BINARY_DIR}/Executable/postbuild.txt") + ARGS "Executable/postbuild.txt" + WORKING_DIRECTORY "${Complex_BINARY_DIR}") add_custom_command(TARGET complex POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy - "${Complex_BINARY_DIR}/Executable/postbuild.txt" - "${Complex_BINARY_DIR}/Executable/postbuild2.txt") + "Executable/postbuild.txt" + "Executable/postbuild2.txt" + WORKING_DIRECTORY "${Complex_BINARY_DIR}") set_source_files_properties(complex COMPILE_FLAGS diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx index 31442ba..ec222a5 100644 --- a/Tests/Complex/Executable/complex.cxx +++ b/Tests/Complex/Executable/complex.cxx @@ -716,14 +716,14 @@ int main() // the file was removed the last time 'complex' was run, and it is // only created during a build. - TestAndRemoveFile(BINARY_DIR "/Library/prebuild.txt"); - TestAndRemoveFile(BINARY_DIR "/Library/prelink.txt"); - TestAndRemoveFile(BINARY_DIR "/Library/postbuild.txt"); - TestAndRemoveFile(BINARY_DIR "/Library/postbuild2.txt"); - TestAndRemoveFile(BINARY_DIR "/Executable/prebuild.txt"); - TestAndRemoveFile(BINARY_DIR "/Executable/prelink.txt"); - TestAndRemoveFile(BINARY_DIR "/Executable/postbuild.txt"); - TestAndRemoveFile(BINARY_DIR "/Executable/postbuild2.txt"); + TestAndRemoveFile("Library/prebuild.txt"); + TestAndRemoveFile("Library/prelink.txt"); + TestAndRemoveFile("Library/postbuild.txt"); + TestAndRemoveFile("Library/postbuild2.txt"); + TestAndRemoveFile("Executable/prebuild.txt"); + TestAndRemoveFile("Executable/prelink.txt"); + TestAndRemoveFile("Executable/postbuild.txt"); + TestAndRemoveFile("Executable/postbuild2.txt"); // ---------------------------------------------------------------------- // A custom target has been created (see Library/). @@ -733,12 +733,12 @@ int main() // the file was removed the last time 'complex' was run, and it is // only created during a build. - TestAndRemoveFile(BINARY_DIR "/Library/custom_target1.txt"); + TestAndRemoveFile("Library/custom_target1.txt"); // ---------------------------------------------------------------------- // A directory has been created. - TestDir(BINARY_DIR "/make_dir"); + TestDir("make_dir"); // ---------------------------------------------------------------------- // Test OUTPUT_REQUIRED_FILES @@ -749,7 +749,7 @@ int main() // the file was removed the last time 'complex' was run, and it is // only created during a build. - TestAndRemoveFile(BINARY_DIR "/Executable/Temp/complex-required.txt"); + TestAndRemoveFile("Executable/Temp/complex-required.txt"); // ---------------------------------------------------------------------- // Test FIND_LIBRARY diff --git a/Tests/ComplexOneConfig/Executable/CMakeLists.txt b/Tests/ComplexOneConfig/Executable/CMakeLists.txt index 01f1005..e910f20 100644 --- a/Tests/ComplexOneConfig/Executable/CMakeLists.txt +++ b/Tests/ComplexOneConfig/Executable/CMakeLists.txt @@ -89,18 +89,22 @@ remove_definitions(-DCOMPLEX_DEFINED) # Test pre-build/pre-link/post-build rules for an executable. add_custom_command(TARGET complex PRE_BUILD COMMAND ${CREATE_FILE_EXE} - ARGS "${Complex_BINARY_DIR}/Executable/prebuild.txt") + ARGS "Executable/prebuild.txt" + WORKING_DIRECTORY "${Complex_BINARY_DIR}") add_custom_command(TARGET complex PRE_BUILD COMMAND ${CREATE_FILE_EXE} - ARGS "${Complex_BINARY_DIR}/Executable/prelink.txt") + ARGS "Executable/prelink.txt" + WORKING_DIRECTORY "${Complex_BINARY_DIR}") add_custom_command(TARGET complex POST_BUILD COMMAND ${CREATE_FILE_EXE} - ARGS "${Complex_BINARY_DIR}/Executable/postbuild.txt") + ARGS "Executable/postbuild.txt" + WORKING_DIRECTORY "${Complex_BINARY_DIR}") add_custom_command(TARGET complex POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy - "${Complex_BINARY_DIR}/Executable/postbuild.txt" - "${Complex_BINARY_DIR}/Executable/postbuild2.txt") + "Executable/postbuild.txt" + "Executable/postbuild2.txt" + WORKING_DIRECTORY "${Complex_BINARY_DIR}") set_source_files_properties(complex COMPILE_FLAGS diff --git a/Tests/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx index 31442ba..ec222a5 100644 --- a/Tests/ComplexOneConfig/Executable/complex.cxx +++ b/Tests/ComplexOneConfig/Executable/complex.cxx @@ -716,14 +716,14 @@ int main() // the file was removed the last time 'complex' was run, and it is // only created during a build. - TestAndRemoveFile(BINARY_DIR "/Library/prebuild.txt"); - TestAndRemoveFile(BINARY_DIR "/Library/prelink.txt"); - TestAndRemoveFile(BINARY_DIR "/Library/postbuild.txt"); - TestAndRemoveFile(BINARY_DIR "/Library/postbuild2.txt"); - TestAndRemoveFile(BINARY_DIR "/Executable/prebuild.txt"); - TestAndRemoveFile(BINARY_DIR "/Executable/prelink.txt"); - TestAndRemoveFile(BINARY_DIR "/Executable/postbuild.txt"); - TestAndRemoveFile(BINARY_DIR "/Executable/postbuild2.txt"); + TestAndRemoveFile("Library/prebuild.txt"); + TestAndRemoveFile("Library/prelink.txt"); + TestAndRemoveFile("Library/postbuild.txt"); + TestAndRemoveFile("Library/postbuild2.txt"); + TestAndRemoveFile("Executable/prebuild.txt"); + TestAndRemoveFile("Executable/prelink.txt"); + TestAndRemoveFile("Executable/postbuild.txt"); + TestAndRemoveFile("Executable/postbuild2.txt"); // ---------------------------------------------------------------------- // A custom target has been created (see Library/). @@ -733,12 +733,12 @@ int main() // the file was removed the last time 'complex' was run, and it is // only created during a build. - TestAndRemoveFile(BINARY_DIR "/Library/custom_target1.txt"); + TestAndRemoveFile("Library/custom_target1.txt"); // ---------------------------------------------------------------------- // A directory has been created. - TestDir(BINARY_DIR "/make_dir"); + TestDir("make_dir"); // ---------------------------------------------------------------------- // Test OUTPUT_REQUIRED_FILES @@ -749,7 +749,7 @@ int main() // the file was removed the last time 'complex' was run, and it is // only created during a build. - TestAndRemoveFile(BINARY_DIR "/Executable/Temp/complex-required.txt"); + TestAndRemoveFile("Executable/Temp/complex-required.txt"); // ---------------------------------------------------------------------- // Test FIND_LIBRARY diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index 915da0a..57ffeec 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -164,13 +164,6 @@ add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/not_included.h ${PROJECT_BINARY_DIR}/not_included.h ) -# Tell the executable where to find not_included.h. -configure_file( - ${PROJECT_SOURCE_DIR}/config.h.in - ${PROJECT_BINARY_DIR}/config.h - @ONLY - ) - # add the executable add_executable(CustomCommand ${PROJECT_BINARY_DIR}/foo.h diff --git a/Tests/CustomCommand/config.h.in b/Tests/CustomCommand/config.h.in deleted file mode 100644 index 86c97bd..0000000 --- a/Tests/CustomCommand/config.h.in +++ /dev/null @@ -1 +0,0 @@ -#define PROJECT_BINARY_DIR "@PROJECT_BINARY_DIR@" diff --git a/Tests/CustomCommand/foo.in b/Tests/CustomCommand/foo.in index 0c5021c..e43aed1 100644 --- a/Tests/CustomCommand/foo.in +++ b/Tests/CustomCommand/foo.in @@ -1,6 +1,5 @@ #include "doc1.h" #include "foo.h" -#include "config.h" #include <stdio.h> @@ -11,7 +10,7 @@ int main () { if (generated()*wrapped()*doc() == 3*5*7) { - FILE* fin = fopen(PROJECT_BINARY_DIR "/not_included.h", "r"); + FILE* fin = fopen("not_included.h", "r"); if(fin) { fclose(fin); diff --git a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt index 5b2f1de..cfaa78c 100644 --- a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt +++ b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0.0) +cmake_minimum_required(VERSION 3.1.0) project(WriteCompilerDetectionHeader) set(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -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 MSVC VERSION 3.1 PROLOG "// something" EPILOG "// more" @@ -56,17 +56,29 @@ macro(set_defines target true_defs false_defs) ) endmacro() -if (CMAKE_CXX_COMPILER_ID STREQUAL GNU - OR CMAKE_CXX_COMPILER_ID STREQUAL Clang - OR CMAKE_CXX_COMPILER_ID STREQUAL AppleClang) +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" + OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" + OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") # False for C++98 mode. list(APPEND false_defs EXPECTED_COMPILER_CXX_DELEGATING_CONSTRUCTORS) list(APPEND false_defs EXPECTED_COMPILER_CXX_VARIADIC_TEMPLATES) endif() -if (CMAKE_C_COMPILER_ID STREQUAL GNU - OR CMAKE_C_COMPILER_ID STREQUAL Clang - OR CMAKE_C_COMPILER_ID STREQUAL AppleClang) +# for msvc the compiler version determines which c++11 features are available. +# Both variadic templates and delegating constructors support exist in +# all versions that we write compile headers for. +if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND + ";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";cxx_delegating_constructors;") + list(APPEND true_defs EXPECTED_COMPILER_CXX_DELEGATING_CONSTRUCTORS) + list(APPEND true_defs EXPECTED_COMPILER_CXX_VARIADIC_TEMPLATES) +else(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + list(APPEND false_defs EXPECTED_COMPILER_CXX_DELEGATING_CONSTRUCTORS) + list(APPEND false_defs EXPECTED_COMPILER_CXX_VARIADIC_TEMPLATES) +endif() + +if (CMAKE_C_COMPILER_ID STREQUAL "GNU" + OR CMAKE_C_COMPILER_ID STREQUAL "Clang" + OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang") add_executable(C_undefined c_undefined.c) set_property(TARGET C_undefined PROPERTY CXX_STANDARD 90) target_compile_options(C_undefined PRIVATE -Werror=undef) @@ -81,7 +93,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 MSVC VERSION 3.1 FEATURES ${cxx_known_features} ${c_known_features} diff --git a/Tests/OutDir/OutDir.cmake b/Tests/OutDir/OutDir.cmake index e1e6b7f..a1f13e7 100644 --- a/Tests/OutDir/OutDir.cmake +++ b/Tests/OutDir/OutDir.cmake @@ -16,13 +16,17 @@ find_program(CONLY_EXE PATHS ${top}/runtime NO_DEFAULT_PATH) +file(RELATIVE_PATH TESTC1_LIB_FILE "${top}" "${TESTC1_LIB}") +file(RELATIVE_PATH TESTC2_LIB_FILE "${top}" "${TESTC2_LIB}") +file(RELATIVE_PATH CONLY_EXE_FILE "${top}" "${CONLY_EXE}") + file(WRITE ${top}/OutDir.h "/* Generated by ${CMAKE_CURRENT_LIST_FILE} */ #ifndef OutDir_h #define OutDir_h -#define TESTC1_LIB \"${TESTC1_LIB}\" -#define TESTC2_LIB \"${TESTC2_LIB}\" -#define CONLY_EXE \"${CONLY_EXE}\" +#define TESTC1_LIB \"${TESTC1_LIB_FILE}\" +#define TESTC2_LIB \"${TESTC2_LIB_FILE}\" +#define CONLY_EXE \"${CONLY_EXE_FILE}\" #endif ") diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index b5e41d9..1697025 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -121,6 +121,7 @@ add_RunCMake_test(file) add_RunCMake_test(find_library) add_RunCMake_test(find_package) add_RunCMake_test(get_filename_component) +add_RunCMake_test(get_property) add_RunCMake_test(if) add_RunCMake_test(include) add_RunCMake_test(include_directories) diff --git a/Tests/RunCMake/CompileFeatures/NonValidTarget1.cmake b/Tests/RunCMake/CompileFeatures/NonValidTarget1.cmake index c6707c1..4de8e88 100644 --- a/Tests/RunCMake/CompileFeatures/NonValidTarget1.cmake +++ b/Tests/RunCMake/CompileFeatures/NonValidTarget1.cmake @@ -7,11 +7,11 @@ else() set(expected_result 0) endif() -add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file${HAVE_FINAL}.cpp" +add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file${expected_result}.cpp" COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp" "${CMAKE_CURRENT_BINARY_DIR}/copied_file${genexvar}.cpp" ) -add_library(empty "${CMAKE_CURRENT_BINARY_DIR}/copied_file${genexvar}.cpp") +add_library(empty "${CMAKE_CURRENT_BINARY_DIR}/copied_file${expected_result}.cpp") if (HAVE_FINAL) target_compile_features(empty PRIVATE cxx_final) endif() diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake index 1892a5c..3b37091 100644 --- a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake @@ -27,8 +27,13 @@ if (NOT CXX_FEATURES) run_cmake(NoSupportedCxxFeatures) run_cmake(NoSupportedCxxFeaturesGenex) else() - run_cmake(LinkImplementationFeatureCycle) - run_cmake(LinkImplementationFeatureCycleSolved) + # compilers such as MSVC have no explicit flags to enable c++11 mode. + # Instead they come with all c++11 features implicitly enabled. + # So for those types of compilers this tests is not applicable. + if(CMAKE_CXX11_STANDARD_COMPILE_OPTION) + run_cmake(LinkImplementationFeatureCycle) + run_cmake(LinkImplementationFeatureCycleSolved) + endif() if (";${CXX_FEATURES};" MATCHES ";cxx_final;") set(RunCMake_TEST_OPTIONS "-DHAVE_FINAL=1") diff --git a/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE-check.cmake b/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE-check.cmake index 748d14f..2a588bc 100644 --- a/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE-check.cmake +++ b/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE-check.cmake @@ -1,4 +1,4 @@ -file(STRINGS ${RunCMake_TEST_BINARY_DIR}/test.txt TEST_TXT) +file(STRINGS ${RunCMake_TEST_BINARY_DIR}/test.txt TEST_TXT ENCODING UTF-8) list(GET TEST_TXT 0 PDB_PATH) list(GET TEST_TXT 1 PDB_NAME) diff --git a/Tests/RunCMake/get_property/CMakeLists.txt b/Tests/RunCMake/get_property/CMakeLists.txt new file mode 100644 index 0000000..12cd3c7 --- /dev/null +++ b/Tests/RunCMake/get_property/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.4) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/get_property/RunCMakeTest.cmake b/Tests/RunCMake/get_property/RunCMakeTest.cmake new file mode 100644 index 0000000..1964824 --- /dev/null +++ b/Tests/RunCMake/get_property/RunCMakeTest.cmake @@ -0,0 +1,9 @@ +include(RunCMake) + +run_cmake(cache_properties) +run_cmake(directory_properties) +run_cmake(global_properties) +run_cmake(install_properties) +run_cmake(source_properties) +run_cmake(target_properties) +run_cmake(test_properties) diff --git a/Tests/RunCMake/get_property/cache_properties-stderr.txt b/Tests/RunCMake/get_property/cache_properties-stderr.txt new file mode 100644 index 0000000..ee019c6 --- /dev/null +++ b/Tests/RunCMake/get_property/cache_properties-stderr.txt @@ -0,0 +1,3 @@ +^get_property: --><-- +get_property: -->TRUE<-- +get_property: --><--$ diff --git a/Tests/RunCMake/get_property/cache_properties.cmake b/Tests/RunCMake/get_property/cache_properties.cmake new file mode 100644 index 0000000..bf3e7ab --- /dev/null +++ b/Tests/RunCMake/get_property/cache_properties.cmake @@ -0,0 +1,15 @@ +function (check_cache_property var prop) + get_property(gp_val + CACHE "${var}" + PROPERTY "${prop}") + + message("get_property: -->${gp_val}<--") +endfunction () + +set(var val CACHE STRING "doc") +set_property(CACHE var PROPERTY VALUE "") # empty +set_property(CACHE var PROPERTY ADVANCED TRUE) + +check_cache_property(var VALUE) +check_cache_property(var ADVANCED) +check_cache_property(var noexist) diff --git a/Tests/RunCMake/get_property/directory_properties-stderr.txt b/Tests/RunCMake/get_property/directory_properties-stderr.txt new file mode 100644 index 0000000..80c9877 --- /dev/null +++ b/Tests/RunCMake/get_property/directory_properties-stderr.txt @@ -0,0 +1,6 @@ +^get_directory_property: --><-- +get_property: --><-- +get_directory_property: -->value<-- +get_property: -->value<-- +get_directory_property: --><-- +get_property: --><--$ diff --git a/Tests/RunCMake/get_property/directory_properties.cmake b/Tests/RunCMake/get_property/directory_properties.cmake new file mode 100644 index 0000000..b0a9b1b --- /dev/null +++ b/Tests/RunCMake/get_property/directory_properties.cmake @@ -0,0 +1,15 @@ +function (check_directory_property dir prop) + get_directory_property(gdp_val DIRECTORY "${dir}" "${prop}") + get_property(gp_val + DIRECTORY "${dir}" + PROPERTY "${prop}") + + message("get_directory_property: -->${gdp_val}<--") + message("get_property: -->${gp_val}<--") +endfunction () + +set_directory_properties(PROPERTIES empty "" custom value) + +check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" empty) +check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" custom) +check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" noexist) diff --git a/Tests/RunCMake/get_property/global_properties-stderr.txt b/Tests/RunCMake/get_property/global_properties-stderr.txt new file mode 100644 index 0000000..4c08ad7 --- /dev/null +++ b/Tests/RunCMake/get_property/global_properties-stderr.txt @@ -0,0 +1,6 @@ +^get_cmake_property: --><-- +get_property: --><-- +get_cmake_property: -->value<-- +get_property: -->value<-- +get_cmake_property: -->NOTFOUND<-- +get_property: --><--$ diff --git a/Tests/RunCMake/get_property/global_properties.cmake b/Tests/RunCMake/get_property/global_properties.cmake new file mode 100644 index 0000000..2073136 --- /dev/null +++ b/Tests/RunCMake/get_property/global_properties.cmake @@ -0,0 +1,16 @@ +function (check_global_property prop) + get_cmake_property(gcp_val "${prop}") + get_property(gp_val + GLOBAL + PROPERTY "${prop}") + + message("get_cmake_property: -->${gcp_val}<--") + message("get_property: -->${gp_val}<--") +endfunction () + +set_property(GLOBAL PROPERTY empty "") +set_property(GLOBAL PROPERTY custom value) + +check_global_property(empty) +check_global_property(custom) +check_global_property(noexist) diff --git a/Tests/RunCMake/get_property/install_properties-stderr.txt b/Tests/RunCMake/get_property/install_properties-stderr.txt new file mode 100644 index 0000000..b1a2987 --- /dev/null +++ b/Tests/RunCMake/get_property/install_properties-stderr.txt @@ -0,0 +1,3 @@ +^get_property: --><-- +get_property: -->value<-- +get_property: --><--$ diff --git a/Tests/RunCMake/get_property/install_properties.cmake b/Tests/RunCMake/get_property/install_properties.cmake new file mode 100644 index 0000000..aa89225 --- /dev/null +++ b/Tests/RunCMake/get_property/install_properties.cmake @@ -0,0 +1,18 @@ +function (check_install_property file prop) + get_property(gp_val + INSTALL "${file}" + PROPERTY "${prop}") + + message("get_property: -->${gp_val}<--") +endfunction () + +install( + FILES "${CMAKE_CURRENT_LIST_FILE}" + DESTINATION "${CMAKE_CURRENT_LIST_DIR}" + RENAME "installed-file-dest") +set_property(INSTALL "${CMAKE_CURRENT_LIST_FILE}" PROPERTY empty "") +set_property(INSTALL "${CMAKE_CURRENT_LIST_FILE}" PROPERTY custom value) + +check_install_property("${CMAKE_CURRENT_LIST_FILE}" empty) +check_install_property("${CMAKE_CURRENT_LIST_FILE}" custom) +check_install_property("${CMAKE_CURRENT_LIST_FILE}" noexist) diff --git a/Tests/RunCMake/get_property/source_properties-stderr.txt b/Tests/RunCMake/get_property/source_properties-stderr.txt new file mode 100644 index 0000000..0a46f96 --- /dev/null +++ b/Tests/RunCMake/get_property/source_properties-stderr.txt @@ -0,0 +1,6 @@ +^get_source_file_property: --><-- +get_property: --><-- +get_source_file_property: -->value<-- +get_property: -->value<-- +get_source_file_property: -->NOTFOUND<-- +get_property: --><--$ diff --git a/Tests/RunCMake/get_property/source_properties.cmake b/Tests/RunCMake/get_property/source_properties.cmake new file mode 100644 index 0000000..263ffe1 --- /dev/null +++ b/Tests/RunCMake/get_property/source_properties.cmake @@ -0,0 +1,15 @@ +function (check_source_file_property file prop) + get_source_file_property(gsfp_val "${file}" "${prop}") + get_property(gp_val + SOURCE "${file}" + PROPERTY "${prop}") + + message("get_source_file_property: -->${gsfp_val}<--") + message("get_property: -->${gp_val}<--") +endfunction () + +set_source_files_properties(file.c PROPERTIES empty "" custom value) + +check_source_file_property(file.c empty) +check_source_file_property(file.c custom) +check_source_file_property(file.c noexist) diff --git a/Tests/RunCMake/get_property/target_properties-stderr.txt b/Tests/RunCMake/get_property/target_properties-stderr.txt new file mode 100644 index 0000000..d0981ac --- /dev/null +++ b/Tests/RunCMake/get_property/target_properties-stderr.txt @@ -0,0 +1,6 @@ +^get_target_property: --><-- +get_property: --><-- +get_target_property: -->value<-- +get_property: -->value<-- +get_target_property: -->gtp_val-NOTFOUND<-- +get_property: --><--$ diff --git a/Tests/RunCMake/get_property/target_properties.cmake b/Tests/RunCMake/get_property/target_properties.cmake new file mode 100644 index 0000000..c5a141d --- /dev/null +++ b/Tests/RunCMake/get_property/target_properties.cmake @@ -0,0 +1,16 @@ +function (check_target_property target prop) + get_target_property(gtp_val "${target}" "${prop}") + get_property(gp_val + TARGET "${target}" + PROPERTY "${prop}") + + message("get_target_property: -->${gtp_val}<--") + message("get_property: -->${gp_val}<--") +endfunction () + +add_custom_target(tgt) +set_target_properties(tgt PROPERTIES empty "" custom value) + +check_target_property(tgt empty) +check_target_property(tgt custom) +check_target_property(tgt noexist) diff --git a/Tests/RunCMake/get_property/test_properties-stderr.txt b/Tests/RunCMake/get_property/test_properties-stderr.txt new file mode 100644 index 0000000..a447280 --- /dev/null +++ b/Tests/RunCMake/get_property/test_properties-stderr.txt @@ -0,0 +1,6 @@ +^get_test_property: --><-- +get_property: --><-- +get_test_property: -->value<-- +get_property: -->value<-- +get_test_property: -->NOTFOUND<-- +get_property: --><--$ diff --git a/Tests/RunCMake/get_property/test_properties.cmake b/Tests/RunCMake/get_property/test_properties.cmake new file mode 100644 index 0000000..1d0295c --- /dev/null +++ b/Tests/RunCMake/get_property/test_properties.cmake @@ -0,0 +1,17 @@ +function (check_test_property test prop) + get_test_property("${test}" "${prop}" gtp_val) + get_property(gp_val + TEST "${test}" + PROPERTY "${prop}") + + message("get_test_property: -->${gtp_val}<--") + message("get_property: -->${gp_val}<--") +endfunction () + +include(CTest) +add_test(NAME test COMMAND "${CMAKE_COMMAND}" --help) +set_tests_properties(test PROPERTIES empty "" custom value) + +check_test_property(test empty) +check_test_property(test custom) +check_test_property(test noexist) |