diff options
Diffstat (limited to 'Tests/RunCMake')
29 files changed, 217 insertions, 4 deletions
diff --git a/Tests/RunCMake/CMP0104/CMP0104-OLD-stderr.txt b/Tests/RunCMake/CMP0104/CMP0104-OLD-stderr.txt new file mode 100644 index 0000000..66d3016 --- /dev/null +++ b/Tests/RunCMake/CMP0104/CMP0104-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0104-OLD.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0104 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CMP0106/CMP0106-OLD-stderr.txt b/Tests/RunCMake/CMP0106/CMP0106-OLD-stderr.txt new file mode 100644 index 0000000..ef48d5c --- /dev/null +++ b/Tests/RunCMake/CMP0106/CMP0106-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0106-OLD.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0106 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 6c5ab7f..3f92829 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -752,7 +752,8 @@ add_RunCMake_test(CheckCompilerFlag -DCMake_TEST_CUDA=${CMake_TEST_CUDA} add_RunCMake_test(CheckSourceCompiles -DCMake_TEST_CUDA=${CMake_TEST_CUDA} -DCMake_TEST_ISPC=${CMake_TEST_ISPC} -DCMAKE_Fortran_COMPILER_ID=${CMAKE_Fortran_COMPILER_ID} - -DCMake_TEST_HIP=${CMake_TEST_HIP}) + -DCMake_TEST_HIP=${CMake_TEST_HIP} + -DCMake_TEST_Swift=${CMake_TEST_Swift}) add_RunCMake_test(CheckSourceRuns -DCMake_TEST_CUDA=${CMake_TEST_CUDA} -DCMAKE_Fortran_COMPILER_ID=${CMAKE_Fortran_COMPILER_ID} -DCMake_TEST_HIP=${CMake_TEST_HIP}) diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake index 3f17c1f..921fabd 100644 --- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake +++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake @@ -120,7 +120,9 @@ function (run_cxx_module_test directory) if (RunCMake_CXXModules_INSTALL) run_cmake_command("examples/${test_name}-install" "${CMAKE_COMMAND}" --build . --target install --config Debug) endif () - run_cmake_command("examples/${test_name}-test" "${CMAKE_CTEST_COMMAND}" -C Debug --output-on-failure) + if (NOT RunCMake_CXXModules_NO_TEST) + run_cmake_command("examples/${test_name}-test" "${CMAKE_CTEST_COMMAND}" -C Debug --output-on-failure) + endif () endfunction () string(REPLACE "," ";" CMake_TEST_MODULE_COMPILATION "${CMake_TEST_MODULE_COMPILATION}") @@ -132,6 +134,10 @@ if ("named" IN_LIST CMake_TEST_MODULE_COMPILATION) run_cxx_module_test(generated) run_cxx_module_test(public-req-private) run_cxx_module_test(deep-chain) + run_cxx_module_test(duplicate) + set(RunCMake_CXXModules_NO_TEST 1) + run_cxx_module_test(circular) + unset(RunCMake_CXXModules_NO_TEST) endif () # Tests which use named modules in shared libraries. diff --git a/Tests/RunCMake/CXXModules/examples/circular-build-result.txt b/Tests/RunCMake/CXXModules/examples/circular-build-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/circular-build-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CXXModules/examples/circular-build-stdout.txt b/Tests/RunCMake/CXXModules/examples/circular-build-stdout.txt new file mode 100644 index 0000000..433b461 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/circular-build-stdout.txt @@ -0,0 +1 @@ +(Ninja generators)?(build stopped: dependency cycle:) diff --git a/Tests/RunCMake/CXXModules/examples/circular-stderr.txt b/Tests/RunCMake/CXXModules/examples/circular-stderr.txt new file mode 100644 index 0000000..5e4392a --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/circular-stderr.txt @@ -0,0 +1,9 @@ +CMake Warning \(dev\) at CMakeLists.txt:7 \(target_sources\): + CMake's C\+\+ module support is experimental. It is meant only for + experimentation and feedback to CMake developers. +This warning is for project developers. Use -Wno-dev to suppress it. + +CMake Warning \(dev\): + C\+\+20 modules support via CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP is + experimental. It is meant only for compiler developers to try. +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/circular/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/circular/CMakeLists.txt new file mode 100644 index 0000000..4d1997c --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/circular/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.24) +project(cxx_modules_circular CXX) + +include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") + +add_library(circular STATIC) +target_sources(circular + PUBLIC + FILE_SET CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + circular-a.cppm + circular-b.cppm) +target_compile_features(circular PUBLIC cxx_std_20) diff --git a/Tests/RunCMake/CXXModules/examples/circular/circular-a.cppm b/Tests/RunCMake/CXXModules/examples/circular/circular-a.cppm new file mode 100644 index 0000000..eea842b --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/circular/circular-a.cppm @@ -0,0 +1,6 @@ +export module a; +import b; + +export int a() { + return b(); +} diff --git a/Tests/RunCMake/CXXModules/examples/circular/circular-b.cppm b/Tests/RunCMake/CXXModules/examples/circular/circular-b.cppm new file mode 100644 index 0000000..fc6dc42 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/circular/circular-b.cppm @@ -0,0 +1,6 @@ +export module b; +import a; + +export int b() { + return a(); +} diff --git a/Tests/RunCMake/CXXModules/examples/duplicate-stderr.txt b/Tests/RunCMake/CXXModules/examples/duplicate-stderr.txt new file mode 100644 index 0000000..5e4392a --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/duplicate-stderr.txt @@ -0,0 +1,9 @@ +CMake Warning \(dev\) at CMakeLists.txt:7 \(target_sources\): + CMake's C\+\+ module support is experimental. It is meant only for + experimentation and feedback to CMake developers. +This warning is for project developers. Use -Wno-dev to suppress it. + +CMake Warning \(dev\): + C\+\+20 modules support via CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP is + experimental. It is meant only for compiler developers to try. +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/duplicate/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/duplicate/CMakeLists.txt new file mode 100644 index 0000000..27be7a8 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/duplicate/CMakeLists.txt @@ -0,0 +1,39 @@ +cmake_minimum_required(VERSION 3.24) +project(cxx_modules_duplicate CXX) + +include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") + +add_executable(duplicate) +target_sources(duplicate + PRIVATE + main.cxx + PRIVATE + FILE_SET CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + duplicate.cxx) +target_compile_features(duplicate PRIVATE cxx_std_20) +target_compile_definitions(duplicate PRIVATE NDUPLICATE=1) + +add_executable(duplicate2) +target_sources(duplicate2 + PRIVATE + main.cxx + PRIVATE + FILE_SET CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + duplicate.cxx) +target_compile_features(duplicate2 PRIVATE cxx_std_20) +target_compile_definitions(duplicate2 PRIVATE NDUPLICATE=2) + +add_test(NAME duplicate COMMAND duplicate) +set_property(TEST duplicate + PROPERTY + PASS_REGULAR_EXPRESSION "From duplicate #1") +add_test(NAME duplicate2 COMMAND duplicate2) +set_property(TEST duplicate2 + PROPERTY + PASS_REGULAR_EXPRESSION "From duplicate #2") diff --git a/Tests/RunCMake/CXXModules/examples/duplicate/duplicate.cxx b/Tests/RunCMake/CXXModules/examples/duplicate/duplicate.cxx new file mode 100644 index 0000000..c0c820b --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/duplicate/duplicate.cxx @@ -0,0 +1,11 @@ +module; + +#include <iostream> + +export module duplicate; + +export int from_import() +{ + std::cerr << "From duplicate #" << NDUPLICATE << std::endl; + return 0; +} diff --git a/Tests/RunCMake/CXXModules/examples/duplicate/main.cxx b/Tests/RunCMake/CXXModules/examples/duplicate/main.cxx new file mode 100644 index 0000000..c2c0636 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/duplicate/main.cxx @@ -0,0 +1,6 @@ +import duplicate; + +int main(int argc, char* argv[]) +{ + return from_import(); +} diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesSwift.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesSwift.cmake new file mode 100644 index 0000000..767fa69 --- /dev/null +++ b/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesSwift.cmake @@ -0,0 +1,15 @@ +enable_language(Swift) +include(CheckSourceCompiles) + +set(Swift 1) # test that this is tolerated + +check_source_compiles(Swift "baz()" SHOULD_FAIL) + +if(SHOULD_FAIL) + message(SEND_ERROR "invalid Swift source didn't fail.") +endif() + +check_source_compiles(Swift "print(\"Hello, CMake\")" SHOULD_BUILD) +if(NOT SHOULD_BUILD) + message(SEND_ERROR "Test failed for valid Swift source.") +endif() diff --git a/Tests/RunCMake/CheckSourceCompiles/RunCMakeTest.cmake b/Tests/RunCMake/CheckSourceCompiles/RunCMakeTest.cmake index df77d3d..2ed3e36 100644 --- a/Tests/RunCMake/CheckSourceCompiles/RunCMakeTest.cmake +++ b/Tests/RunCMake/CheckSourceCompiles/RunCMakeTest.cmake @@ -31,3 +31,7 @@ endif() if(CMake_TEST_HIP) run_cmake(CheckSourceCompilesHIP) endif() + +if(CMake_TEST_Swift) + run_cmake(CheckSourceCompilesSwift) +endif() diff --git a/Tests/RunCMake/CommandLine/Envgen-bad-help-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-bad-help-stderr.txt new file mode 100644 index 0000000..cdfe857 --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-bad-help-stderr.txt @@ -0,0 +1 @@ +CMake Error: CMAKE_GENERATOR was set but the specified generator doesn't exist. Using CMake default. diff --git a/Tests/RunCMake/CommandLine/Envgen-bad-help-stdout.txt b/Tests/RunCMake/CommandLine/Envgen-bad-help-stdout.txt new file mode 100644 index 0000000..075c48c --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-bad-help-stdout.txt @@ -0,0 +1,2 @@ +Generators.* +\* (Unix Makefiles|Visual Studio).* diff --git a/Tests/RunCMake/CommandLine/Envgen-ninja-multi-help-stdout.txt b/Tests/RunCMake/CommandLine/Envgen-ninja-multi-help-stdout.txt new file mode 100644 index 0000000..ece6e5d --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-ninja-multi-help-stdout.txt @@ -0,0 +1 @@ +\* Ninja Multi-Config[ ]+= Generates build-<Config>.ninja files. diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index a2eeddf..327b772 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -349,6 +349,13 @@ function(run_EnvironmentGenerator) run_cmake_command(Envgen-bad ${CMAKE_COMMAND} -G) unset(ENV{CMAKE_GENERATOR}) + # Honor CMAKE_GENERATOR env var in --help output + set(ENV{CMAKE_GENERATOR} "Ninja Multi-Config") + run_cmake_command(Envgen-ninja-multi-help ${CMAKE_COMMAND} --help) + set(ENV{CMAKE_GENERATOR} "NoSuchGenerator") + run_cmake_command(Envgen-bad-help ${CMAKE_COMMAND} --help) + unset(ENV{CMAKE_GENERATOR}) + if(RunCMake_GENERATOR MATCHES "Visual Studio.*") set(ENV{CMAKE_GENERATOR} "${RunCMake_GENERATOR}") run_cmake_command(Envgen ${CMAKE_COMMAND} ${source_dir}) @@ -940,6 +947,7 @@ unset(RunCMake_TEST_OPTIONS) set(RunCMake_TEST_OPTIONS --trace) run_cmake(trace) +run_cmake(trace-try_compile) unset(RunCMake_TEST_OPTIONS) set(RunCMake_TEST_OPTIONS --trace-expand) @@ -952,6 +960,7 @@ unset(RunCMake_TEST_OPTIONS) set(RunCMake_TEST_OPTIONS --trace-redirect=${RunCMake_BINARY_DIR}/redirected.trace) run_cmake(trace-redirect) +run_cmake(trace-try_compile-redirect) unset(RunCMake_TEST_OPTIONS) set(RunCMake_TEST_OPTIONS --trace-redirect=/no/such/file.txt) diff --git a/Tests/RunCMake/CommandLine/trace-try_compile-redirect-check.cmake b/Tests/RunCMake/CommandLine/trace-try_compile-redirect-check.cmake new file mode 100644 index 0000000..94a7c95 --- /dev/null +++ b/Tests/RunCMake/CommandLine/trace-try_compile-redirect-check.cmake @@ -0,0 +1,13 @@ +file(READ ${RunCMake_SOURCE_DIR}/trace-try_compile-stderr.txt expected_content) +string(REGEX REPLACE "\n+$" "" expected_content "${expected_content}") + +file(READ ${RunCMake_BINARY_DIR}/redirected.trace actual_content) +string(REGEX REPLACE "\r\n" "\n" actual_content "${actual_content}") +string(REGEX REPLACE "\n+$" "" actual_content "${actual_content}") +if(NOT "${actual_content}" MATCHES "${expected_content}") + set(RunCMake_TEST_FAILED + "Trace file content does not match that expected." + "Expected to match:\n${expected_content}\n" + "Actual content:\n${actual_content}\n" + ) +endif() diff --git a/Tests/RunCMake/CommandLine/trace-try_compile-redirect.cmake b/Tests/RunCMake/CommandLine/trace-try_compile-redirect.cmake new file mode 100644 index 0000000..982cb89 --- /dev/null +++ b/Tests/RunCMake/CommandLine/trace-try_compile-redirect.cmake @@ -0,0 +1,2 @@ +cmake_minimum_required(VERSION 3.24) +project(test C) diff --git a/Tests/RunCMake/CommandLine/trace-try_compile-stderr.txt b/Tests/RunCMake/CommandLine/trace-try_compile-stderr.txt new file mode 100644 index 0000000..1674b8f --- /dev/null +++ b/Tests/RunCMake/CommandLine/trace-try_compile-stderr.txt @@ -0,0 +1,4 @@ +.*Modules/CMakeDetermineCompilerABI.cmake\([0-9]+\): try_compile\([^)]+\) +.*Tests/RunCMake/CommandLine/trace-try_compile(-redirect)?-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+/CMakeLists.txt\([0-9]+\): cmake_minimum_required.* +.*Tests/RunCMake/CommandLine/trace-try_compile(-redirect)?-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+/CMakeLists.txt\([0-9]+\): project\(CMAKE_TRY_COMPILE.* +.*Tests/RunCMake/CommandLine/trace-try_compile(-redirect)?-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+/CMakeLists.txt\([0-9]+\): add_executable\(cmTC_.* diff --git a/Tests/RunCMake/CommandLine/trace-try_compile.cmake b/Tests/RunCMake/CommandLine/trace-try_compile.cmake new file mode 100644 index 0000000..982cb89 --- /dev/null +++ b/Tests/RunCMake/CommandLine/trace-try_compile.cmake @@ -0,0 +1,2 @@ +cmake_minimum_required(VERSION 3.24) +project(test C) diff --git a/Tests/RunCMake/alias_targets/duplicate-target-CMP0107-OLD-stderr.txt b/Tests/RunCMake/alias_targets/duplicate-target-CMP0107-OLD-stderr.txt new file mode 100644 index 0000000..f5247ca --- /dev/null +++ b/Tests/RunCMake/alias_targets/duplicate-target-CMP0107-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at duplicate-target-CMP0107-OLD.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0107 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/export/Repeat-CMP0103-OLD-stderr.txt b/Tests/RunCMake/export/Repeat-CMP0103-OLD-stderr.txt new file mode 100644 index 0000000..1183f86 --- /dev/null +++ b/Tests/RunCMake/export/Repeat-CMP0103-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at Repeat-CMP0103-OLD.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0103 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/string/Timestamp-stderr.txt b/Tests/RunCMake/string/Timestamp-stderr.txt index f162f52..c57bba6 100644 --- a/Tests/RunCMake/string/Timestamp-stderr.txt +++ b/Tests/RunCMake/string/Timestamp-stderr.txt @@ -1 +1 @@ -RESULT=2005-08-07 23:19:49.000000 Sunday=Sun August=Aug 05 day=219 wd=0 week=32 w_iso=31 %I=11 epoch=1123456789 +^RESULT=2005-08-07 23:19:49.000000 Sunday=Sun August=Aug 05 day=219 wd=0 week=32 w_iso=31 %I=11 epoch=1123456789 TZ=GMT tz=\+0000$ diff --git a/Tests/RunCMake/string/Timestamp.cmake b/Tests/RunCMake/string/Timestamp.cmake index 531a237..3d68b1a 100644 --- a/Tests/RunCMake/string/Timestamp.cmake +++ b/Tests/RunCMake/string/Timestamp.cmake @@ -1,3 +1,3 @@ set(ENV{SOURCE_DATE_EPOCH} "1123456789") -string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S.%f %A=%a %B=%b %y day=%j wd=%w week=%U w_iso=%V %%I=%I epoch=%s" UTC) +string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S.%f %A=%a %B=%b %y day=%j wd=%w week=%U w_iso=%V %%I=%I epoch=%s TZ=%Z tz=%z" UTC) message("RESULT=${RESULT}") diff --git a/Tests/RunCMake/target_link_libraries/CMP0108-OLD-self-link-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0108-OLD-self-link-stderr.txt new file mode 100644 index 0000000..07e9a9f --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/CMP0108-OLD-self-link-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0108-OLD-self-link.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0108 will be removed from a future version + of CMake. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ |