diff options
Diffstat (limited to 'Tests/RunCMake')
201 files changed, 943 insertions, 108 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 1e485c4..1e0cb86 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -279,6 +279,7 @@ add_RunCMake_test(include) add_RunCMake_test(include_directories) add_RunCMake_test(include_guard) add_RunCMake_test(list) +add_RunCMake_test(load_cache) add_RunCMake_test(math) add_RunCMake_test(message) add_RunCMake_test(option) @@ -317,6 +318,8 @@ function(add_RunCMake_test_try_compile) CMAKE_CXX_COMPILER_VERSION CMAKE_CXX_STANDARD_DEFAULT CMake_TEST_CUDA + CMAKE_OBJC_STANDARD_DEFAULT + CMAKE_OBJCXX_STANDARD_DEFAULT ) if(DEFINED ${var}) list(APPEND try_compile_ARGS -D${var}=${${var}}) @@ -443,7 +446,7 @@ add_RunCMake_test(target_include_directories) add_RunCMake_test(target_sources) add_RunCMake_test(CheckModules) add_RunCMake_test(CheckIPOSupported) -add_RunCMake_test(CommandLine -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}) +add_RunCMake_test(CommandLine -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DCYGWIN=${CYGWIN}) add_RunCMake_test(CommandLineTar) if(CMAKE_PLATFORM_NO_VERSIONED_SONAME OR (NOT CMAKE_SHARED_LIBRARY_SONAME_FLAG AND NOT CMAKE_SHARED_LIBRARY_SONAME_C_FLAG)) diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 5fce32a..76d16e1 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -36,9 +36,6 @@ run_cpack_test(MD5SUMS "DEB.MD5SUMS" false "MONOLITHIC;COMPONENT") run_cpack_test_subtests(CPACK_INSTALL_SCRIPTS "singular;plural;both" "ZIP" false "MONOLITHIC") run_cpack_test(DEB_PACKAGE_VERSION_BACK_COMPATIBILITY "DEB.DEB_PACKAGE_VERSION_BACK_COMPATIBILITY" false "MONOLITHIC;COMPONENT") run_cpack_test_subtests(EXTERNAL "none;good;good_multi;bad_major;bad_minor;invalid_good;invalid_bad;stage_and_package" "External" false "MONOLITHIC;COMPONENT") -if(RunCMake_GENERATOR MATCHES "Visual Studio|Xcode") - run_cpack_test(CPACK_INSTALL_CMAKE_CONFIGURATIONS "ZIP" false "MONOLITHIC") -endif() run_cpack_test_subtests( DEB_DESCRIPTION "CPACK_DEBIAN_PACKAGE_DESCRIPTION;CPACK_PACKAGE_DESCRIPTION;CPACK_PACKAGE_DESCRIPTION_FILE" diff --git a/Tests/RunCMake/CPack/tests/CPACK_INSTALL_CMAKE_CONFIGURATIONS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/CPACK_INSTALL_CMAKE_CONFIGURATIONS/ExpectedFiles.cmake deleted file mode 100644 index 34c7f8a..0000000 --- a/Tests/RunCMake/CPack/tests/CPACK_INSTALL_CMAKE_CONFIGURATIONS/ExpectedFiles.cmake +++ /dev/null @@ -1,3 +0,0 @@ -set(EXPECTED_FILES_COUNT "1") - -set(EXPECTED_FILE_CONTENT_1_LIST "foo;foo/debug.txt;foo/release.txt") diff --git a/Tests/RunCMake/CPack/tests/CPACK_INSTALL_CMAKE_CONFIGURATIONS/ZIP-stdout.txt b/Tests/RunCMake/CPack/tests/CPACK_INSTALL_CMAKE_CONFIGURATIONS/ZIP-stdout.txt deleted file mode 100644 index 2a3aa9e..0000000 --- a/Tests/RunCMake/CPack/tests/CPACK_INSTALL_CMAKE_CONFIGURATIONS/ZIP-stdout.txt +++ /dev/null @@ -1,3 +0,0 @@ -CPack: Install projects -CPack: - Install project: CPACK_INSTALL_CMAKE_CONFIGURATIONS-MONOLITHIC-type \[Debug\] -CPack: - Install project: CPACK_INSTALL_CMAKE_CONFIGURATIONS-MONOLITHIC-type \[Release\] diff --git a/Tests/RunCMake/CPack/tests/CPACK_INSTALL_CMAKE_CONFIGURATIONS/test.cmake b/Tests/RunCMake/CPack/tests/CPACK_INSTALL_CMAKE_CONFIGURATIONS/test.cmake deleted file mode 100644 index 4f562cf..0000000 --- a/Tests/RunCMake/CPack/tests/CPACK_INSTALL_CMAKE_CONFIGURATIONS/test.cmake +++ /dev/null @@ -1,9 +0,0 @@ -set(CMAKE_CONFIGURATION_TYPES Debug Release) - -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/debug.txt" "debug content") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/release.txt" "release content") - -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/debug.txt" DESTINATION "foo" CONFIGURATIONS Debug) -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/release.txt" DESTINATION "foo" CONFIGURATIONS Release) - -set(CPACK_INSTALL_CMAKE_CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES}) diff --git a/Tests/RunCMake/CPackCommandLine/CMakeLists.txt b/Tests/RunCMake/CPackCommandLine/CMakeLists.txt new file mode 100644 index 0000000..2632ffa --- /dev/null +++ b/Tests/RunCMake/CPackCommandLine/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.16) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CPackCommandLine/MultiConfig-check-stdout.txt b/Tests/RunCMake/CPackCommandLine/MultiConfig-check-stdout.txt new file mode 100644 index 0000000..f2ae844 --- /dev/null +++ b/Tests/RunCMake/CPackCommandLine/MultiConfig-check-stdout.txt @@ -0,0 +1,4 @@ +MultiConfig-0\.1\.1-[^/ +]*/lib/(lib|)foo_dbg\.(a|lib) +MultiConfig-0\.1\.1-[^/ +]*/lib/(lib|)foo_rel\.(a|lib) diff --git a/Tests/RunCMake/CPackCommandLine/MultiConfig-package-stdout.txt b/Tests/RunCMake/CPackCommandLine/MultiConfig-package-stdout.txt new file mode 100644 index 0000000..4fb8181 --- /dev/null +++ b/Tests/RunCMake/CPackCommandLine/MultiConfig-package-stdout.txt @@ -0,0 +1,8 @@ +^CPack: Create package using ZIP +CPack: Install projects +CPack: - Install project: MultiConfig \[Debug\] +CPack: - Install project: MultiConfig \[Release\] +CPack: Create package +CPack: - package: [^ +]*/Tests/RunCMake/CPackCommandLine/MultiConfig-build/MultiConfig-0.1.1-[^ +]*.zip generated.$ diff --git a/Tests/RunCMake/CPackCommandLine/MultiConfig.cmake b/Tests/RunCMake/CPackCommandLine/MultiConfig.cmake new file mode 100644 index 0000000..71fd189 --- /dev/null +++ b/Tests/RunCMake/CPackCommandLine/MultiConfig.cmake @@ -0,0 +1,9 @@ +enable_language(C) + +include(CPack) + +add_library(foo foo.c) +set_property(TARGET foo PROPERTY DEBUG_POSTFIX _dbg) +set_property(TARGET foo PROPERTY RELEASE_POSTFIX _rel) + +install(TARGETS foo) diff --git a/Tests/RunCMake/CPackCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CPackCommandLine/RunCMakeTest.cmake index 991146c..53f4e4f 100644 --- a/Tests/RunCMake/CPackCommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPackCommandLine/RunCMakeTest.cmake @@ -8,3 +8,26 @@ set(CPACK_PACKAGE_VERSION "1") set(RunCMake_TEST_NO_CLEAN 1) run_cmake_command(NotAGenerator ${CMAKE_CPACK_COMMAND} -G NotAGenerator) unset(RunCMake_TEST_NO_CLEAN) + +function(run_MultiConfig) + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/MultiConfig-build") + run_cmake(MultiConfig) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(MultiConfig-build-dbg ${CMAKE_COMMAND} --build . --config Debug) + run_cmake_command(MultiConfig-build-rel ${CMAKE_COMMAND} --build . --config Release) + run_cmake_command(MultiConfig-package ${CMAKE_CPACK_COMMAND} -G ZIP -C "Debug\;Release") + set(zip_glob "${RunCMake_TEST_BINARY_DIR}/MultiConfig-0.1.1-*.zip") + file(GLOB zips "${zip_glob}") + set(zip_found 0) + foreach(zip IN LISTS zips) + set(zip_found 1) + run_cmake_command(MultiConfig-check ${CMAKE_COMMAND} -E tar tf "${zip}") + endforeach() + if(NOT zip_found) + message(SEND_ERROR "No package file found at\n ${zip_glob}") + endif() +endfunction() + +if(RunCMake_GENERATOR MATCHES "Visual Studio|Xcode") + run_MultiConfig() +endif() diff --git a/Tests/RunCMake/CPackCommandLine/foo.c b/Tests/RunCMake/CPackCommandLine/foo.c new file mode 100644 index 0000000..c83d856 --- /dev/null +++ b/Tests/RunCMake/CPackCommandLine/foo.c @@ -0,0 +1,4 @@ +int foo(void) +{ + return 0; +} diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake index 6a7fd3b..0953504 100644 --- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake @@ -4,14 +4,26 @@ set(RunCMake_TEST_TIMEOUT 60) unset(ENV{CTEST_PARALLEL_LEVEL}) unset(ENV{CTEST_OUTPUT_ON_FAILURE}) -run_cmake_command(repeat-until-pass-bad1 - ${CMAKE_CTEST_COMMAND} --repeat-until-pass +run_cmake_command(repeat-opt-bad1 + ${CMAKE_CTEST_COMMAND} --repeat until-pass ) -run_cmake_command(repeat-until-pass-bad2 - ${CMAKE_CTEST_COMMAND} --repeat-until-pass foo +run_cmake_command(repeat-opt-bad2 + ${CMAKE_CTEST_COMMAND} --repeat until-pass:foo ) -run_cmake_command(repeat-until-pass-good - ${CMAKE_CTEST_COMMAND} --repeat-until-pass 2 +run_cmake_command(repeat-opt-bad3 + ${CMAKE_CTEST_COMMAND} --repeat until-fail:2 --repeat-until-fail 2 + ) +run_cmake_command(repeat-opt-bad4 + ${CMAKE_CTEST_COMMAND} --repeat-until-fail 2 --repeat until-fail:2 + ) +run_cmake_command(repeat-opt-until-pass + ${CMAKE_CTEST_COMMAND} --repeat until-pass:2 + ) +run_cmake_command(repeat-opt-until-fail + ${CMAKE_CTEST_COMMAND} --repeat until-fail:2 + ) +run_cmake_command(repeat-opt-after-timeout + ${CMAKE_CTEST_COMMAND} --repeat after-timeout:2 ) run_cmake_command(repeat-until-fail-bad1 @@ -24,33 +36,13 @@ run_cmake_command(repeat-until-fail-good ${CMAKE_CTEST_COMMAND} --repeat-until-fail 2 ) -run_cmake_command(repeat-after-timeout-bad1 - ${CMAKE_CTEST_COMMAND} --repeat-after-timeout - ) -run_cmake_command(repeat-after-timeout-bad2 - ${CMAKE_CTEST_COMMAND} --repeat-after-timeout foo - ) -run_cmake_command(repeat-after-timeout-good - ${CMAKE_CTEST_COMMAND} --repeat-after-timeout 2 - ) - -run_cmake_command(repeat-until-pass-and-fail - ${CMAKE_CTEST_COMMAND} --repeat-until-pass 2 --repeat-until-fail 2 - ) -run_cmake_command(repeat-until-fail-and-pass - ${CMAKE_CTEST_COMMAND} --repeat-until-fail 2 --repeat-until-pass 2 - ) -run_cmake_command(repeat-until-fail-and-timeout - ${CMAKE_CTEST_COMMAND} --repeat-until-fail 2 --repeat-after-timeout 2 - ) - function(run_repeat_until_pass_tests) # Use a single build tree for a few tests without cleaning. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/repeat-until-pass-build) run_cmake(repeat-until-pass-cmake) set(RunCMake_TEST_NO_CLEAN 1) run_cmake_command(repeat-until-pass-ctest - ${CMAKE_CTEST_COMMAND} -C Debug --repeat-until-pass 3 + ${CMAKE_CTEST_COMMAND} -C Debug --repeat until-pass:3 ) endfunction() run_repeat_until_pass_tests() @@ -61,7 +53,7 @@ function(run_repeat_after_timeout_tests) run_cmake(repeat-after-timeout-cmake) set(RunCMake_TEST_NO_CLEAN 1) run_cmake_command(repeat-after-timeout-ctest - ${CMAKE_CTEST_COMMAND} -C Debug --repeat-after-timeout 3 + ${CMAKE_CTEST_COMMAND} -C Debug --repeat after-timeout:3 ) endfunction() run_repeat_after_timeout_tests() @@ -72,10 +64,11 @@ function(run_repeat_until_fail_tests) run_cmake(repeat-until-fail-cmake) set(RunCMake_TEST_NO_CLEAN 1) run_cmake_command(repeat-until-fail-ctest - ${CMAKE_CTEST_COMMAND} -C Debug --repeat-until-fail 3 + ${CMAKE_CTEST_COMMAND} -C Debug ${ARGN} ) endfunction() -run_repeat_until_fail_tests() +run_repeat_until_fail_tests(--repeat-until-fail 3) +run_repeat_until_fail_tests(--repeat until-fail:3) function(run_BadCTestTestfile) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/BadCTestTestfile) diff --git a/Tests/RunCMake/CTestCommandLine/repeat-after-timeout-bad1-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-after-timeout-bad1-stderr.txt deleted file mode 100644 index aea92b8..0000000 --- a/Tests/RunCMake/CTestCommandLine/repeat-after-timeout-bad1-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -^CMake Error: '--repeat-after-timeout' requires an argument$ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-after-timeout-bad2-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-after-timeout-bad2-stderr.txt deleted file mode 100644 index c5db55b..0000000 --- a/Tests/RunCMake/CTestCommandLine/repeat-after-timeout-bad2-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -^CMake Error: '--repeat-after-timeout' given non-integer value 'foo'$ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-until-pass-good-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-opt-after-timeout-stderr.txt index a7c4b11..a7c4b11 100644 --- a/Tests/RunCMake/CTestCommandLine/repeat-until-pass-good-stderr.txt +++ b/Tests/RunCMake/CTestCommandLine/repeat-opt-after-timeout-stderr.txt diff --git a/Tests/RunCMake/CTestCommandLine/repeat-until-pass-bad2-result.txt b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad1-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/CTestCommandLine/repeat-until-pass-bad2-result.txt +++ b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad1-result.txt diff --git a/Tests/RunCMake/CTestCommandLine/repeat-opt-bad1-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad1-stderr.txt new file mode 100644 index 0000000..f6f3241 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad1-stderr.txt @@ -0,0 +1 @@ +^CMake Error: '--repeat' given invalid value 'until-pass'$ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-until-pass-bad1-result.txt b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad2-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/CTestCommandLine/repeat-until-pass-bad1-result.txt +++ b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad2-result.txt diff --git a/Tests/RunCMake/CTestCommandLine/repeat-opt-bad2-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad2-stderr.txt new file mode 100644 index 0000000..2f9f32a --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad2-stderr.txt @@ -0,0 +1 @@ +^CMake Error: '--repeat' given invalid value 'until-pass:foo'$ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-until-pass-and-fail-result.txt b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad3-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/CTestCommandLine/repeat-until-pass-and-fail-result.txt +++ b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad3-result.txt diff --git a/Tests/RunCMake/CTestCommandLine/repeat-opt-bad3-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad3-stderr.txt new file mode 100644 index 0000000..de4e11b --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad3-stderr.txt @@ -0,0 +1 @@ +^CMake Error: At most one '--repeat' option may be used\.$ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-until-fail-and-timeout-result.txt b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad4-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/CTestCommandLine/repeat-until-fail-and-timeout-result.txt +++ b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad4-result.txt diff --git a/Tests/RunCMake/CTestCommandLine/repeat-opt-bad4-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad4-stderr.txt new file mode 100644 index 0000000..de4e11b --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-opt-bad4-stderr.txt @@ -0,0 +1 @@ +^CMake Error: At most one '--repeat' option may be used\.$ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-after-timeout-good-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-opt-until-fail-stderr.txt index a7c4b11..a7c4b11 100644 --- a/Tests/RunCMake/CTestCommandLine/repeat-after-timeout-good-stderr.txt +++ b/Tests/RunCMake/CTestCommandLine/repeat-opt-until-fail-stderr.txt diff --git a/Tests/RunCMake/CTestCommandLine/repeat-opt-until-pass-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-opt-until-pass-stderr.txt new file mode 100644 index 0000000..a7c4b11 --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/repeat-opt-until-pass-stderr.txt @@ -0,0 +1 @@ +^No tests were found!!!$ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-until-fail-and-pass-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-until-fail-and-pass-stderr.txt deleted file mode 100644 index 15ee3a9..0000000 --- a/Tests/RunCMake/CTestCommandLine/repeat-until-fail-and-pass-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -^CMake Error: At most one '--repeat-\*' option may be used\.$ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-until-fail-and-timeout-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-until-fail-and-timeout-stderr.txt deleted file mode 100644 index 15ee3a9..0000000 --- a/Tests/RunCMake/CTestCommandLine/repeat-until-fail-and-timeout-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -^CMake Error: At most one '--repeat-\*' option may be used\.$ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-until-pass-and-fail-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-until-pass-and-fail-stderr.txt deleted file mode 100644 index 15ee3a9..0000000 --- a/Tests/RunCMake/CTestCommandLine/repeat-until-pass-and-fail-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -^CMake Error: At most one '--repeat-\*' option may be used\.$ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-until-pass-bad1-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-until-pass-bad1-stderr.txt deleted file mode 100644 index c6afb1d..0000000 --- a/Tests/RunCMake/CTestCommandLine/repeat-until-pass-bad1-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -^CMake Error: '--repeat-until-pass' requires an argument$ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-until-pass-bad2-stderr.txt b/Tests/RunCMake/CTestCommandLine/repeat-until-pass-bad2-stderr.txt deleted file mode 100644 index cc3aed5..0000000 --- a/Tests/RunCMake/CTestCommandLine/repeat-until-pass-bad2-stderr.txt +++ /dev/null @@ -1 +0,0 @@ -^CMake Error: '--repeat-until-pass' given non-integer value 'foo'$ diff --git a/Tests/RunCMake/CTestResourceAllocation/ResourceCommon.cmake b/Tests/RunCMake/CTestResourceAllocation/ResourceCommon.cmake index 7d63299..ef79dce 100644 --- a/Tests/RunCMake/CTestResourceAllocation/ResourceCommon.cmake +++ b/Tests/RunCMake/CTestResourceAllocation/ResourceCommon.cmake @@ -1,6 +1,6 @@ function(setup_resource_tests) if(CTEST_RESOURCE_ALLOC_ENABLED) - add_test(NAME ResourceSetup COMMAND "${CMAKE_COMMAND}" -E remove -f "${CMAKE_BINARY_DIR}/ctresalloc.log") + add_test(NAME ResourceSetup COMMAND "${CMAKE_COMMAND}" -E rm -f "${CMAKE_BINARY_DIR}/ctresalloc.log") endif() endfunction() diff --git a/Tests/RunCMake/CTestResourceAllocation/RunCMakeTest.cmake b/Tests/RunCMake/CTestResourceAllocation/RunCMakeTest.cmake index d52a63e..8584786 100644 --- a/Tests/RunCMake/CTestResourceAllocation/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTestResourceAllocation/RunCMakeTest.cmake @@ -160,6 +160,8 @@ run_ctest_resource(checkfree1 2 0) run_ctest_resource(checkfree2 1 0) run_ctest_resource(notenough1 1 0) run_ctest_resource(notenough2 1 0) +run_ctest_resource(notenough3 1 0) +run_ctest_resource(combine 1 0) run_ctest_resource(ensure_parallel 2 0) set(ENV{CTEST_RESOURCE_GROUP_COUNT} 2) diff --git a/Tests/RunCMake/CTestResourceAllocation/combine.cmake b/Tests/RunCMake/CTestResourceAllocation/combine.cmake new file mode 100644 index 0000000..ed5b251 --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/combine.cmake @@ -0,0 +1,5 @@ +setup_resource_tests() + +add_resource_test(Test1 0 "widgets:8,widgets:4") + +cleanup_resource_tests() diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough1.cmake b/Tests/RunCMake/CTestResourceAllocation/notenough1.cmake index 2908812..f820c37 100644 --- a/Tests/RunCMake/CTestResourceAllocation/notenough1.cmake +++ b/Tests/RunCMake/CTestResourceAllocation/notenough1.cmake @@ -1,5 +1,5 @@ setup_resource_tests() -add_resource_test(Test1 1 "fluxcapacitors:200") +add_resource_test(Test1 0 "fluxcapacitors:200") cleanup_resource_tests() diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough2.cmake b/Tests/RunCMake/CTestResourceAllocation/notenough2.cmake index d7600c8..5b81776 100644 --- a/Tests/RunCMake/CTestResourceAllocation/notenough2.cmake +++ b/Tests/RunCMake/CTestResourceAllocation/notenough2.cmake @@ -1,5 +1,5 @@ setup_resource_tests() -add_resource_test(Test1 1 "terminators:2") +add_resource_test(Test1 0 "terminators:2") cleanup_resource_tests() diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-check.cmake b/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-check.cmake new file mode 100644 index 0000000..321e9a2 --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-check.cmake @@ -0,0 +1,3 @@ +if(EXISTS "${RunCMake_TEST_BINARY_DIR}/ctresalloc.log") + set(RunCMake_TEST_FAILED "ctresalloc.log should not exist") +endif() diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-result.txt b/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-stderr.txt b/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-stderr.txt new file mode 100644 index 0000000..82dfdef --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-stderr.txt @@ -0,0 +1,4 @@ +^Insufficient resources +CMake Error at [^ +]*/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res/test\.cmake:[0-9]+ \(message\): + Tests did not pass$ diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough3.cmake b/Tests/RunCMake/CTestResourceAllocation/notenough3.cmake new file mode 100644 index 0000000..ddf3a9c --- /dev/null +++ b/Tests/RunCMake/CTestResourceAllocation/notenough3.cmake @@ -0,0 +1,5 @@ +setup_resource_tests() + +add_resource_test(Test1 0 "widgets:12") + +cleanup_resource_tests() diff --git a/Tests/RunCMake/CTestResourceAllocation/resspec.json b/Tests/RunCMake/CTestResourceAllocation/resspec.json index c67fcca..48321ec 100644 --- a/Tests/RunCMake/CTestResourceAllocation/resspec.json +++ b/Tests/RunCMake/CTestResourceAllocation/resspec.json @@ -1,4 +1,8 @@ { + "version": { + "major": 1, + "minor": 0 + }, "local": [ { "widgets": [ diff --git a/Tests/RunCMake/CTestCommandLine/repeat-until-fail-and-pass-result.txt b/Tests/RunCMake/CommandLine/E_rm_bad_argument-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/CTestCommandLine/repeat-until-fail-and-pass-result.txt +++ b/Tests/RunCMake/CommandLine/E_rm_bad_argument-result.txt diff --git a/Tests/RunCMake/CommandLine/E_rm_bad_argument-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_bad_argument-stderr.txt new file mode 100644 index 0000000..62b963a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_bad_argument-stderr.txt @@ -0,0 +1 @@ +^CMake Error: Unknown -E rm argument: -rd$ diff --git a/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-check.cmake new file mode 100644 index 0000000..b1a29a2 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-check.cmake @@ -0,0 +1,3 @@ +if(NOT EXISTS ${out}/dir/existing.txt) + set(RunCMake_TEST_FAILED "${out}/dir/existing.txt should exist (we only removed the link to dir folder)") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_empty_file_specified-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_empty_file_specified-stderr.txt new file mode 100644 index 0000000..1ac7dba --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_empty_file_specified-stderr.txt @@ -0,0 +1 @@ +^CMake Error: Missing file/directory to remove$ diff --git a/Tests/RunCMake/CommandLine/E_rm_empty_file_specified.cmake b/Tests/RunCMake/CommandLine/E_rm_empty_file_specified.cmake new file mode 100644 index 0000000..6cd4edd --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_empty_file_specified.cmake @@ -0,0 +1,8 @@ +execute_process( + COMMAND ${CMAKE_COMMAND} -E rm "" + RESULT_VARIABLE actual_result + ) + +if(NOT "${actual_result}" EQUAL "1") + message(SEND_ERROR "cmake -E rm \"\" should have returned 1, got ${actual_result}") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_file_force_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_file_force_existing-check.cmake new file mode 100644 index 0000000..e28b160 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_force_existing-check.cmake @@ -0,0 +1,3 @@ +if(EXISTS ${out}/existing.txt) + set(RunCMake_TEST_FAILED "${out}/existing.txt not removed") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_file_force_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_force_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_force_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_file_force_non_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_force_non_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_force_non_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_file_link_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_file_link_existing-check.cmake new file mode 100644 index 0000000..a0a9b20 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_link_existing-check.cmake @@ -0,0 +1,3 @@ +if(NOT EXISTS ${out}/existing.txt) + set(RunCMake_TEST_FAILED "${out}/existing.txt should exist (we only removed the link)") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_file_link_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_link_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_link_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_file_link_non_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_link_non_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_link_non_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-check.cmake new file mode 100644 index 0000000..e28b160 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-check.cmake @@ -0,0 +1,3 @@ +if(EXISTS ${out}/existing.txt) + set(RunCMake_TEST_FAILED "${out}/existing.txt not removed") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CTestCommandLine/repeat-after-timeout-bad2-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/CTestCommandLine/repeat-after-timeout-bad2-result.txt +++ b/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-result.txt diff --git a/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-stderr.txt new file mode 100644 index 0000000..05df88a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-stderr.txt @@ -0,0 +1 @@ +^CMake Error: File to remove does not exist and force is not set: .*/rm_tests/not_existing.txt diff --git a/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-check.cmake new file mode 100644 index 0000000..e28b160 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-check.cmake @@ -0,0 +1,3 @@ +if(EXISTS ${out}/existing.txt) + set(RunCMake_TEST_FAILED "${out}/existing.txt not removed") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CTestCommandLine/repeat-after-timeout-bad1-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/CTestCommandLine/repeat-after-timeout-bad1-result.txt +++ b/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-result.txt diff --git a/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-stderr.txt new file mode 100644 index 0000000..05df88a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-stderr.txt @@ -0,0 +1 @@ +^CMake Error: File to remove does not exist and force is not set: .*/rm_tests/not_existing.txt diff --git a/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-check.cmake b/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-check.cmake new file mode 100644 index 0000000..1a976cb --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-check.cmake @@ -0,0 +1,3 @@ +if(EXISTS ${out}) + set(RunCMake_TEST_FAILED "${out} not removed") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-result.txt b/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_force_recursive_non_existing_file-result.txt b/Tests/RunCMake/CommandLine/E_rm_force_recursive_non_existing_file-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_force_recursive_non_existing_file-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_no_file_specified-result.txt b/Tests/RunCMake/CommandLine/E_rm_no_file_specified-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_no_file_specified-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_rm_no_file_specified-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_no_file_specified-stderr.txt new file mode 100644 index 0000000..1ac7dba --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_no_file_specified-stderr.txt @@ -0,0 +1 @@ +^CMake Error: Missing file/directory to remove$ diff --git a/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-check.cmake b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-check.cmake new file mode 100644 index 0000000..609271e --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-check.cmake @@ -0,0 +1,3 @@ +if(NOT EXISTS ${out}/d1 OR NOT EXISTS ${out}/d2) + set(RunCMake_TEST_FAILED "${out}/d1 or ${out}/d2 is removed but should not") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-result.txt b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-stderr.txt new file mode 100644 index 0000000..33ea2e3 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-stderr.txt @@ -0,0 +1,2 @@ +^Error removing directory ".*/rm_tests/d1" without recursive option\. +Error removing directory ".*/rm_tests/d2" without recursive option\.$ diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-check.cmake b/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-check.cmake new file mode 100644 index 0000000..5282da7 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-check.cmake @@ -0,0 +1,3 @@ +if(EXISTS ${out}/d1 OR EXISTS ${out}/d2) + set(RunCMake_TEST_FAILED "${out}/d1 or ${out}/d2 should be removed") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-result.txt b/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-check.cmake new file mode 100644 index 0000000..b1a29a2 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-check.cmake @@ -0,0 +1,3 @@ +if(NOT EXISTS ${out}/dir/existing.txt) + set(RunCMake_TEST_FAILED "${out}/dir/existing.txt should exist (we only removed the link to dir folder)") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-check.cmake new file mode 100644 index 0000000..a0a9b20 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-check.cmake @@ -0,0 +1,3 @@ +if(NOT EXISTS ${out}/existing.txt) + set(RunCMake_TEST_FAILED "${out}/existing.txt should exist (we only removed the link)") +endif() diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_non_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_non_existing-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_non_existing-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index f903c3d..bd368cb 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -388,6 +388,76 @@ endif() unset(out) unset(outfile) +set(out ${RunCMake_BINARY_DIR}/rm_tests) +file(REMOVE_RECURSE "${out}") +file(MAKE_DIRECTORY ${out}) +file(TOUCH ${out}/existing.txt) +run_cmake_command(E_rm_file_force_existing + ${CMAKE_COMMAND} -E rm -f ${out}/existing.txt) +file(TOUCH ${out}/existing.txt) +run_cmake_command(E_rm_file_non_force_existing + ${CMAKE_COMMAND} -E rm ${out}/existing.txt) +run_cmake_command(E_rm_file_force_non_existing + ${CMAKE_COMMAND} -E rm -f ${out}/not_existing.txt) +run_cmake_command(E_rm_file_non_force_non_existing + ${CMAKE_COMMAND} -E rm ${out}/not_existing.txt) + +file(TOUCH ${out}/existing.txt) +run_cmake_command(E_rm_file_recursive_existing + ${CMAKE_COMMAND} -E rm -r ${out}/existing.txt) +run_cmake_command(E_rm_file_recursive_non_existing + ${CMAKE_COMMAND} -E rm -r ${out}/not_existing.txt) + +file(MAKE_DIRECTORY ${out}/d1 ${out}/d2) +run_cmake_command(E_rm_non_recursive_directory-two-directories + ${CMAKE_COMMAND} -E rm ${out}/d1 ${out}/d2) + +run_cmake_command(E_rm_recursive_directory-two-directories + ${CMAKE_COMMAND} -E rm -R ${out}/d1 ${out}/d2) + +run_cmake_command(E_rm_no_file_specified + ${CMAKE_COMMAND} -E rm -rf) + +run_cmake_command(E_rm_empty_file_specified + ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/E_rm_empty_file_specified.cmake) + +run_cmake_command(E_rm_bad_argument + ${CMAKE_COMMAND} -E rm -rd ${out}/d1 ${out}/d2) + +file(MAKE_DIRECTORY ${out}/d1 ${out}/d2) +file(WRITE ${out}/test.txt "") +run_cmake_command(E_rm_force_recursive_directory_with_files + ${CMAKE_COMMAND} -E rm -rf ${out}/) + +run_cmake_command(E_rm_force_recursive_non_existing_file + ${CMAKE_COMMAND} -E rm -Rf ${out}/test.txt) + +if(NOT WIN32 AND NOT CYGWIN) + file(MAKE_DIRECTORY ${out}) + file(TOUCH ${out}/existing.txt) + file(MAKE_DIRECTORY ${out}/dir) + file(TOUCH ${out}/dir/existing.txt) # add a file in the folder + file(CREATE_LINK ${out}/dir ${out}/link_dir SYMBOLIC) + file(CREATE_LINK ${out}/existing.txt ${out}/existing_file_link.txt SYMBOLIC) + file(CREATE_LINK ${out}/non_existing.txt ${out}/non_existing_file_link.txt SYMBOLIC) + run_cmake_command(E_rm_file_link_existing + ${CMAKE_COMMAND} -E rm ${out}/existing_file_link.txt) + run_cmake_command(E_rm_directory_link_existing + ${CMAKE_COMMAND} -E rm ${out}/link_dir) + run_cmake_command(E_rm_file_link_non_existing + ${CMAKE_COMMAND} -E rm ${out}/non_existing_file_link.txt) + + file(CREATE_LINK ${out}/dir ${out}/link_dir SYMBOLIC) + file(CREATE_LINK ${out}/existing.txt ${out}/existing_file_link.txt SYMBOLIC) + file(CREATE_LINK ${out}/non_existing.txt ${out}/non_existing_file_link.txt SYMBOLIC) + run_cmake_command(E_rm_recursive_file_link_existing + ${CMAKE_COMMAND} -E rm -R ${out}/existing_file_link.txt) + run_cmake_command(E_rm_recursive_directory_link_existing + ${CMAKE_COMMAND} -E rm -r ${out}/link_dir) + run_cmake_command(E_rm_recursive_file_link_non_existing + ${CMAKE_COMMAND} -E rm -r ${out}/non_existing_file_link.txt) +endif() +unset(out) run_cmake_command(E_env-no-command0 ${CMAKE_COMMAND} -E env) run_cmake_command(E_env-no-command1 ${CMAKE_COMMAND} -E env TEST_ENV=1) diff --git a/Tests/RunCMake/CompilerLauncher/C-common.cmake b/Tests/RunCMake/CompilerLauncher/C-common.cmake new file mode 100644 index 0000000..96b004b --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/C-common.cmake @@ -0,0 +1,3 @@ +enable_language(C) +set(CMAKE_VERBOSE_MAKEFILE TRUE) +add_executable(main main.c) diff --git a/Tests/RunCMake/CompilerLauncher/C-env-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/C-env-Build-stdout.txt new file mode 100644 index 0000000..3313e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/C-env-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/C-env-launch-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/C-env-launch-Build-stdout.txt new file mode 100644 index 0000000..3313e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/C-env-launch-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/C-env.cmake b/Tests/RunCMake/CompilerLauncher/C-env.cmake new file mode 100644 index 0000000..09b5167 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/C-env.cmake @@ -0,0 +1 @@ +include(C-common.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/C-launch-env.cmake b/Tests/RunCMake/CompilerLauncher/C-launch-env.cmake new file mode 100644 index 0000000..68abcb5 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/C-launch-env.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(C-env.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/C.cmake b/Tests/RunCMake/CompilerLauncher/C.cmake index 67bf7c4..481e74d 100644 --- a/Tests/RunCMake/CompilerLauncher/C.cmake +++ b/Tests/RunCMake/CompilerLauncher/C.cmake @@ -1,4 +1,2 @@ -enable_language(C) set(CMAKE_C_COMPILER_LAUNCHER "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1") -set(CMAKE_VERBOSE_MAKEFILE TRUE) -add_executable(main main.c) +include(C-common.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/CUDA-common.cmake b/Tests/RunCMake/CompilerLauncher/CUDA-common.cmake new file mode 100644 index 0000000..6f7fc86 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CUDA-common.cmake @@ -0,0 +1,3 @@ +enable_language(CUDA) +set(CMAKE_VERBOSE_MAKEFILE TRUE) +add_executable(main main.cu) diff --git a/Tests/RunCMake/CompilerLauncher/CUDA-env-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/CUDA-env-Build-stdout.txt new file mode 100644 index 0000000..3313e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CUDA-env-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/CUDA-env-launch-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/CUDA-env-launch-Build-stdout.txt new file mode 100644 index 0000000..3313e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CUDA-env-launch-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/CUDA-env.cmake b/Tests/RunCMake/CompilerLauncher/CUDA-env.cmake new file mode 100644 index 0000000..cefbe9e --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CUDA-env.cmake @@ -0,0 +1 @@ +include(CUDA-common.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/CUDA-launch-env.cmake b/Tests/RunCMake/CompilerLauncher/CUDA-launch-env.cmake new file mode 100644 index 0000000..d0d777a --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CUDA-launch-env.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(CUDA-env.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/CUDA.cmake b/Tests/RunCMake/CompilerLauncher/CUDA.cmake index fe5560b..7f1652b 100644 --- a/Tests/RunCMake/CompilerLauncher/CUDA.cmake +++ b/Tests/RunCMake/CompilerLauncher/CUDA.cmake @@ -1,4 +1,2 @@ -enable_language(CUDA) set(CMAKE_CUDA_COMPILER_LAUNCHER "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1") -set(CMAKE_VERBOSE_MAKEFILE TRUE) -add_executable(main main.cu) +include(CUDA-common.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/CXX-common.cmake b/Tests/RunCMake/CompilerLauncher/CXX-common.cmake new file mode 100644 index 0000000..3d2ee00 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CXX-common.cmake @@ -0,0 +1,3 @@ +enable_language(CXX) +set(CMAKE_VERBOSE_MAKEFILE TRUE) +add_executable(main main.cxx) diff --git a/Tests/RunCMake/CompilerLauncher/CXX-env-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/CXX-env-Build-stdout.txt new file mode 100644 index 0000000..3313e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CXX-env-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/CXX-env-launch-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/CXX-env-launch-Build-stdout.txt new file mode 100644 index 0000000..3313e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CXX-env-launch-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/CXX-env.cmake b/Tests/RunCMake/CompilerLauncher/CXX-env.cmake new file mode 100644 index 0000000..db36956 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CXX-env.cmake @@ -0,0 +1 @@ +include(CXX-common.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/CXX-launch-env.cmake b/Tests/RunCMake/CompilerLauncher/CXX-launch-env.cmake new file mode 100644 index 0000000..a65cc89 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/CXX-launch-env.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(CXX-env.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/CXX.cmake b/Tests/RunCMake/CompilerLauncher/CXX.cmake index cdd3478..1f9a12b 100644 --- a/Tests/RunCMake/CompilerLauncher/CXX.cmake +++ b/Tests/RunCMake/CompilerLauncher/CXX.cmake @@ -1,4 +1,2 @@ -enable_language(CXX) set(CMAKE_CXX_COMPILER_LAUNCHER "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1") -set(CMAKE_VERBOSE_MAKEFILE TRUE) -add_executable(main main.cxx) +include(CXX-common.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/Fortran-common.cmake b/Tests/RunCMake/CompilerLauncher/Fortran-common.cmake new file mode 100644 index 0000000..e33c2ca --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/Fortran-common.cmake @@ -0,0 +1,3 @@ +enable_language(Fortran) +set(CMAKE_VERBOSE_MAKEFILE TRUE) +add_executable(main main.F) diff --git a/Tests/RunCMake/CompilerLauncher/Fortran-env-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/Fortran-env-Build-stdout.txt new file mode 100644 index 0000000..3313e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/Fortran-env-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/Fortran-env-launch-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/Fortran-env-launch-Build-stdout.txt new file mode 100644 index 0000000..3313e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/Fortran-env-launch-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/Fortran-env.cmake b/Tests/RunCMake/CompilerLauncher/Fortran-env.cmake new file mode 100644 index 0000000..3dc27c3 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/Fortran-env.cmake @@ -0,0 +1 @@ +include(Fortran-common.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/Fortran-launch-env.cmake b/Tests/RunCMake/CompilerLauncher/Fortran-launch-env.cmake new file mode 100644 index 0000000..30a196c --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/Fortran-launch-env.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(Fortran-env.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/Fortran.cmake b/Tests/RunCMake/CompilerLauncher/Fortran.cmake index 72cc03e..dc46173 100644 --- a/Tests/RunCMake/CompilerLauncher/Fortran.cmake +++ b/Tests/RunCMake/CompilerLauncher/Fortran.cmake @@ -1,4 +1,2 @@ -enable_language(Fortran) set(CMAKE_Fortran_COMPILER_LAUNCHER "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1") -set(CMAKE_VERBOSE_MAKEFILE TRUE) -add_executable(main main.F) +include(Fortran-common.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake b/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake index bb8da03..f86e8ea 100644 --- a/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake @@ -15,6 +15,13 @@ function(run_compiler_launcher lang) run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build . ${verbose_args}) endfunction() +function(run_compiler_launcher_env lang) + string(REGEX REPLACE "-.*" "" core_lang "${lang}") + set(ENV{CMAKE_${core_lang}_COMPILER_LAUNCHER} "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1") + run_compiler_launcher(${lang}) + unset(ENV{CMAKE_${core_lang}_COMPILER_LAUNCHER}) +endfunction() + set(langs C CXX) if(CMake_TEST_CUDA) list(APPEND langs CUDA) @@ -25,7 +32,9 @@ endif() foreach(lang ${langs}) run_compiler_launcher(${lang}) + run_compiler_launcher_env(${lang}-env) if (NOT RunCMake_GENERATOR STREQUAL "Watcom WMake") run_compiler_launcher(${lang}-launch) + run_compiler_launcher_env(${lang}-launch-env) endif() endforeach() diff --git a/Tests/RunCMake/FileAPI/check_index.py b/Tests/RunCMake/FileAPI/check_index.py index cda7234..23b02e9 100644 --- a/Tests/RunCMake/FileAPI/check_index.py +++ b/Tests/RunCMake/FileAPI/check_index.py @@ -109,10 +109,11 @@ def check_cmake_generator(g): name = g.get("name", None) assert is_string(name) if name.startswith("Visual Studio"): - assert sorted(g.keys()) == ["name", "platform"] + assert sorted(g.keys()) == ["multiConfig", "name", "platform"] assert is_string(g["platform"]) else: - assert sorted(g.keys()) == ["name"] + assert sorted(g.keys()) == ["multiConfig", "name"] + assert is_bool(g["multiConfig"], matches(name, "^(Visual Studio |Xcode$)")) def check_index_object(indexEntry, kind, major, minor, check): assert is_dict(indexEntry) diff --git a/Tests/RunCMake/ObjectLibrary/OwnSources-stderr.txt b/Tests/RunCMake/ObjectLibrary/OwnSources-stderr.txt index 208f3c9..cb1a2e5 100644 --- a/Tests/RunCMake/ObjectLibrary/OwnSources-stderr.txt +++ b/Tests/RunCMake/ObjectLibrary/OwnSources-stderr.txt @@ -4,4 +4,10 @@ Call Stack \(most recent call first\): CMakeLists.txt:[0-9]+ \(include\) + +CMake Error at OwnSources.cmake:[0-9]+ \(add_library\): + The SOURCES of "A" use a generator expression that depends on the SOURCES + themselves. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/ParseImplicitData/mingw.org-C-GNU-4.9.3.input b/Tests/RunCMake/ParseImplicitData/mingw.org-C-GNU-4.9.3.input index 81e9ee0..b1c4ce0 100644 --- a/Tests/RunCMake/ParseImplicitData/mingw.org-C-GNU-4.9.3.input +++ b/Tests/RunCMake/ParseImplicitData/mingw.org-C-GNU-4.9.3.input @@ -53,7 +53,7 @@ LIBRARY_PATH=c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/;c:/DoesNotExist COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles\cmTC_ab097.dir\CMakeCCompilerABI.c.obj' '-c' '-mtune=generic' '-march=i586' Linking C executable cmTC_ab097.exe "C:\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_ab097.dir\link.txt --verbose=1 -"C:\CMake\bin\cmake.exe" -E remove -f CMakeFiles\cmTC_ab097.dir/objects.a +"C:\CMake\bin\cmake.exe" -E rm -f CMakeFiles\cmTC_ab097.dir/objects.a C:\DoesNotExist\MinGW\bin\ar.exe cr CMakeFiles\cmTC_ab097.dir/objects.a @CMakeFiles\cmTC_ab097.dir\objects1.rsp C:\DoesNotExist\MinGW\bin\gcc.exe -v -Wl,--whole-archive CMakeFiles\cmTC_ab097.dir/objects.a -Wl,--no-whole-archive -o cmTC_ab097.exe -Wl,--out-implib,libcmTC_ab097.dll.a -Wl,--major-image-version,0,--minor-image-version,0 Using built-in specs. diff --git a/Tests/RunCMake/ParseImplicitData/mingw.org-CXX-GNU-4.9.3.input b/Tests/RunCMake/ParseImplicitData/mingw.org-CXX-GNU-4.9.3.input index cd77340..aae67bb 100644 --- a/Tests/RunCMake/ParseImplicitData/mingw.org-CXX-GNU-4.9.3.input +++ b/Tests/RunCMake/ParseImplicitData/mingw.org-CXX-GNU-4.9.3.input @@ -59,7 +59,7 @@ LIBRARY_PATH=c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/;c:/DoesNotExist COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles\cmTC_2b790.dir\CMakeCXXCompilerABI.cpp.obj' '-c' '-shared-libgcc' '-mtune=generic' '-march=i586' Linking CXX executable cmTC_2b790.exe "C:\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_2b790.dir\link.txt --verbose=1 -"C:\CMake\bin\cmake.exe" -E remove -f CMakeFiles\cmTC_2b790.dir/objects.a +"C:\CMake\bin\cmake.exe" -E rm -f CMakeFiles\cmTC_2b790.dir/objects.a C:\DoesNotExist\MinGW\bin\ar.exe cr CMakeFiles\cmTC_2b790.dir/objects.a @CMakeFiles\cmTC_2b790.dir\objects1.rsp C:\DoesNotExist\MinGW\bin\g++.exe -v -Wl,--whole-archive CMakeFiles\cmTC_2b790.dir/objects.a -Wl,--no-whole-archive -o cmTC_2b790.exe -Wl,--out-implib,libcmTC_2b790.dll.a -Wl,--major-image-version,0,--minor-image-version,0 Using built-in specs. diff --git a/Tests/RunCMake/PrecompileHeaders/DisabledPch-check.cmake b/Tests/RunCMake/PrecompileHeaders/DisabledPch-check.cmake index 8cf0fc9..494bcf7 100644 --- a/Tests/RunCMake/PrecompileHeaders/DisabledPch-check.cmake +++ b/Tests/RunCMake/PrecompileHeaders/DisabledPch-check.cmake @@ -1,10 +1,5 @@ -if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) - set(foo_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foo.dir/CMakeFiles/foo.dir/cmake_pch.h") - set(foobar_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/CMakeFiles/foobar.dir/cmake_pch.h") -else() - set(foo_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foo.dir/cmake_pch.h") - set(foobar_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/cmake_pch.h") -endif() +set(foo_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foo.dir/cmake_pch.h") +set(foobar_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/cmake_pch.h") if (NOT EXISTS ${foo_pch_header}) set(RunCMake_TEST_FAILED "Generated foo pch header ${foo_pch_header} does not exist") diff --git a/Tests/RunCMake/PrecompileHeaders/PchInterface-check.cmake b/Tests/RunCMake/PrecompileHeaders/PchInterface-check.cmake index caeb22b..4e62b81 100644 --- a/Tests/RunCMake/PrecompileHeaders/PchInterface-check.cmake +++ b/Tests/RunCMake/PrecompileHeaders/PchInterface-check.cmake @@ -1,10 +1,5 @@ -if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) - set(foo_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foo.dir/CMakeFiles/foo.dir/cmake_pch.h") - set(foobar_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/CMakeFiles/foobar.dir/cmake_pch.h") -else() - set(foo_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foo.dir/cmake_pch.h") - set(foobar_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/cmake_pch.h") -endif() +set(foo_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foo.dir/cmake_pch.h") +set(foobar_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/cmake_pch.h") if (NOT EXISTS ${foo_pch_header}) set(RunCMake_TEST_FAILED "Generated foo pch header ${foo_pch_header} does not exist") diff --git a/Tests/RunCMake/PrecompileHeaders/PchMultilanguage-check.cmake b/Tests/RunCMake/PrecompileHeaders/PchMultilanguage-check.cmake index e0b753a..cc01ecb 100644 --- a/Tests/RunCMake/PrecompileHeaders/PchMultilanguage-check.cmake +++ b/Tests/RunCMake/PrecompileHeaders/PchMultilanguage-check.cmake @@ -1,10 +1,5 @@ -if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) - set(foobar_pch_h_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/CMakeFiles/foobar.dir/cmake_pch.h") - set(foobar_pch_hxx_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/CMakeFiles/foobar.dir/cmake_pch.hxx") -else() - set(foobar_pch_h_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/cmake_pch.h") - set(foobar_pch_hxx_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/cmake_pch.hxx") -endif() +set(foobar_pch_h_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/cmake_pch.h") +set(foobar_pch_hxx_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/cmake_pch.hxx") if (NOT EXISTS ${foobar_pch_h_header}) set(RunCMake_TEST_FAILED "Generated foobar C pch header ${foobar_pch_h_header} does not exist") diff --git a/Tests/RunCMake/PrecompileHeaders/PchPrologueEpilogue-check.cmake b/Tests/RunCMake/PrecompileHeaders/PchPrologueEpilogue-check.cmake index ba220f3..9018664 100644 --- a/Tests/RunCMake/PrecompileHeaders/PchPrologueEpilogue-check.cmake +++ b/Tests/RunCMake/PrecompileHeaders/PchPrologueEpilogue-check.cmake @@ -1,8 +1,4 @@ -if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) - set(main_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/main.dir/CMakeFiles/main.dir/cmake_pch.hxx") -else() - set(main_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/main.dir/cmake_pch.hxx") -endif() +set(main_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/main.dir/cmake_pch.hxx") file(STRINGS ${main_pch_header} main_pch_header_strings) string(REGEX MATCH "#pragma warning\\(push, 0\\).*#include.*pch.h.*#pragma warning\\(pop\\)" matched_code ${main_pch_header_strings}) diff --git a/Tests/RunCMake/PrecompileHeaders/PchReuseFrom.cmake b/Tests/RunCMake/PrecompileHeaders/PchReuseFrom.cmake index 4502456..03a97ed 100644 --- a/Tests/RunCMake/PrecompileHeaders/PchReuseFrom.cmake +++ b/Tests/RunCMake/PrecompileHeaders/PchReuseFrom.cmake @@ -1,8 +1,12 @@ cmake_minimum_required(VERSION 3.15) project(PchReuseFrom C) +if(CMAKE_C_COMPILE_OPTIONS_USE_PCH) + add_definitions(-DHAVE_PCH_SUPPORT) +endif() + add_library(empty empty.c) -target_precompile_headers(empty PUBLIC +target_precompile_headers(empty PRIVATE <stdio.h> <string.h> ) @@ -12,6 +16,9 @@ add_library(foo foo.c) target_include_directories(foo PUBLIC include) target_precompile_headers(foo REUSE_FROM empty) +# should not cause problems if configured multiple times +target_precompile_headers(foo REUSE_FROM empty) + add_executable(foobar foobar.c) target_link_libraries(foobar foo ) set_target_properties(foobar PROPERTIES PRECOMPILE_HEADERS_REUSE_FROM foo) diff --git a/Tests/RunCMake/PrecompileHeaders/PchReuseFromPrefixed-build-stderr.txt b/Tests/RunCMake/PrecompileHeaders/PchReuseFromPrefixed-build-stderr.txt new file mode 100644 index 0000000..8cdcfd9 --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/PchReuseFromPrefixed-build-stderr.txt @@ -0,0 +1,2 @@ +^(|Warning #670: precompiled header file [^ +]* was not generated in this directory)$ diff --git a/Tests/RunCMake/PrecompileHeaders/PchReuseFromPrefixed.cmake b/Tests/RunCMake/PrecompileHeaders/PchReuseFromPrefixed.cmake new file mode 100644 index 0000000..e306d8e --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/PchReuseFromPrefixed.cmake @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.15) +project(PchReuseFromPrefixed C) + +if(CMAKE_C_COMPILE_OPTIONS_USE_PCH) + add_definitions(-DHAVE_PCH_SUPPORT) +endif() + +add_library(empty empty.c) +target_precompile_headers(empty PRIVATE + <stdio.h> + <string.h> +) +target_include_directories(empty PUBLIC include) + +add_library(foo foo.c) +target_include_directories(foo PUBLIC include) +target_precompile_headers(foo REUSE_FROM empty) + +# Visual Studio 2017 and greater +if (NOT (CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_LESS_EQUAL 19.10)) + set_target_properties(foo PROPERTIES PREFIX "lib" IMPORT_PREFIX "lib") +endif() + +add_executable(foobar foobar.c) +target_link_libraries(foobar foo ) +set_target_properties(foobar PROPERTIES PRECOMPILE_HEADERS_REUSE_FROM empty) + +enable_testing() +add_test(NAME foobar COMMAND foobar) diff --git a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake index ec13663..8d2f4f9 100644 --- a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake +++ b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake @@ -17,5 +17,6 @@ run_test(PchInterface) run_cmake(PchPrologueEpilogue) run_test(SkipPrecompileHeaders) run_test(PchReuseFrom) +run_test(PchReuseFromPrefixed) run_test(PchReuseFromSubdir) run_cmake(PchMultilanguage) diff --git a/Tests/RunCMake/PrecompileHeaders/foobar.c b/Tests/RunCMake/PrecompileHeaders/foobar.c index 7a135ea..97d465c 100644 --- a/Tests/RunCMake/PrecompileHeaders/foobar.c +++ b/Tests/RunCMake/PrecompileHeaders/foobar.c @@ -4,5 +4,11 @@ int main() { - return foo() + foo2() + bar(); + int zeroSize = 0; + +#ifdef HAVE_PCH_SUPPORT + zeroSize = (int)strlen(""); +#endif + + return foo() + foo2() + bar() + zeroSize; } diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt index 6d72fac..9a1e027 100644 --- a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt +++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt @@ -28,6 +28,7 @@ \* CMP0081 \* CMP0083 \* CMP0095 + \* CMP0099 Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/UnityBuild/RunCMakeTest.cmake b/Tests/RunCMake/UnityBuild/RunCMakeTest.cmake index 8e484d0..24daa64 100644 --- a/Tests/RunCMake/UnityBuild/RunCMakeTest.cmake +++ b/Tests/RunCMake/UnityBuild/RunCMakeTest.cmake @@ -21,3 +21,4 @@ function(run_test name) endfunction() run_test(unitybuild_runtest) +run_test(unitybuild_object_library) diff --git a/Tests/RunCMake/UnityBuild/unitybuild_object_library.cmake b/Tests/RunCMake/UnityBuild/unitybuild_object_library.cmake new file mode 100644 index 0000000..b400517 --- /dev/null +++ b/Tests/RunCMake/UnityBuild/unitybuild_object_library.cmake @@ -0,0 +1,13 @@ +project(unitybuild_object_library C) + +set(CMAKE_UNITY_BUILD ON) # This tests that the variable works in addition to the property + +add_library(lib OBJECT func.c) + +add_library(other-lib STATIC func.c) + +add_executable(main main.c) +target_link_libraries(main PRIVATE lib) + +enable_testing() +add_test(NAME main COMMAND main) diff --git a/Tests/RunCMake/UnityBuild/unitybuild_runtest.cmake b/Tests/RunCMake/UnityBuild/unitybuild_runtest.cmake index 8816299..3589cc8 100644 --- a/Tests/RunCMake/UnityBuild/unitybuild_runtest.cmake +++ b/Tests/RunCMake/UnityBuild/unitybuild_runtest.cmake @@ -2,6 +2,7 @@ project(unitybuild_runtest C) set(CMAKE_UNITY_BUILD ON) # This tests that the variable works in addition to the property +add_library(lib main.c func.c) add_executable(main main.c func.c) enable_testing() diff --git a/Tests/RunCMake/UnityBuild/unitybuild_skip-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_skip-check.cmake index 61419d8..fdd45bc 100644 --- a/Tests/RunCMake/UnityBuild/unitybuild_skip-check.cmake +++ b/Tests/RunCMake/UnityBuild/unitybuild_skip-check.cmake @@ -1,9 +1,9 @@ set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.c") file(STRINGS ${unitybuild_c} unitybuild_c_strings) -string(REGEX MATCH "\\/s[2-6].c" matched_files_2_6 ${unitybuild_c_strings}) -if(matched_files_2_6) - set(RunCMake_TEST_FAILED "Generated unity contains s2.c -> s6.c which should have been skipped") +string(REGEX MATCH "\\/s[1-6].c" matched_files_1_6 ${unitybuild_c_strings}) +if(matched_files_1_6) + set(RunCMake_TEST_FAILED "Generated unity contains s1.c -> s6.c which should have been skipped") return() endif() diff --git a/Tests/RunCMake/UnityBuild/unitybuild_skip.cmake b/Tests/RunCMake/UnityBuild/unitybuild_skip.cmake index eef8ccc..94e5aa3 100644 --- a/Tests/RunCMake/UnityBuild/unitybuild_skip.cmake +++ b/Tests/RunCMake/UnityBuild/unitybuild_skip.cmake @@ -1,7 +1,7 @@ project(unitybuild_skip C) set(srcs "") -foreach(s RANGE 2 8) +foreach(s RANGE 1 8) set(src "${CMAKE_CURRENT_BINARY_DIR}/s${s}.c") file(WRITE "${src}" "int s${s}(void) { return 0; }\n") list(APPEND srcs "${src}") @@ -11,6 +11,9 @@ add_library(tgt SHARED ${srcs}) set_target_properties(tgt PROPERTIES UNITY_BUILD ON) +set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/s1.c + PROPERTIES HEADER_FILE_ONLY ON) + set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/s2.c PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON) diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index 9e82841..6ecf3f2 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -54,6 +54,20 @@ endfunction() XcodeDependOnZeroCheck() +function(XcodeObjcxxFlags testName) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${testName}-build) + set(RunCMake_TEST_NO_CLEAN 1) + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(${testName}) + run_cmake_command(${testName}-build ${CMAKE_COMMAND} --build .) +endfunction() + +XcodeObjcxxFlags(XcodeObjcFlags) +XcodeObjcxxFlags(XcodeObjcxxFlags) + # Isolate device tests from host architecture selection. unset(ENV{CMAKE_OSX_ARCHITECTURES}) diff --git a/Tests/RunCMake/XcodeProject/XcodeObjcFlags.cmake b/Tests/RunCMake/XcodeProject/XcodeObjcFlags.cmake new file mode 100644 index 0000000..4840276 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeObjcFlags.cmake @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.15) +project(objctest LANGUAGES C OBJC) + +include(CheckOBJCCompilerFlag) +check_objc_compiler_flag(-fobjc-arc HAVE_OBJC_ARC) + +if(HAVE_OBJC_ARC) + add_compile_options(-fobjc-arc) + add_compile_definitions(HAVE_OBJC_ARC) +endif() + +add_library(myfuncs STATIC myfuncs.m) diff --git a/Tests/RunCMake/XcodeProject/XcodeObjcxxFlags.cmake b/Tests/RunCMake/XcodeProject/XcodeObjcxxFlags.cmake new file mode 100644 index 0000000..0ad942f --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeObjcxxFlags.cmake @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.15) +project(objcxxtest LANGUAGES CXX OBJCXX) + +include(CheckOBJCXXCompilerFlag) +check_objcxx_compiler_flag(-fobjc-arc HAVE_OBJC_ARC) + +if(HAVE_OBJC_ARC) + add_compile_options(-fobjc-arc) + add_compile_definitions(HAVE_OBJC_ARC) +endif() + +add_library(myfuncs STATIC myfuncs.mm) diff --git a/Tests/RunCMake/XcodeProject/XcodeSchemaProperty-check.cmake b/Tests/RunCMake/XcodeProject/XcodeSchemaProperty-check.cmake index 7d83a70..c742f50 100644 --- a/Tests/RunCMake/XcodeProject/XcodeSchemaProperty-check.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeSchemaProperty-check.cmake @@ -45,6 +45,7 @@ check_property("ENVIRONMENT" [=[key="FOO"]=]) check_property("ENVIRONMENT" [=[value="foo"]=]) check_property("ENVIRONMENT" [=[key="BAR"]=]) check_property("ENVIRONMENT" [=[value="bar"]=]) +check_property("WORKING_DIRECTORY" [=["/working/dir"]=]) expect_no_schema("NoSchema") diff --git a/Tests/RunCMake/XcodeProject/XcodeSchemaProperty.cmake b/Tests/RunCMake/XcodeProject/XcodeSchemaProperty.cmake index be219f4..ce5c0c9 100644 --- a/Tests/RunCMake/XcodeProject/XcodeSchemaProperty.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeSchemaProperty.cmake @@ -35,6 +35,7 @@ endfunction() create_scheme_for_property(EXECUTABLE myExecutable) create_scheme_for_property(ARGUMENTS "--foo;--bar=baz") create_scheme_for_property(ENVIRONMENT "FOO=foo;BAR=bar") +create_scheme_for_property(WORKING_DIRECTORY "/working/dir") add_executable(NoSchema main.cpp) set_target_properties(NoSchema PROPERTIES XCODE_GENERATE_SCHEME OFF) diff --git a/Tests/RunCMake/XcodeProject/myfuncs.m b/Tests/RunCMake/XcodeProject/myfuncs.m new file mode 100644 index 0000000..742ba8e --- /dev/null +++ b/Tests/RunCMake/XcodeProject/myfuncs.m @@ -0,0 +1,3 @@ +#if defined(HAVE_OBJC_ARC) && ! __has_feature(objc_arc) +#error THIS CODE MUST BE COMPILED WITH ARC ENABLED! +#endif diff --git a/Tests/RunCMake/XcodeProject/myfuncs.mm b/Tests/RunCMake/XcodeProject/myfuncs.mm new file mode 100644 index 0000000..742ba8e --- /dev/null +++ b/Tests/RunCMake/XcodeProject/myfuncs.mm @@ -0,0 +1,3 @@ +#if defined(HAVE_OBJC_ARC) && ! __has_feature(objc_arc) +#error THIS CODE MUST BE COMPILED WITH ARC ENABLED! +#endif diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake index 6877e6a..84d1d66 100644 --- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake @@ -1,6 +1,9 @@ include(RunCTest) set(RunCMake_TEST_TIMEOUT 60) +unset(ENV{CTEST_PARALLEL_LEVEL}) +unset(ENV{CTEST_OUTPUT_ON_FAILURE}) + set(CASE_CTEST_TEST_ARGS "") set(CASE_CTEST_TEST_LOAD "") @@ -71,7 +74,24 @@ add_test(NAME PassingTest COMMAND ${CMAKE_COMMAND} -E echo PassingTestOutput) add_test(NAME FailingTest COMMAND ${CMAKE_COMMAND} -E no_such_command) ]]) - unset(ENV{CTEST_PARALLEL_LEVEL}) run_ctest(TestOutputSize) endfunction() run_TestOutputSize() + +run_ctest_test(TestRepeatBad1 REPEAT UNKNOWN:3) +run_ctest_test(TestRepeatBad2 REPEAT UNTIL_FAIL:-1) + +function(run_TestRepeat case) + set(CASE_CTEST_TEST_ARGS EXCLUDE RunCMakeVersion ${ARGN}) + string(CONCAT CASE_CMAKELISTS_SUFFIX_CODE [[ +add_test(NAME testRepeat + COMMAND ${CMAKE_COMMAND} -D COUNT_FILE=${CMAKE_CURRENT_BINARY_DIR}/count.cmake + -P "]] "${RunCMake_SOURCE_DIR}/TestRepeat${case}" [[.cmake") +set_property(TEST testRepeat PROPERTY TIMEOUT 5) + ]]) + + run_ctest(TestRepeat${case}) +endfunction() +run_TestRepeat(UntilFail REPEAT UNTIL_FAIL:3) +run_TestRepeat(UntilPass REPEAT UNTIL_PASS:3) +run_TestRepeat(AfterTimeout REPEAT AFTER_TIMEOUT:3) diff --git a/Tests/RunCMake/ctest_test/TestRepeatAfterTimeout-stdout.txt b/Tests/RunCMake/ctest_test/TestRepeatAfterTimeout-stdout.txt new file mode 100644 index 0000000..17657c5 --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatAfterTimeout-stdout.txt @@ -0,0 +1,10 @@ +Test project [^ +]*/Tests/RunCMake/ctest_test/TestRepeatAfterTimeout-build + Start 1: testRepeat +1/1 Test #1: testRepeat .......................\*\*\*Timeout +[0-9.]+ sec + Start 1: testRepeat + Test #1: testRepeat ....................... Passed +[0-9.]+ sec ++ +100% tests passed, 0 tests failed out of 1 ++ +Total Test time \(real\) = +[0-9.]+ sec$ diff --git a/Tests/RunCMake/ctest_test/TestRepeatAfterTimeout.cmake b/Tests/RunCMake/ctest_test/TestRepeatAfterTimeout.cmake new file mode 100644 index 0000000..abde4f0 --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatAfterTimeout.cmake @@ -0,0 +1,10 @@ +include("${COUNT_FILE}" OPTIONAL) +if(NOT COUNT) + set(COUNT 0) +endif() +math(EXPR COUNT "${COUNT} + 1") +file(WRITE "${COUNT_FILE}" "set(COUNT ${COUNT})\n") +if(NOT COUNT EQUAL 2) + message("this test times out except on the 2nd run") + execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 10) +endif() diff --git a/Tests/RunCMake/ctest_test/TestRepeatBad1-result.txt b/Tests/RunCMake/ctest_test/TestRepeatBad1-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatBad1-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_test/TestRepeatBad1-stderr.txt b/Tests/RunCMake/ctest_test/TestRepeatBad1-stderr.txt new file mode 100644 index 0000000..37cffbf --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatBad1-stderr.txt @@ -0,0 +1 @@ +Repeat option invalid value: UNKNOWN:3 diff --git a/Tests/RunCMake/ctest_test/TestRepeatBad2-result.txt b/Tests/RunCMake/ctest_test/TestRepeatBad2-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatBad2-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_test/TestRepeatBad2-stderr.txt b/Tests/RunCMake/ctest_test/TestRepeatBad2-stderr.txt new file mode 100644 index 0000000..ca5cef7 --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatBad2-stderr.txt @@ -0,0 +1 @@ +Repeat option invalid value: UNTIL_FAIL:-1 diff --git a/Tests/RunCMake/ctest_test/TestRepeatUntilFail-stdout.txt b/Tests/RunCMake/ctest_test/TestRepeatUntilFail-stdout.txt new file mode 100644 index 0000000..5f91a67 --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatUntilFail-stdout.txt @@ -0,0 +1,13 @@ +Test project [^ +]*/Tests/RunCMake/ctest_test/TestRepeatUntilFail-build + Start 1: testRepeat + Test #1: testRepeat ....................... Passed +[0-9.]+ sec + Start 1: testRepeat + Test #1: testRepeat .......................\*\*\*Failed +[0-9.]+ sec ++ +0% tests passed, 1 tests failed out of 1 ++ +Total Test time \(real\) = +[0-9.]+ sec ++ +The following tests FAILED: +[ ]+1 - testRepeat \(Failed\)$ diff --git a/Tests/RunCMake/ctest_test/TestRepeatUntilFail.cmake b/Tests/RunCMake/ctest_test/TestRepeatUntilFail.cmake new file mode 100644 index 0000000..5eb0d8a --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatUntilFail.cmake @@ -0,0 +1,9 @@ +include("${COUNT_FILE}" OPTIONAL) +if(NOT COUNT) + set(COUNT 0) +endif() +math(EXPR COUNT "${COUNT} + 1") +file(WRITE "${COUNT_FILE}" "set(COUNT ${COUNT})\n") +if(COUNT EQUAL 2) + message(FATAL_ERROR "this test fails on the 2nd run") +endif() diff --git a/Tests/RunCMake/ctest_test/TestRepeatUntilPass-stdout.txt b/Tests/RunCMake/ctest_test/TestRepeatUntilPass-stdout.txt new file mode 100644 index 0000000..bc6939a --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatUntilPass-stdout.txt @@ -0,0 +1,10 @@ +Test project [^ +]*/Tests/RunCMake/ctest_test/TestRepeatUntilPass-build + Start 1: testRepeat +1/1 Test #1: testRepeat .......................\*\*\*Failed +[0-9.]+ sec + Start 1: testRepeat + Test #1: testRepeat ....................... Passed +[0-9.]+ sec ++ +100% tests passed, 0 tests failed out of 1 ++ +Total Test time \(real\) = +[0-9.]+ sec$ diff --git a/Tests/RunCMake/ctest_test/TestRepeatUntilPass.cmake b/Tests/RunCMake/ctest_test/TestRepeatUntilPass.cmake new file mode 100644 index 0000000..0662522 --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestRepeatUntilPass.cmake @@ -0,0 +1,9 @@ +include("${COUNT_FILE}" OPTIONAL) +if(NOT COUNT) + set(COUNT 0) +endif() +math(EXPR COUNT "${COUNT} + 1") +file(WRITE "${COUNT_FILE}" "set(COUNT ${COUNT})\n") +if(NOT COUNT EQUAL 2) + message(FATAL_ERROR "this test passes only on the 2nd run") +endif() diff --git a/Tests/RunCMake/foreach/RunCMakeTest.cmake b/Tests/RunCMake/foreach/RunCMakeTest.cmake index 0f1fdd4..8f50203 100644 --- a/Tests/RunCMake/foreach/RunCMakeTest.cmake +++ b/Tests/RunCMake/foreach/RunCMakeTest.cmake @@ -2,3 +2,13 @@ include(RunCMake) run_cmake(BadRangeInFunction) run_cmake(foreach-all-test) +run_cmake(foreach-ITEMS-multiple-iter-vars-test) +run_cmake(foreach-LISTS-multiple-iter-vars-test) +run_cmake(foreach-ZIP_LISTS-test) +run_cmake(foreach-ITEMS-with-ZIP_LISTS-mix-test) +run_cmake(foreach-LISTS-with-ZIP_LISTS-mix-test) +run_cmake(foreach-ZIP_LISTS-with-ITEMS-mix-test) +run_cmake(foreach-ZIP_LISTS-with-LISTS-mix-test) +run_cmake(foreach-ZIP_LISTS-multiple-iter-vars-test) +run_cmake(foreach-ZIP_LISTS-iter-vars-mismatch-test-1) +run_cmake(foreach-ZIP_LISTS-iter-vars-mismatch-test-2) diff --git a/Tests/RunCMake/foreach/foreach-ITEMS-multiple-iter-vars-test-result.txt b/Tests/RunCMake/foreach/foreach-ITEMS-multiple-iter-vars-test-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ITEMS-multiple-iter-vars-test-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-ITEMS-multiple-iter-vars-test-stderr.txt b/Tests/RunCMake/foreach/foreach-ITEMS-multiple-iter-vars-test-stderr.txt new file mode 100644 index 0000000..d174bb1 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ITEMS-multiple-iter-vars-test-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-ITEMS-multiple-iter-vars-test.cmake:1 \(foreach\): + ITEMS or LISTS require exactly one iteration variable +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/foreach/foreach-ITEMS-multiple-iter-vars-test.cmake b/Tests/RunCMake/foreach/foreach-ITEMS-multiple-iter-vars-test.cmake new file mode 100644 index 0000000..55d33a8 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ITEMS-multiple-iter-vars-test.cmake @@ -0,0 +1,2 @@ +foreach(one two IN ITEMS one two) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-ITEMS-with-ZIP_LISTS-mix-test-result.txt b/Tests/RunCMake/foreach/foreach-ITEMS-with-ZIP_LISTS-mix-test-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ITEMS-with-ZIP_LISTS-mix-test-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-ITEMS-with-ZIP_LISTS-mix-test-stderr.txt b/Tests/RunCMake/foreach/foreach-ITEMS-with-ZIP_LISTS-mix-test-stderr.txt new file mode 100644 index 0000000..f7d5ae7 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ITEMS-with-ZIP_LISTS-mix-test-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-ITEMS-with-ZIP_LISTS-mix-test.cmake:1 \(foreach\): + ZIP_LISTS can not be used with LISTS or ITEMS +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/foreach/foreach-ITEMS-with-ZIP_LISTS-mix-test.cmake b/Tests/RunCMake/foreach/foreach-ITEMS-with-ZIP_LISTS-mix-test.cmake new file mode 100644 index 0000000..28099a0 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ITEMS-with-ZIP_LISTS-mix-test.cmake @@ -0,0 +1,2 @@ +foreach(i IN ITEMS one two three ZIP_LISTS blah) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-LISTS-multiple-iter-vars-test-result.txt b/Tests/RunCMake/foreach/foreach-LISTS-multiple-iter-vars-test-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-LISTS-multiple-iter-vars-test-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-LISTS-multiple-iter-vars-test-stderr.txt b/Tests/RunCMake/foreach/foreach-LISTS-multiple-iter-vars-test-stderr.txt new file mode 100644 index 0000000..f2f83c2 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-LISTS-multiple-iter-vars-test-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-LISTS-multiple-iter-vars-test.cmake:1 \(foreach\): + ITEMS or LISTS require exactly one iteration variable +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/foreach/foreach-LISTS-multiple-iter-vars-test.cmake b/Tests/RunCMake/foreach/foreach-LISTS-multiple-iter-vars-test.cmake new file mode 100644 index 0000000..78f3847 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-LISTS-multiple-iter-vars-test.cmake @@ -0,0 +1,2 @@ +foreach(one two IN LISTS one two) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-LISTS-with-ZIP_LISTS-mix-test-result.txt b/Tests/RunCMake/foreach/foreach-LISTS-with-ZIP_LISTS-mix-test-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-LISTS-with-ZIP_LISTS-mix-test-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-LISTS-with-ZIP_LISTS-mix-test-stderr.txt b/Tests/RunCMake/foreach/foreach-LISTS-with-ZIP_LISTS-mix-test-stderr.txt new file mode 100644 index 0000000..42f8d1e --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-LISTS-with-ZIP_LISTS-mix-test-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-LISTS-with-ZIP_LISTS-mix-test.cmake:1 \(foreach\): + ZIP_LISTS can not be used with LISTS or ITEMS +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/foreach/foreach-LISTS-with-ZIP_LISTS-mix-test.cmake b/Tests/RunCMake/foreach/foreach-LISTS-with-ZIP_LISTS-mix-test.cmake new file mode 100644 index 0000000..8a919dd --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-LISTS-with-ZIP_LISTS-mix-test.cmake @@ -0,0 +1,2 @@ +foreach(i IN LISTS one two three ZIP_LISTS blah) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-1-result.txt b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-1-stderr.txt b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-1-stderr.txt new file mode 100644 index 0000000..fa51e46 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-1-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-ZIP_LISTS-iter-vars-mismatch-test-1.cmake:1 \(foreach\): + Expected 3 list variables, but given 4 +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-1.cmake b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-1.cmake new file mode 100644 index 0000000..458b6ca --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-1.cmake @@ -0,0 +1,2 @@ +foreach(less than lists IN ZIP_LISTS list_1 list_2 list_3 list_4) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-2-result.txt b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-2-stderr.txt b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-2-stderr.txt new file mode 100644 index 0000000..7b6b484 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-2-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-ZIP_LISTS-iter-vars-mismatch-test-2.cmake:1 \(foreach\): + Expected 3 list variables, but given 2 +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-2.cmake b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-2.cmake new file mode 100644 index 0000000..d24d99c --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-iter-vars-mismatch-test-2.cmake @@ -0,0 +1,2 @@ +foreach(greater than lists IN ZIP_LISTS list_1 list_2) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-multiple-iter-vars-test-stdout.txt b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-multiple-iter-vars-test-stdout.txt new file mode 100644 index 0000000..e009d15 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-multiple-iter-vars-test-stdout.txt @@ -0,0 +1,6 @@ +-- foreach\(\.\.\. IN ZIP_LISTS\): +-- Begin output +-- | one, satu, raz +-- | two, dua, dva +-- | three, tiga, tri +-- End output diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-multiple-iter-vars-test.cmake b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-multiple-iter-vars-test.cmake new file mode 100644 index 0000000..9647dea --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-multiple-iter-vars-test.cmake @@ -0,0 +1,42 @@ +function(foreachTest result list_var_1 list_var_2 list_var_3) + set(_options MUTE) + set(_one_value_args) + set(_multi_value_args) + cmake_parse_arguments(PARSE_ARGV 3 _arg "${_options}" "${_one_value_args}" "${_multi_value_args}") + + set(_has_any_output FALSE) + list(APPEND CMAKE_MESSAGE_INDENT "| ") + foreach(first second third IN ZIP_LISTS ${list_var_1} ${list_var_2} ${list_var_3}) + if(NOT first) + set(first "[undefiend]") + endif() + if(NOT second) + set(second "[undefiend]") + endif() + if(NOT third) + set(third "[undefiend]") + endif() + if(NOT _arg_MUTE) + message(STATUS "${first}, ${second}, ${third}") + endif() + set(_has_any_output TRUE) + endforeach() + set(${result} ${_has_any_output} PARENT_SCOPE) +endfunction() + +function(foreachTestDecorated list_var_1 list_var_2 list_var_3) + list(APPEND CMAKE_MESSAGE_INDENT " ") + message(STATUS "Begin output") + foreachTest(_has_any_output ${list_var_1} ${list_var_2} ${list_var_3}) + if(NOT _has_any_output) + message(STATUS "--> empty-output <--") + endif() + message(STATUS "End output") +endfunction() + +list(APPEND english one two three) +list(APPEND bahasa satu dua tiga) +list(APPEND russian raz dva tri) + +message(STATUS "foreach(... IN ZIP_LISTS):") +foreachTestDecorated(english bahasa russian) diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-test-stdout.txt b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-test-stdout.txt new file mode 100644 index 0000000..25433fd --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-test-stdout.txt @@ -0,0 +1,19 @@ +-- foreach\(IN ZIP_LISTS\): +-- <<< empty lists case >>> +-- Begin output +-- --> empty-output <-- +-- End output +-- <<< same lengths lists case >>> +-- Begin output +-- | one, satu, raz +-- | two, dua, dva +-- | three, tiga, tri +-- End output +-- <<< different lengths lists case >>> +-- Begin output +-- | one, satu, raz +-- | two, dua, dva +-- | three, tiga, tri +-- | \[undefiend\], empat, \[undefiend\] +-- End output +-- <<< test variable value restored -- PASSED >>> diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-test.cmake b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-test.cmake new file mode 100644 index 0000000..56cfe64 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-test.cmake @@ -0,0 +1,68 @@ +function(foreachTest result list_var_1 list_var_2 list_var_3) + set(_options MUTE) + set(_one_value_args) + set(_multi_value_args) + cmake_parse_arguments(PARSE_ARGV 3 _arg "${_options}" "${_one_value_args}" "${_multi_value_args}") + + set(_has_any_output FALSE) + list(APPEND CMAKE_MESSAGE_INDENT "| ") + foreach(num IN ZIP_LISTS ${list_var_1} ${list_var_2} ${list_var_3}) + foreach(i RANGE 2) + if(NOT num_${i}) + set(num_${i} "[undefiend]") + endif() + endforeach() + if(NOT _arg_MUTE) + message(STATUS "${num_0}, ${num_1}, ${num_2}") + endif() + set(_has_any_output TRUE) + endforeach() + set(${result} ${_has_any_output} PARENT_SCOPE) +endfunction() + +function(foreachTestDecorated list_var_1 list_var_2 list_var_3) + list(APPEND CMAKE_MESSAGE_INDENT " ") + message(STATUS "Begin output") + foreachTest(_has_any_output ${list_var_1} ${list_var_2} ${list_var_3}) + if(NOT _has_any_output) + message(STATUS "--> empty-output <--") + endif() + message(STATUS "End output") +endfunction() + +message(STATUS "foreach(IN ZIP_LISTS):") +list(APPEND CMAKE_MESSAGE_INDENT " ") + +set(english) +set(bahasa) +set(russian) + +message(STATUS "<<< empty lists case >>>") +foreachTestDecorated(english bahasa russian) + +list(APPEND english one two three) +list(APPEND bahasa satu dua tiga) +list(APPEND russian raz dva tri) + +message(STATUS "<<< same lengths lists case >>>") +foreachTestDecorated(english bahasa russian) + +list(APPEND bahasa empat) + +message(STATUS "<<< different lengths lists case >>>") +foreachTestDecorated(english bahasa russian) + +set(num_0 "old-0") +set(num_1 "old-1") +set(num_2 "old-2") +foreachTest(_ english bahasa russian MUTE) +set(check PASSED) +foreach(i RANGE 2) + if(NOT "${num_${i}}" STREQUAL "old-${i}") + message(SEND_ERROR "num_${i} value is corrupted") + set(check FAILED) + endif() +endforeach() +message(STATUS "<<< test variable value restored -- ${check} >>>") + +list(POP_BACK CMAKE_MESSAGE_INDENT) diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-ITEMS-mix-test-result.txt b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-ITEMS-mix-test-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-ITEMS-mix-test-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-ITEMS-mix-test-stderr.txt b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-ITEMS-mix-test-stderr.txt new file mode 100644 index 0000000..0dcab01 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-ITEMS-mix-test-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-ZIP_LISTS-with-ITEMS-mix-test.cmake:1 \(foreach\): + ZIP_LISTS can not be used with LISTS or ITEMS +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-ITEMS-mix-test.cmake b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-ITEMS-mix-test.cmake new file mode 100644 index 0000000..71ed842 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-ITEMS-mix-test.cmake @@ -0,0 +1,2 @@ +foreach(i IN ZIP_LISTS blah ITEMS blah) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-LISTS-mix-test-result.txt b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-LISTS-mix-test-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-LISTS-mix-test-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-LISTS-mix-test-stderr.txt b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-LISTS-mix-test-stderr.txt new file mode 100644 index 0000000..a6b6e9c --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-LISTS-mix-test-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-ZIP_LISTS-with-LISTS-mix-test.cmake:1 \(foreach\): + ZIP_LISTS can not be used with LISTS or ITEMS +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-LISTS-mix-test.cmake b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-LISTS-mix-test.cmake new file mode 100644 index 0000000..11a97b2 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-ZIP_LISTS-with-LISTS-mix-test.cmake @@ -0,0 +1,2 @@ +foreach(i IN ZIP_LISTS blah LISTS blah) +endforeach() diff --git a/Tests/RunCMake/load_cache/CMakeLists.txt b/Tests/RunCMake/load_cache/CMakeLists.txt new file mode 100644 index 0000000..2632ffa --- /dev/null +++ b/Tests/RunCMake/load_cache/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.16) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/load_cache/NewForm_Project.cmake b/Tests/RunCMake/load_cache/NewForm_Project.cmake new file mode 100644 index 0000000..13a450b --- /dev/null +++ b/Tests/RunCMake/load_cache/NewForm_Project.cmake @@ -0,0 +1,16 @@ +load_cache(${CMAKE_CURRENT_BINARY_DIR}/../test_project READ_WITH_PREFIX LOAD_CACHE_TEST_ + CACHE_STRING + CACHE_BOOL + CACHE_INTERNAL) + +if(NOT LOAD_CACHE_TEST_CACHE_STRING STREQUAL "cache string") + message(FATAL_ERROR "CACHE_STRING: was ${CACHE_STRING}, expected \"cache string\"") +endif() + +if(NOT LOAD_CACHE_TEST_CACHE_BOOL) + message(FATAL_ERROR "CACHE_BOOL: was falsey, expected ON") +endif() + +if(NOT LOAD_CACHE_TEST_CACHE_INTERNAL STREQUAL "cache internal") + message(FATAL_ERROR "CACHE_INTERNAL: was ${CACHE_INTENRAL}, expected \"cache internal\"") +endif() diff --git a/Tests/RunCMake/load_cache/NewForm_Script.cmake b/Tests/RunCMake/load_cache/NewForm_Script.cmake new file mode 100644 index 0000000..f3cee92 --- /dev/null +++ b/Tests/RunCMake/load_cache/NewForm_Script.cmake @@ -0,0 +1,16 @@ +load_cache(${RunCMake_BINARY_DIR}/test_project READ_WITH_PREFIX LOAD_CACHE_TEST_ + CACHE_STRING + CACHE_BOOL + CACHE_INTERNAL) + +if(NOT LOAD_CACHE_TEST_CACHE_STRING STREQUAL "cache string") + message(FATAL_ERROR "CACHE_STRING: was ${CACHE_STRING}, expected \"cache string\"") +endif() + +if(NOT LOAD_CACHE_TEST_CACHE_BOOL) + message(FATAL_ERROR "CACHE_BOOL: was falsey, expected ON") +endif() + +if(NOT LOAD_CACHE_TEST_CACHE_INTERNAL STREQUAL "cache internal") + message(FATAL_ERROR "CACHE_INTERNAL: was ${CACHE_INTENRAL}, expected \"cache internal\"") +endif() diff --git a/Tests/RunCMake/load_cache/OldForm_Script-result.txt b/Tests/RunCMake/load_cache/OldForm_Script-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/load_cache/OldForm_Script-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/load_cache/OldForm_Script-stderr.txt b/Tests/RunCMake/load_cache/OldForm_Script-stderr.txt new file mode 100644 index 0000000..9ad5c80 --- /dev/null +++ b/Tests/RunCMake/load_cache/OldForm_Script-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error at.*/Tests/RunCMake/load_cache/OldForm_Script.cmake:1 \(load_cache\): + load_cache Only load_cache\(READ_WITH_PREFIX\) may be used in script mode$ diff --git a/Tests/RunCMake/load_cache/OldForm_Script.cmake b/Tests/RunCMake/load_cache/OldForm_Script.cmake new file mode 100644 index 0000000..9560f61 --- /dev/null +++ b/Tests/RunCMake/load_cache/OldForm_Script.cmake @@ -0,0 +1,13 @@ +load_cache(${RunCMake_BINARY_DIR}/test_project INCLUDE_INTERNALS CACHE_INTERNAL) + +if(NOT CACHE_STRING STREQUAL "cache string") + message(FATAL_ERROR "CACHE_STRING: was ${CACHE_STRING}, expected \"cache string\"") +endif() + +if(NOT CACHE_BOOL) + message(FATAL_ERROR "CACHE_BOOL: was falsey, expected ON") +endif() + +if(NOT CACHE_INTERNAL STREQUAL "cache internal") + message(FATAL_ERROR "CACHE_INTERNAL: was ${CACHE_INTENRAL}, expected \"cache internal\"") +endif() diff --git a/Tests/RunCMake/load_cache/RunCMakeTest.cmake b/Tests/RunCMake/load_cache/RunCMakeTest.cmake new file mode 100644 index 0000000..a0d54ea --- /dev/null +++ b/Tests/RunCMake/load_cache/RunCMakeTest.cmake @@ -0,0 +1,13 @@ +include(RunCMake) + +file(WRITE ${RunCMake_BINARY_DIR}/test_project/CMakeCache.txt [[ +CACHE_STRING:STRING=cache string +CACHE_BOOL:BOOL=ON +CACHE_INTERNAL:INTERNAL=cache internal +]]) + +run_cmake(NewForm_Project) +run_cmake_command(NewForm_Script ${CMAKE_COMMAND} -DRunCMake_BINARY_DIR=${RunCMake_BINARY_DIR} + -P "${RunCMake_SOURCE_DIR}/NewForm_Script.cmake") +run_cmake_command(OldForm_Script ${CMAKE_COMMAND} -DRunCMake_BINARY_DIR=${RunCMake_BINARY_DIR} + -P "${RunCMake_SOURCE_DIR}/OldForm_Script.cmake") diff --git a/Tests/RunCMake/target_link_directories/CMP0099-NEW-basic-check.cmake b/Tests/RunCMake/target_link_directories/CMP0099-NEW-basic-check.cmake new file mode 100644 index 0000000..2fffddd --- /dev/null +++ b/Tests/RunCMake/target_link_directories/CMP0099-NEW-basic-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "DIR_INTERFACE") + string (APPEND RunCMake_TEST_FAILED "\nNot found expected 'DIR_INTERFACE'.") +endif() diff --git a/Tests/RunCMake/target_link_directories/CMP0099-NEW-basic-result.txt b/Tests/RunCMake/target_link_directories/CMP0099-NEW-basic-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_directories/CMP0099-NEW-basic-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_directories/CMP0099-NEW.cmake b/Tests/RunCMake/target_link_directories/CMP0099-NEW.cmake new file mode 100644 index 0000000..17dd68e --- /dev/null +++ b/Tests/RunCMake/target_link_directories/CMP0099-NEW.cmake @@ -0,0 +1,4 @@ + +cmake_policy(SET CMP0099 NEW) + +include(${CMAKE_CURRENT_SOURCE_DIR}/CMP0099.cmake) diff --git a/Tests/RunCMake/target_link_directories/CMP0099-OLD-basic-check.cmake b/Tests/RunCMake/target_link_directories/CMP0099-OLD-basic-check.cmake new file mode 100644 index 0000000..16573a7 --- /dev/null +++ b/Tests/RunCMake/target_link_directories/CMP0099-OLD-basic-check.cmake @@ -0,0 +1,4 @@ + +if (actual_stdout MATCHES "DIR_INTERFACE") + string (APPEND RunCMake_TEST_FAILED "\nFound unexpected 'DIR_INTERFACE'.") +endif() diff --git a/Tests/RunCMake/target_link_directories/CMP0099-OLD-basic-result.txt b/Tests/RunCMake/target_link_directories/CMP0099-OLD-basic-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_directories/CMP0099-OLD-basic-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_directories/CMP0099-OLD.cmake b/Tests/RunCMake/target_link_directories/CMP0099-OLD.cmake new file mode 100644 index 0000000..193a4c7 --- /dev/null +++ b/Tests/RunCMake/target_link_directories/CMP0099-OLD.cmake @@ -0,0 +1,4 @@ + +cmake_policy(SET CMP0099 OLD) + +include(${CMAKE_CURRENT_SOURCE_DIR}/CMP0099.cmake) diff --git a/Tests/RunCMake/target_link_directories/CMP0099.cmake b/Tests/RunCMake/target_link_directories/CMP0099.cmake new file mode 100644 index 0000000..a2be279 --- /dev/null +++ b/Tests/RunCMake/target_link_directories/CMP0099.cmake @@ -0,0 +1,14 @@ + +enable_language(C) + +set(CMAKE_VERBOSE_MAKEFILE TRUE) +set(CMAKE_C_USE_RESPONSE_FILE_FOR_LIBRARIES FALSE) + +add_library(LinkDirs_interface INTERFACE) +target_link_directories (LinkDirs_interface INTERFACE "/DIR_INTERFACE"}) + +add_library(LinkDirs_static STATIC lib.c) +target_link_libraries (LinkDirs_static PRIVATE LinkDirs_interface) + +add_executable(LinkDirs_exe exe.c) +target_link_libraries (LinkDirs_exe PRIVATE LinkDirs_static) diff --git a/Tests/RunCMake/target_link_directories/RunCMakeTest.cmake b/Tests/RunCMake/target_link_directories/RunCMakeTest.cmake index b67c598..a74ee25 100644 --- a/Tests/RunCMake/target_link_directories/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_directories/RunCMakeTest.cmake @@ -1,3 +1,33 @@ include(RunCMake) +macro(run_cmake_target test subtest target) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(${test}-${subtest} ${CMAKE_COMMAND} --build . --target ${target} ${ARGN}) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) +endmacro() + run_cmake(empty_keyword_args) + +if(RunCMake_GENERATOR MATCHES "(Ninja|Makefiles)" AND + NOT RunCMake_GENERATOR MATCHES "(NMake|Borland)") + set(RunCMake_TEST_OUTPUT_MERGE TRUE) + if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release) + endif() + if (RunCMake_GENERATOR MATCHES "Ninja") + set(VERBOSE -- -v) + endif() + + run_cmake(CMP0099-NEW) + run_cmake_target(CMP0099-NEW basic LinkDirs_exe ${VERBOSE}) + + + run_cmake(CMP0099-OLD) + run_cmake_target(CMP0099-OLD basic LinkDirs_exe ${VERBOSE}) + + unset(RunCMake_TEST_OPTIONS) + unset(RunCMake_TEST_OUTPUT_MERGE) +endif() diff --git a/Tests/RunCMake/target_link_directories/exe.c b/Tests/RunCMake/target_link_directories/exe.c new file mode 100644 index 0000000..8488f4e --- /dev/null +++ b/Tests/RunCMake/target_link_directories/exe.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/RunCMake/target_link_directories/lib.c b/Tests/RunCMake/target_link_directories/lib.c new file mode 100644 index 0000000..9bbd24c --- /dev/null +++ b/Tests/RunCMake/target_link_directories/lib.c @@ -0,0 +1,7 @@ +#if defined(_WIN32) +__declspec(dllexport) +#endif + int flags_lib(void) +{ + return 0; +} diff --git a/Tests/RunCMake/target_link_options/CMP0099-NEW-basic-check.cmake b/Tests/RunCMake/target_link_options/CMP0099-NEW-basic-check.cmake new file mode 100644 index 0000000..555bc37 --- /dev/null +++ b/Tests/RunCMake/target_link_options/CMP0099-NEW-basic-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "BADFLAG_INTERFACE") + string (APPEND RunCMake_TEST_FAILED "\nNot found expected 'BADFLAG_INTERFACE'.") +endif() diff --git a/Tests/RunCMake/target_link_options/CMP0099-NEW-basic-result.txt b/Tests/RunCMake/target_link_options/CMP0099-NEW-basic-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_options/CMP0099-NEW-basic-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_options/CMP0099-NEW.cmake b/Tests/RunCMake/target_link_options/CMP0099-NEW.cmake new file mode 100644 index 0000000..17dd68e --- /dev/null +++ b/Tests/RunCMake/target_link_options/CMP0099-NEW.cmake @@ -0,0 +1,4 @@ + +cmake_policy(SET CMP0099 NEW) + +include(${CMAKE_CURRENT_SOURCE_DIR}/CMP0099.cmake) diff --git a/Tests/RunCMake/target_link_options/CMP0099-OLD-basic-check.cmake b/Tests/RunCMake/target_link_options/CMP0099-OLD-basic-check.cmake new file mode 100644 index 0000000..4f159f1 --- /dev/null +++ b/Tests/RunCMake/target_link_options/CMP0099-OLD-basic-check.cmake @@ -0,0 +1,4 @@ + +if (actual_stdout MATCHES "BADFLAG_INTERFACE") + string (APPEND RunCMake_TEST_FAILED "\nFound unexpected 'BADFLAG_INTERFACE'.") +endif() diff --git a/Tests/RunCMake/target_link_options/CMP0099-OLD-basic-result.txt b/Tests/RunCMake/target_link_options/CMP0099-OLD-basic-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_options/CMP0099-OLD-basic-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_options/CMP0099-OLD.cmake b/Tests/RunCMake/target_link_options/CMP0099-OLD.cmake new file mode 100644 index 0000000..193a4c7 --- /dev/null +++ b/Tests/RunCMake/target_link_options/CMP0099-OLD.cmake @@ -0,0 +1,4 @@ + +cmake_policy(SET CMP0099 OLD) + +include(${CMAKE_CURRENT_SOURCE_DIR}/CMP0099.cmake) diff --git a/Tests/RunCMake/target_link_options/CMP0099.cmake b/Tests/RunCMake/target_link_options/CMP0099.cmake new file mode 100644 index 0000000..9dee964 --- /dev/null +++ b/Tests/RunCMake/target_link_options/CMP0099.cmake @@ -0,0 +1,16 @@ + +enable_language(C) + +set(obj "${CMAKE_C_OUTPUT_EXTENSION}") +if(BORLAND) + set(pre -) +endif() + +add_library(LinkOptions_interface INTERFACE) +target_link_options (LinkOptions_interface INTERFACE ${pre}BADFLAG_INTERFACE${obj}) + +add_library(LinkOptions_static STATIC LinkOptionsLib.c) +target_link_libraries (LinkOptions_static PRIVATE LinkOptions_interface) + +add_executable(LinkOptions_exe LinkOptionsExe.c) +target_link_libraries (LinkOptions_exe PRIVATE LinkOptions_static) diff --git a/Tests/RunCMake/target_link_options/RunCMakeTest.cmake b/Tests/RunCMake/target_link_options/RunCMakeTest.cmake index 1d9ef8b..cdfdd7b 100644 --- a/Tests/RunCMake/target_link_options/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_options/RunCMakeTest.cmake @@ -41,3 +41,21 @@ if(RunCMake_GENERATOR MATCHES "(Ninja|Makefile)") endif() run_cmake(empty_keyword_args) + +if (NOT CMAKE_C_COMPILER_ID STREQUAL "Intel") + # Intel compiler does not reject bad flags or objects! + set(RunCMake_TEST_OUTPUT_MERGE TRUE) + if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release) + endif() + + run_cmake(CMP0099-NEW) + run_cmake_target(CMP0099-NEW basic LinkOptions_exe) + + + run_cmake(CMP0099-OLD) + run_cmake_target(CMP0099-OLD basic LinkOptions_exe) + + unset(RunCMake_TEST_OPTIONS) + unset(RunCMake_TEST_OUTPUT_MERGE) +endif() diff --git a/Tests/RunCMake/try_compile/ObjCStandard-result.txt b/Tests/RunCMake/try_compile/ObjCStandard-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/try_compile/ObjCStandard-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/ObjCStandard-stderr.txt b/Tests/RunCMake/try_compile/ObjCStandard-stderr.txt new file mode 100644 index 0000000..f1b4df9 --- /dev/null +++ b/Tests/RunCMake/try_compile/ObjCStandard-stderr.txt @@ -0,0 +1,7 @@ +^CMake Error at .*/Tests/RunCMake/try_compile/ObjCStandard-build/CMakeFiles/CMakeTmp/CMakeLists.txt:[0-9]+ \(add_executable\): + OBJC_STANDARD is set to invalid value '3' ++ +CMake Error at ObjCStandard.cmake:[0-9]+ \(try_compile\): + Failed to generate test project build system. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/try_compile/ObjCStandard.cmake b/Tests/RunCMake/try_compile/ObjCStandard.cmake new file mode 100644 index 0000000..b2066f9 --- /dev/null +++ b/Tests/RunCMake/try_compile/ObjCStandard.cmake @@ -0,0 +1,7 @@ +enable_language(OBJC) +try_compile(result ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.m + OBJC_STANDARD 3 + OUTPUT_VARIABLE out + ) +message("try_compile output:\n${out}") diff --git a/Tests/RunCMake/try_compile/ObjCxxStandard-result.txt b/Tests/RunCMake/try_compile/ObjCxxStandard-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/try_compile/ObjCxxStandard-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/ObjCxxStandard-stderr.txt b/Tests/RunCMake/try_compile/ObjCxxStandard-stderr.txt new file mode 100644 index 0000000..a2f91b4 --- /dev/null +++ b/Tests/RunCMake/try_compile/ObjCxxStandard-stderr.txt @@ -0,0 +1,7 @@ +^CMake Error at .*/Tests/RunCMake/try_compile/ObjCxxStandard-build/CMakeFiles/CMakeTmp/CMakeLists.txt:[0-9]+ \(add_executable\): + OBJCXX_STANDARD is set to invalid value '3' ++ +CMake Error at ObjCxxStandard.cmake:[0-9]+ \(try_compile\): + Failed to generate test project build system. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/try_compile/ObjCxxStandard.cmake b/Tests/RunCMake/try_compile/ObjCxxStandard.cmake new file mode 100644 index 0000000..1221805 --- /dev/null +++ b/Tests/RunCMake/try_compile/ObjCxxStandard.cmake @@ -0,0 +1,7 @@ +enable_language(OBJCXX) +try_compile(result ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.mm + OBJCXX_STANDARD 3 + OUTPUT_VARIABLE out + ) +message("try_compile output:\n${out}") diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index 77fb7a0..91f014e 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -37,11 +37,17 @@ if(CMAKE_C_STANDARD_DEFAULT) elseif(DEFINED CMAKE_C_STANDARD_DEFAULT) run_cmake(CStandardNoDefault) endif() +if(CMAKE_OBJC_STANDARD_DEFAULT) + run_cmake(ObjCStandard) +endif() if(CMAKE_CXX_STANDARD_DEFAULT) run_cmake(CxxStandard) elseif(DEFINED CMAKE_CXX_STANDARD_DEFAULT) run_cmake(CxxStandardNoDefault) endif() +if(CMAKE_OBJCXX_STANDARD_DEFAULT) + run_cmake(ObjCxxStandard) +endif() if(CMake_TEST_CUDA) if(CMAKE_HOST_WIN32) run_cmake(CudaStandardNoDefault) diff --git a/Tests/RunCMake/try_compile/src.m b/Tests/RunCMake/try_compile/src.m new file mode 100644 index 0000000..f8b643a --- /dev/null +++ b/Tests/RunCMake/try_compile/src.m @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/RunCMake/try_compile/src.mm b/Tests/RunCMake/try_compile/src.mm new file mode 100644 index 0000000..f8b643a --- /dev/null +++ b/Tests/RunCMake/try_compile/src.mm @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} |