diff options
Diffstat (limited to 'Tests/RunCMake')
121 files changed, 579 insertions, 31 deletions
diff --git a/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake b/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake index 3784a6a..f268de7 100644 --- a/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake +++ b/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake @@ -6,8 +6,8 @@ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") # configure the AutoExport test run_cmake(AutoExport) unset(RunCMake_TEST_OPTIONS) -# don't run this test on VS 6 as it is not supported -if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 6|Watcom WMake|Borland Makefiles") +# don't run this test on Watcom or Borland make as it is not supported +if("${RunCMake_GENERATOR}" MATCHES "Watcom WMake|Borland Makefiles") return() endif() # we build debug so the say.exe will be found in Debug/say.exe for diff --git a/Tests/RunCMake/BuildDepends/MakeInProjectOnly.c b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.c new file mode 100644 index 0000000..bcb8745 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.c @@ -0,0 +1,2 @@ +#include <MakeInProjectOnly.h> +int main() { return MakeInProjectOnly(); } diff --git a/Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake new file mode 100644 index 0000000..add9aeb --- /dev/null +++ b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake @@ -0,0 +1,16 @@ +enable_language(C) +get_filename_component(include_dir "${CMAKE_BINARY_DIR}" PATH) +include_directories("${include_dir}") +add_executable(MakeInProjectOnly MakeInProjectOnly.c) +set(CMAKE_DEPENDS_IN_PROJECT_ONLY 1) +file(GENERATE OUTPUT check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT " +if (check_step EQUAL 1) + set(check_pairs + \"$<TARGET_FILE:MakeInProjectOnly>|${include_dir}/MakeInProjectOnly.h\" + ) +else() + set(check_pairs + \"${include_dir}/MakeInProjectOnly.h|\$<TARGET_FILE:MakeInProjectOnly>\" + ) +endif() +") diff --git a/Tests/RunCMake/BuildDepends/MakeInProjectOnly.step1.cmake b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.step1.cmake new file mode 100644 index 0000000..d6551ab --- /dev/null +++ b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.step1.cmake @@ -0,0 +1,3 @@ +file(WRITE "${RunCMake_TEST_BINARY_DIR}/../MakeInProjectOnly.h" [[ +int MakeInProjectOnly(void) { return 0; } +]]) diff --git a/Tests/RunCMake/BuildDepends/MakeInProjectOnly.step2.cmake b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.step2.cmake new file mode 100644 index 0000000..145605b --- /dev/null +++ b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.step2.cmake @@ -0,0 +1,3 @@ +file(WRITE "${RunCMake_TEST_BINARY_DIR}/../MakeInProjectOnly.h" [[ +int MakeInProjectOnly(void) { return 1; } +]]) diff --git a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake index 0dd27d4..8541070 100644 --- a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake +++ b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake @@ -30,7 +30,7 @@ function(run_BuildDepends CASE) endfunction() run_BuildDepends(C-Exe) -if(NOT RunCMake_GENERATOR MATCHES "Visual Studio [67]|Xcode") +if(NOT RunCMake_GENERATOR MATCHES "Visual Studio 7|Xcode") if(RunCMake_GENERATOR MATCHES "Visual Studio 10") # VS 10 forgets to re-link when a manifest changes set(run_BuildDepends_skip_step_2 1) @@ -41,3 +41,47 @@ endif() run_BuildDepends(Custom-Symbolic-and-Byproduct) run_BuildDepends(Custom-Always) + +if(RunCMake_GENERATOR MATCHES "Make" AND + NOT "${RunCMake_BINARY_DIR}" STREQUAL "${RunCMake_SOURCE_DIR}") + run_BuildDepends(MakeInProjectOnly) +endif() + +function(run_ReGeneration) + # test re-generation of project even if CMakeLists.txt files disappeared + + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/regenerate-project-build) + set(RunCMake_TEST_SOURCE_DIR ${RunCMake_BINARY_DIR}/regenerate-project-source) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}") + set(ProjectHeader [=[ + cmake_minimum_required(VERSION 3.5) + project(Regenerate-Project NONE) + ]=]) + + # create project with subdirectory + file(WRITE "${RunCMake_TEST_SOURCE_DIR}/CMakeLists.txt" "${ProjectHeader}" + "add_subdirectory(mysubdir)") + file(MAKE_DIRECTORY "${RunCMake_TEST_SOURCE_DIR}/mysubdir") + file(WRITE "${RunCMake_TEST_SOURCE_DIR}/mysubdir/CMakeLists.txt" "# empty") + + run_cmake(Regenerate-Project) + execute_process(COMMAND ${CMAKE_COMMAND} -E sleep ${fs_delay}) + + # now we delete the subdirectory and adjust the CMakeLists.txt + file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}/mysubdir") + file(WRITE "${RunCMake_TEST_SOURCE_DIR}/CMakeLists.txt" "${ProjectHeader}") + + run_cmake_command(Regenerate-Project-Directory-Removed + ${CMAKE_COMMAND} --build "${RunCMake_TEST_BINARY_DIR}") + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_SOURCE_DIR) + unset(RunCMake_TEST_NO_CLEAN) +endfunction() + +if(RunCMake_GENERATOR STREQUAL "Xcode") + run_ReGeneration(regenerate-project) +endif() diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 0a388c5..d22c39c 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -152,6 +152,7 @@ add_RunCMake_test(ObjectLibrary) add_RunCMake_test(Swift) add_RunCMake_test(TargetObjects) add_RunCMake_test(TargetSources) +add_RunCMake_test(ToolchainFile) add_RunCMake_test(find_dependency) add_RunCMake_test(CompileDefinitions) add_RunCMake_test(CompileFeatures) @@ -216,6 +217,7 @@ add_RunCMake_test(alias_targets) add_RunCMake_test(interface_library) add_RunCMake_test(no_install_prefix) add_RunCMake_test(configure_file) +add_RunCMake_test(CTestTimeoutAfterMatch) find_package(Qt4 QUIET) find_package(Qt5Core QUIET) @@ -231,9 +233,16 @@ if(PKG_CONFIG_FOUND) add_RunCMake_test(FindPkgConfig) endif() -if("${CMAKE_GENERATOR}" MATCHES "Visual Studio [^6]") +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") add_RunCMake_test(include_external_msproject) - add_RunCMake_test(SolutionGlobalSections) + if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([789]|10)" AND NOT CMAKE_VS_DEVENV_COMMAND) + set(NO_USE_FOLDERS 1) + endif() + add_RunCMake_test(VSSolution -DNO_USE_FOLDERS=${NO_USE_FOLDERS}) +endif() + +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([^789]|[789][0-9])") + add_RunCMake_test(VS10Project) endif() if(XCODE_VERSION AND NOT "${XCODE_VERSION}" VERSION_LESS 3) diff --git a/Tests/RunCMake/CPack/INSTALL_SCRIPTS.cmake b/Tests/RunCMake/CPack/INSTALL_SCRIPTS.cmake new file mode 100644 index 0000000..13aa77b --- /dev/null +++ b/Tests/RunCMake/CPack/INSTALL_SCRIPTS.cmake @@ -0,0 +1,26 @@ +set(CMAKE_BUILD_WITH_INSTALL_RPATH 1) + +# default +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pre_install.sh" + "echo \"pre install\"\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_install.sh" + "echo \"post install\"\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall.sh" + "echo \"pre uninstall\"\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall.sh" + "echo \"post uninstall\"\n") + +# specific +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pre_install_foo.sh" + "echo \"pre install foo\"\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_install_foo.sh" + "echo \"post install foo\"\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall_foo.sh" + "echo \"pre uninstall foo\"\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall_foo.sh" + "echo \"post uninstall foo\"\n") + +install(FILES CMakeLists.txt DESTINATION foo COMPONENT foo) +install(FILES CMakeLists.txt DESTINATION bar COMPONENT bar) + +set(CPACK_PACKAGE_NAME "install_scripts") diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake index 2cdfece..8b7fb1e 100644 --- a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake +++ b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake @@ -4,19 +4,19 @@ set(CPACK_RPM_COMPONENT_INSTALL "ON") # does not use them correctly: https://bugs.launchpad.net/rpm/+bug/1475755 set(CPACK_RPM_PACKAGE_AUTOREQ "no") set(CPACK_RPM_PACKAGE_AUTOPROV "no") -set(CPACK_RPM_applications_auto_PACKAGE_AUTOREQPROV "yes") -set(CPACK_RPM_libs_auto_PACKAGE_AUTOREQPROV "yes") +set(CPACK_RPM_APPLICATIONS_AUTO_PACKAGE_AUTOREQPROV "yes") +set(CPACK_RPM_LIBS_AUTO_PACKAGE_AUTOREQPROV "yes") set(CPACK_RPM_PACKAGE_REQUIRES "depend-default, depend-default-b") -set(CPACK_RPM_applications_PACKAGE_REQUIRES "depend-application, depend-application-b") -set(CPACK_RPM_applications_auto_PACKAGE_REQUIRES "depend-application, depend-application-b") -set(CPACK_RPM_headers_PACKAGE_REQUIRES "depend-headers") +set(CPACK_RPM_APPLICATIONS_PACKAGE_REQUIRES "depend-application, depend-application-b") +set(CPACK_RPM_APPLICATIONS_AUTO_PACKAGE_REQUIRES "depend-application, depend-application-b") +set(CPACK_RPM_HEADERS_PACKAGE_REQUIRES "depend-headers") set(CPACK_RPM_PACKAGE_CONFLICTS "conflict-default, conflict-default-b") -set(CPACK_RPM_applications_PACKAGE_CONFLICTS "conflict-application, conflict-application-b") -set(CPACK_RPM_applications_auto_PACKAGE_CONFLICTS "conflict-application, conflict-application-b") -set(CPACK_RPM_headers_PACKAGE_CONFLICTS "conflict-headers") +set(CPACK_RPM_APPLICATIONS_PACKAGE_CONFLICTS "conflict-application, conflict-application-b") +set(CPACK_RPM_APPLICATIONS_AUTO_PACKAGE_CONFLICTS "conflict-application, conflict-application-b") +set(CPACK_RPM_HEADERS_PACKAGE_CONFLICTS "conflict-headers") set(CPACK_RPM_PACKAGE_PROVIDES "provided-default, provided-default-b") -set(CPACK_RPM_libs_PACKAGE_PROVIDES "provided-lib") -set(CPACK_RPM_libs_auto_PACKAGE_PROVIDES "provided-lib_auto, provided-lib_auto-b") +set(CPACK_RPM_LIBS_PACKAGE_PROVIDES "provided-lib") +set(CPACK_RPM_LIBS_AUTO_PACKAGE_PROVIDES "provided-lib_auto, provided-lib_auto-b") diff --git a/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-ExpectedFiles.cmake new file mode 100644 index 0000000..033a45d --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-ExpectedFiles.cmake @@ -0,0 +1,7 @@ +set(whitespaces_ "[\t\n\r ]*") + +set(EXPECTED_FILES_COUNT "2") +set(EXPECTED_FILE_1 "install_scripts*-foo.rpm") +set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") +set(EXPECTED_FILE_2 "install_scripts*-bar.rpm") +set(EXPECTED_FILE_CONTENT_2 "^/usr/bar${whitespaces_}/usr/bar/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-VerifyResult.cmake b/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-VerifyResult.cmake new file mode 100644 index 0000000..d7d82f2 --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-VerifyResult.cmake @@ -0,0 +1,29 @@ +function(checkScripts_ FILE COMPARE_LIST) + set(whitespaces_ "[\t\n\r ]*") + + execute_process(COMMAND ${RPM_EXECUTABLE} -qp --scripts ${FILE} + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + OUTPUT_VARIABLE FILE_SCRIPTS_ + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + + string(REPLACE "\n" ";" FILE_SCRIPTS_LIST_ "${FILE_SCRIPTS_}") + + foreach(COMPARE_REGEX_ IN LISTS COMPARE_LIST) + unset(FOUND_) + + foreach(COMPARE_ IN LISTS FILE_SCRIPTS_LIST_) + if(COMPARE_ MATCHES "${COMPARE_REGEX_}") + set(FOUND_ true) + break() + endif() + endforeach() + + if(NOT FOUND_) + message(FATAL_ERROR "Missing scripts in '${FILE}'; file info: '${FILE_SCRIPTS_}'; missing: '${COMPARE_REGEX_}'") + endif() + endforeach() +endfunction() + +checkScripts_("${FOUND_FILE_1}" "echo \"pre install foo\";echo \"post install foo\";echo \"pre uninstall foo\";echo \"post uninstall foo\"") +checkScripts_("${FOUND_FILE_2}" "echo \"pre install\";echo \"post install\";echo \"pre uninstall\";echo \"post uninstall\"") diff --git a/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-specifics.cmake b/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-specifics.cmake new file mode 100644 index 0000000..4eb53c3 --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-specifics.cmake @@ -0,0 +1,19 @@ +set(CPACK_RPM_COMPONENT_INSTALL "ON") + +set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/pre_install.sh") +set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/post_install.sh") +set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall.sh") +set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall.sh") + +set(CPACK_RPM_foo_PRE_INSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/pre_install_foo.sh") +set(CPACK_RPM_foo_POST_INSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/post_install_foo.sh") +set(CPACK_RPM_foo_PRE_UNINSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall_foo.sh") +set(CPACK_RPM_foo_POST_UNINSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall_foo.sh") diff --git a/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-specifics.cmake b/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-specifics.cmake index d398168..524ef0c 100644 --- a/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-specifics.cmake +++ b/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-specifics.cmake @@ -1,5 +1,5 @@ set(CPACK_RPM_COMPONENT_INSTALL "ON") set(CPACK_RPM_PACKAGE_GROUP "default") -set(CPACK_RPM_pkg_2_PACKAGE_NAME "second") -set(CPACK_RPM_pkg_2_PACKAGE_GROUP "second_group") +set(CPACK_RPM_PKG_2_PACKAGE_NAME "second") +set(CPACK_RPM_PKG_2_PACKAGE_GROUP "second_group") diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index fe2b48b..ee4112d 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -11,3 +11,4 @@ run_cpack_test(DEPENDENCIES "RPM;DEB" true) run_cpack_test(EMPTY_DIR "RPM;DEB;TGZ" true) run_cpack_test(COMPONENTS_EMPTY_DIR "RPM;DEB;TGZ" true) run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false) +run_cpack_test(INSTALL_SCRIPTS "RPM" false) diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/CMakeLists.txt.in b/Tests/RunCMake/CTestTimeoutAfterMatch/CMakeLists.txt.in new file mode 100644 index 0000000..e9592f6 --- /dev/null +++ b/Tests/RunCMake/CTestTimeoutAfterMatch/CMakeLists.txt.in @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.4) +project(TimeoutAfterMatch NONE) +include(CTest) +add_test(NAME SleepFor1Second COMMAND "${CMAKE_COMMAND}" -P ${CMAKE_SOURCE_DIR}/SleepFor1Second.cmake) +set_property(TEST SleepFor1Second PROPERTY TIMEOUT 30) +set_property(TEST SleepFor1Second PROPERTY TIMEOUT_AFTER_MATCH "${arg1}" "${arg2}") diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/CTestConfig.cmake.in b/Tests/RunCMake/CTestTimeoutAfterMatch/CTestConfig.cmake.in new file mode 100644 index 0000000..58b11af --- /dev/null +++ b/Tests/RunCMake/CTestTimeoutAfterMatch/CTestConfig.cmake.in @@ -0,0 +1 @@ +set(CTEST_PROJECT_NAME "TimeoutAfterMatch@CASE_NAME@") diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/MissingArg1-stderr.txt b/Tests/RunCMake/CTestTimeoutAfterMatch/MissingArg1-stderr.txt new file mode 100644 index 0000000..7766c68 --- /dev/null +++ b/Tests/RunCMake/CTestTimeoutAfterMatch/MissingArg1-stderr.txt @@ -0,0 +1 @@ +TIMEOUT_AFTER_MATCH expects two arguments, found 1 diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/MissingArg2-stderr.txt b/Tests/RunCMake/CTestTimeoutAfterMatch/MissingArg2-stderr.txt new file mode 100644 index 0000000..7766c68 --- /dev/null +++ b/Tests/RunCMake/CTestTimeoutAfterMatch/MissingArg2-stderr.txt @@ -0,0 +1 @@ +TIMEOUT_AFTER_MATCH expects two arguments, found 1 diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/RunCMakeTest.cmake b/Tests/RunCMake/CTestTimeoutAfterMatch/RunCMakeTest.cmake new file mode 100644 index 0000000..ee4db83 --- /dev/null +++ b/Tests/RunCMake/CTestTimeoutAfterMatch/RunCMakeTest.cmake @@ -0,0 +1,11 @@ +include(RunCTest) + +function(run_ctest_TimeoutAfterMatch CASE_NAME) + set(CASE_PROPERTY_ARGS "${ARGN}") + run_ctest(${CASE_NAME}) +endfunction() + +run_ctest_TimeoutAfterMatch(MissingArg1 "\"-Darg2=Test started\"") +run_ctest_TimeoutAfterMatch(MissingArg2 "\"-Darg1=2\"") +run_ctest_TimeoutAfterMatch(ShouldTimeout "\"-Darg1=1\" \"-Darg2=Test started\"") +run_ctest_TimeoutAfterMatch(ShouldPass "\"-Darg1=15\" \"-Darg2=Test started\"") diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/ShouldPass-stdout.txt b/Tests/RunCMake/CTestTimeoutAfterMatch/ShouldPass-stdout.txt new file mode 100644 index 0000000..89aae56 --- /dev/null +++ b/Tests/RunCMake/CTestTimeoutAfterMatch/ShouldPass-stdout.txt @@ -0,0 +1,6 @@ + Start 1: SleepFor1Second +1/1 Test #1: SleepFor1Second .................. 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/CTestTimeoutAfterMatch/ShouldTimeout-stdout.txt b/Tests/RunCMake/CTestTimeoutAfterMatch/ShouldTimeout-stdout.txt new file mode 100644 index 0000000..c031eb0 --- /dev/null +++ b/Tests/RunCMake/CTestTimeoutAfterMatch/ShouldTimeout-stdout.txt @@ -0,0 +1 @@ +1 - SleepFor1Second \(Timeout\) diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/SleepFor1Second.cmake b/Tests/RunCMake/CTestTimeoutAfterMatch/SleepFor1Second.cmake new file mode 100644 index 0000000..82c2a44 --- /dev/null +++ b/Tests/RunCMake/CTestTimeoutAfterMatch/SleepFor1Second.cmake @@ -0,0 +1,4 @@ +execute_process(COMMAND "${CMAKE_COMMAND}" -E echo "Gathering required resources") +execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 2) +execute_process(COMMAND "${CMAKE_COMMAND}" -E echo "Test started") +execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/test.cmake.in b/Tests/RunCMake/CTestTimeoutAfterMatch/test.cmake.in new file mode 100644 index 0000000..d049c9f --- /dev/null +++ b/Tests/RunCMake/CTestTimeoutAfterMatch/test.cmake.in @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.4) + +set(CTEST_SITE "test-site") +set(CTEST_BUILD_NAME "test-build-name") +set(CTEST_SOURCE_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@") +set(CTEST_BINARY_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@-build") +set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@") +set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") + +configure_file( + "@RunCMake_SOURCE_DIR@/SleepFor1Second.cmake" + "${CTEST_SOURCE_DIRECTORY}/SleepFor1Second.cmake" + COPYONLY) + +set(options @CASE_PROPERTY_ARGS@) + +ctest_start(Experimental) +ctest_configure(OPTIONS "${options}") +ctest_test() diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-result.txt b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-stderr.txt new file mode 100644 index 0000000..f2cbaa6 --- /dev/null +++ b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-stderr.txt @@ -0,0 +1,3 @@ +^'--target' may not be specified more than once\. ++ +Usage: cmake --build <dir> \[options\] \[-- \[native-options\]\] diff --git a/Tests/RunCMake/CommandLine/BuildDir/CMakeLists.txt b/Tests/RunCMake/CommandLine/BuildDir/CMakeLists.txt index 20df108..d2a2831 100644 --- a/Tests/RunCMake/CommandLine/BuildDir/CMakeLists.txt +++ b/Tests/RunCMake/CommandLine/BuildDir/CMakeLists.txt @@ -3,3 +3,5 @@ add_custom_command( COMMAND ${CMAKE_COMMAND} -E echo CustomCommand > output.txt ) add_custom_target(CustomTarget ALL DEPENDS output.txt) +add_custom_target(CustomTarget2 ALL DEPENDS output.txt) +add_custom_target(CustomTarget3 ALL DEPENDS output.txt) diff --git a/Tests/RunCMake/CommandLine/DeprecateVS6-WARN-ON-stderr.txt b/Tests/RunCMake/CommandLine/DeprecateVS6-WARN-ON-stderr.txt deleted file mode 100644 index 1b6a510..0000000 --- a/Tests/RunCMake/CommandLine/DeprecateVS6-WARN-ON-stderr.txt +++ /dev/null @@ -1,5 +0,0 @@ -^CMake Warning: - The "Visual Studio 6" generator is deprecated and will be removed in a - future version of CMake. - - Add CMAKE_WARN_VS6=OFF to the cache to disable this warning.$ diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index e3b73ff..3b5504e 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -51,6 +51,8 @@ function(run_BuildDir) run_cmake(BuildDir) run_cmake_command(BuildDir--build ${CMAKE_COMMAND} -E chdir .. ${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget) + run_cmake_command(BuildDir--build-multiple-targets ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget2 --target CustomTarget3) endfunction() run_BuildDir() @@ -70,12 +72,7 @@ if(RunCMake_GENERATOR STREQUAL "Ninja") unset(RunCMake_TEST_NO_CLEAN) endif() -if(RunCMake_GENERATOR STREQUAL "Visual Studio 6") - set(RunCMake_WARN_VS6 1) - run_cmake(DeprecateVS6-WARN-ON) - unset(RunCMake_WARN_VS6) - run_cmake(DeprecateVS6-WARN-OFF) -elseif(RunCMake_GENERATOR STREQUAL "Visual Studio 7") +if(RunCMake_GENERATOR STREQUAL "Visual Studio 7") set(RunCMake_WARN_VS70 1) run_cmake(DeprecateVS70-WARN-ON) unset(RunCMake_WARN_VS70) diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index 64f97bc..4e06888 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -16,3 +16,19 @@ run_CMP0058(WARN-no) run_CMP0058(WARN-by) run_CMP0058(NEW-no) run_CMP0058(NEW-by) + +function(run_SubDir) + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SubDir-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(SubDir) + if(WIN32) + set(SubDir_all [[SubDir\all]]) + else() + set(SubDir_all [[SubDir/all]]) + endif() + run_cmake_command(SubDir-build ${CMAKE_COMMAND} --build . --target ${SubDir_all}) +endfunction() +run_SubDir() diff --git a/Tests/RunCMake/Ninja/SubDir-build-stdout.txt b/Tests/RunCMake/Ninja/SubDir-build-stdout.txt new file mode 100644 index 0000000..e4b4662 --- /dev/null +++ b/Tests/RunCMake/Ninja/SubDir-build-stdout.txt @@ -0,0 +1 @@ +Building InAll diff --git a/Tests/RunCMake/Ninja/SubDir.cmake b/Tests/RunCMake/Ninja/SubDir.cmake new file mode 100644 index 0000000..7224ec3 --- /dev/null +++ b/Tests/RunCMake/Ninja/SubDir.cmake @@ -0,0 +1,2 @@ +add_subdirectory(SubDir) +add_custom_target(TopFail ALL COMMAND does_not_exist) diff --git a/Tests/RunCMake/Ninja/SubDir/CMakeLists.txt b/Tests/RunCMake/Ninja/SubDir/CMakeLists.txt new file mode 100644 index 0000000..73ae431 --- /dev/null +++ b/Tests/RunCMake/Ninja/SubDir/CMakeLists.txt @@ -0,0 +1,2 @@ +add_custom_target(SubFail COMMAND does_not_exist) +add_custom_target(InAll ALL COMMAND ${CMAKE_COMMAND} -E echo "Building InAll") diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index db9911d..9d44a8a 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -51,9 +51,6 @@ function(run_cmake test) if(APPLE) list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0025=NEW) endif() - if(RunCMake_GENERATOR STREQUAL "Visual Studio 6" AND NOT RunCMake_WARN_VS6) - list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_WARN_VS6=OFF) - endif() if(RunCMake_GENERATOR STREQUAL "Visual Studio 7" AND NOT RunCMake_WARN_VS70) list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_WARN_VS70=OFF) endif() diff --git a/Tests/RunCMake/ToolchainFile/CMakeLists.txt b/Tests/RunCMake/ToolchainFile/CMakeLists.txt new file mode 100644 index 0000000..93ee9df --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.5) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/ToolchainFile/CallEnableLanguage-result.txt b/Tests/RunCMake/ToolchainFile/CallEnableLanguage-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CallEnableLanguage-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ToolchainFile/CallEnableLanguage-stderr.txt b/Tests/RunCMake/ToolchainFile/CallEnableLanguage-stderr.txt new file mode 100644 index 0000000..0de51c6 --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CallEnableLanguage-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at CallEnableLanguage-toolchain.cmake:[0-9]+ \(enable_language\): + Language 'NONE' is currently being enabled. Recursive call not allowed. +Call Stack \(most recent call first\): + .*/Modules/CMakeDetermineSystem.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(project\)$ diff --git a/Tests/RunCMake/ToolchainFile/CallEnableLanguage-toolchain.cmake b/Tests/RunCMake/ToolchainFile/CallEnableLanguage-toolchain.cmake new file mode 100644 index 0000000..8145101 --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CallEnableLanguage-toolchain.cmake @@ -0,0 +1 @@ +enable_language(NONE) diff --git a/Tests/RunCMake/CommandLine/DeprecateVS6-WARN-ON.cmake b/Tests/RunCMake/ToolchainFile/CallEnableLanguage.cmake index e69de29..e69de29 100644 --- a/Tests/RunCMake/CommandLine/DeprecateVS6-WARN-ON.cmake +++ b/Tests/RunCMake/ToolchainFile/CallEnableLanguage.cmake diff --git a/Tests/RunCMake/ToolchainFile/CallProject-result.txt b/Tests/RunCMake/ToolchainFile/CallProject-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CallProject-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ToolchainFile/CallProject-stderr.txt b/Tests/RunCMake/ToolchainFile/CallProject-stderr.txt new file mode 100644 index 0000000..e2b9f1b --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CallProject-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at CallProject-toolchain.cmake:[0-9]+ \(project\): + Language 'NONE' is currently being enabled. Recursive call not allowed. +Call Stack \(most recent call first\): + .*/Modules/CMakeDetermineSystem.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(project\)$ diff --git a/Tests/RunCMake/ToolchainFile/CallProject-toolchain.cmake b/Tests/RunCMake/ToolchainFile/CallProject-toolchain.cmake new file mode 100644 index 0000000..b113c13 --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/CallProject-toolchain.cmake @@ -0,0 +1 @@ +project(Bad NONE) diff --git a/Tests/RunCMake/CommandLine/DeprecateVS6-WARN-OFF.cmake b/Tests/RunCMake/ToolchainFile/CallProject.cmake index e69de29..e69de29 100644 --- a/Tests/RunCMake/CommandLine/DeprecateVS6-WARN-OFF.cmake +++ b/Tests/RunCMake/ToolchainFile/CallProject.cmake diff --git a/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake b/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake new file mode 100644 index 0000000..75293e7 --- /dev/null +++ b/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake @@ -0,0 +1,9 @@ +include(RunCMake) + +function(run_cmake_toolchain t) + set(RunCMake_TEST_OPTIONS -DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/${t}-toolchain.cmake) + run_cmake(${t}) +endfunction() + +run_cmake_toolchain(CallEnableLanguage) +run_cmake_toolchain(CallProject) diff --git a/Tests/RunCMake/VS10Project/CMakeLists.txt b/Tests/RunCMake/VS10Project/CMakeLists.txt new file mode 100644 index 0000000..91baae7 --- /dev/null +++ b/Tests/RunCMake/VS10Project/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.5.0) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake new file mode 100644 index 0000000..cc2cc2e --- /dev/null +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -0,0 +1,2 @@ +include(RunCMake) +run_cmake(VsConfigurationType) diff --git a/Tests/RunCMake/VS10Project/VsConfigurationType-check.cmake b/Tests/RunCMake/VS10Project/VsConfigurationType-check.cmake new file mode 100644 index 0000000..4690970 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsConfigurationType-check.cmake @@ -0,0 +1,24 @@ +set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj") +if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") + return() +endif() + +set(propertyFound FALSE) +file(STRINGS "${vcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES "^ *<ConfigurationType>(.*)</ConfigurationType>$") + set(propertyFound TRUE) + set(expectedValue "MyValue") + set(actualValue ${CMAKE_MATCH_1}) + if(NOT (${actualValue} STREQUAL ${expectedValue})) + set(RunCMake_TEST_FAILED "ConfigurationType \"${actualValue}\" differs from expected value \"${expectedValue}\".") + return() + endif() + endif() +endforeach() + +if(NOT propertyFound) + set(RunCMake_TEST_FAILED "Property ConfigurationType not found in project file.") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsConfigurationType.cmake b/Tests/RunCMake/VS10Project/VsConfigurationType.cmake new file mode 100644 index 0000000..a73dfe8 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsConfigurationType.cmake @@ -0,0 +1,3 @@ +enable_language(CXX) +add_library(foo foo.cpp) +set_target_properties(foo PROPERTIES VS_CONFIGURATION_TYPE "MyValue") diff --git a/Tests/RunCMake/VS10Project/foo.cpp b/Tests/RunCMake/VS10Project/foo.cpp new file mode 100644 index 0000000..2fb55ee --- /dev/null +++ b/Tests/RunCMake/VS10Project/foo.cpp @@ -0,0 +1 @@ +void foo() { } diff --git a/Tests/RunCMake/SolutionGlobalSections/CMakeLists.txt b/Tests/RunCMake/VSSolution/CMakeLists.txt index 12cd3c7..12cd3c7 100644 --- a/Tests/RunCMake/SolutionGlobalSections/CMakeLists.txt +++ b/Tests/RunCMake/VSSolution/CMakeLists.txt diff --git a/Tests/RunCMake/SolutionGlobalSections/MorePost-check.cmake b/Tests/RunCMake/VSSolution/MorePost-check.cmake index 0f7e370..0f7e370 100644 --- a/Tests/RunCMake/SolutionGlobalSections/MorePost-check.cmake +++ b/Tests/RunCMake/VSSolution/MorePost-check.cmake diff --git a/Tests/RunCMake/SolutionGlobalSections/MorePost.cmake b/Tests/RunCMake/VSSolution/MorePost.cmake index 2eb3f60..2eb3f60 100644 --- a/Tests/RunCMake/SolutionGlobalSections/MorePost.cmake +++ b/Tests/RunCMake/VSSolution/MorePost.cmake diff --git a/Tests/RunCMake/SolutionGlobalSections/MorePre-check.cmake b/Tests/RunCMake/VSSolution/MorePre-check.cmake index 45e7419..45e7419 100644 --- a/Tests/RunCMake/SolutionGlobalSections/MorePre-check.cmake +++ b/Tests/RunCMake/VSSolution/MorePre-check.cmake diff --git a/Tests/RunCMake/SolutionGlobalSections/MorePre.cmake b/Tests/RunCMake/VSSolution/MorePre.cmake index 07f4eb8..07f4eb8 100644 --- a/Tests/RunCMake/SolutionGlobalSections/MorePre.cmake +++ b/Tests/RunCMake/VSSolution/MorePre.cmake diff --git a/Tests/RunCMake/SolutionGlobalSections/OnePost-check.cmake b/Tests/RunCMake/VSSolution/OnePost-check.cmake index 6af5156..6af5156 100644 --- a/Tests/RunCMake/SolutionGlobalSections/OnePost-check.cmake +++ b/Tests/RunCMake/VSSolution/OnePost-check.cmake diff --git a/Tests/RunCMake/SolutionGlobalSections/OnePost.cmake b/Tests/RunCMake/VSSolution/OnePost.cmake index 2295cfb..2295cfb 100644 --- a/Tests/RunCMake/SolutionGlobalSections/OnePost.cmake +++ b/Tests/RunCMake/VSSolution/OnePost.cmake diff --git a/Tests/RunCMake/SolutionGlobalSections/OnePre-check.cmake b/Tests/RunCMake/VSSolution/OnePre-check.cmake index 70b18b2..70b18b2 100644 --- a/Tests/RunCMake/SolutionGlobalSections/OnePre-check.cmake +++ b/Tests/RunCMake/VSSolution/OnePre-check.cmake diff --git a/Tests/RunCMake/SolutionGlobalSections/OnePre.cmake b/Tests/RunCMake/VSSolution/OnePre.cmake index 1499b47..1499b47 100644 --- a/Tests/RunCMake/SolutionGlobalSections/OnePre.cmake +++ b/Tests/RunCMake/VSSolution/OnePre.cmake diff --git a/Tests/RunCMake/SolutionGlobalSections/Override1-check.cmake b/Tests/RunCMake/VSSolution/Override1-check.cmake index a19e2e1..a19e2e1 100644 --- a/Tests/RunCMake/SolutionGlobalSections/Override1-check.cmake +++ b/Tests/RunCMake/VSSolution/Override1-check.cmake diff --git a/Tests/RunCMake/SolutionGlobalSections/Override1.cmake b/Tests/RunCMake/VSSolution/Override1.cmake index a726c9f..a726c9f 100644 --- a/Tests/RunCMake/SolutionGlobalSections/Override1.cmake +++ b/Tests/RunCMake/VSSolution/Override1.cmake diff --git a/Tests/RunCMake/SolutionGlobalSections/Override2-check.cmake b/Tests/RunCMake/VSSolution/Override2-check.cmake index d9656e1..d9656e1 100644 --- a/Tests/RunCMake/SolutionGlobalSections/Override2-check.cmake +++ b/Tests/RunCMake/VSSolution/Override2-check.cmake diff --git a/Tests/RunCMake/SolutionGlobalSections/Override2.cmake b/Tests/RunCMake/VSSolution/Override2.cmake index 0ce43cc..0ce43cc 100644 --- a/Tests/RunCMake/SolutionGlobalSections/Override2.cmake +++ b/Tests/RunCMake/VSSolution/Override2.cmake diff --git a/Tests/RunCMake/SolutionGlobalSections/PrePost-check.cmake b/Tests/RunCMake/VSSolution/PrePost-check.cmake index 322a689..322a689 100644 --- a/Tests/RunCMake/SolutionGlobalSections/PrePost-check.cmake +++ b/Tests/RunCMake/VSSolution/PrePost-check.cmake diff --git a/Tests/RunCMake/SolutionGlobalSections/PrePost.cmake b/Tests/RunCMake/VSSolution/PrePost.cmake index 976c341..976c341 100644 --- a/Tests/RunCMake/SolutionGlobalSections/PrePost.cmake +++ b/Tests/RunCMake/VSSolution/PrePost.cmake diff --git a/Tests/RunCMake/SolutionGlobalSections/RunCMakeTest.cmake b/Tests/RunCMake/VSSolution/RunCMakeTest.cmake index 6ae158d..afd74a1 100644 --- a/Tests/RunCMake/SolutionGlobalSections/RunCMakeTest.cmake +++ b/Tests/RunCMake/VSSolution/RunCMakeTest.cmake @@ -8,3 +8,9 @@ run_cmake(MorePost) run_cmake(PrePost) run_cmake(Override1) run_cmake(Override2) +run_cmake(StartupProject) +run_cmake(StartupProjectMissing) + +if(RunCMake_GENERATOR MATCHES "Visual Studio ([^7]|[7][0-9])" AND NOT NO_USE_FOLDERS) + run_cmake(StartupProjectUseFolders) +endif() diff --git a/Tests/RunCMake/VSSolution/StartupProject-check.cmake b/Tests/RunCMake/VSSolution/StartupProject-check.cmake new file mode 100644 index 0000000..f36aab2 --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProject-check.cmake @@ -0,0 +1,5 @@ +getProjectNames(projects) +list(GET projects 0 first_project) +if(NOT first_project STREQUAL "TestStartup") + error("TestStartup is not the startup project") +endif() diff --git a/Tests/RunCMake/VSSolution/StartupProject.cmake b/Tests/RunCMake/VSSolution/StartupProject.cmake new file mode 100644 index 0000000..7192f3d --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProject.cmake @@ -0,0 +1,2 @@ +add_custom_target(TestStartup) +set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT "TestStartup") diff --git a/Tests/RunCMake/VSSolution/StartupProjectMissing-check.cmake b/Tests/RunCMake/VSSolution/StartupProjectMissing-check.cmake new file mode 100644 index 0000000..b1017dd --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProjectMissing-check.cmake @@ -0,0 +1,5 @@ +getProjectNames(projects) +list(GET projects 0 first_project) +if(NOT first_project STREQUAL "ALL_BUILD") + error("ALL_BUILD is not the startup project") +endif() diff --git a/Tests/RunCMake/VSSolution/StartupProjectMissing-stderr.txt b/Tests/RunCMake/VSSolution/StartupProjectMissing-stderr.txt new file mode 100644 index 0000000..da92c6d --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProjectMissing-stderr.txt @@ -0,0 +1,4 @@ +^CMake Warning \(dev\) in CMakeLists.txt: + Directory property VS_STARTUP_PROJECT specifies target 'DoesNotExist' that + does not exist. Ignoring. +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/VSSolution/StartupProjectMissing.cmake b/Tests/RunCMake/VSSolution/StartupProjectMissing.cmake new file mode 100644 index 0000000..907a877 --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProjectMissing.cmake @@ -0,0 +1 @@ +set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT "DoesNotExist") diff --git a/Tests/RunCMake/VSSolution/StartupProjectUseFolders-check.cmake b/Tests/RunCMake/VSSolution/StartupProjectUseFolders-check.cmake new file mode 100644 index 0000000..c0a545a --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProjectUseFolders-check.cmake @@ -0,0 +1,9 @@ +getProjectNames(projects) +list(GET projects 0 first_project) +if(NOT first_project STREQUAL "CMakePredefinedTargets") + error("CMakePredefinedTargets is not the first project") +endif() +list(GET projects 1 second_project) +if(NOT second_project STREQUAL "TestStartup") + error("TestStartup does not immediately follow the CMakePredefinedTargets project") +endif() diff --git a/Tests/RunCMake/VSSolution/StartupProjectUseFolders.cmake b/Tests/RunCMake/VSSolution/StartupProjectUseFolders.cmake new file mode 100644 index 0000000..8e422a4 --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProjectUseFolders.cmake @@ -0,0 +1,3 @@ +add_custom_target(TestStartup) +set_property(GLOBAL PROPERTY USE_FOLDERS ON) +set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT "TestStartup") diff --git a/Tests/RunCMake/SolutionGlobalSections/solution_parsing.cmake b/Tests/RunCMake/VSSolution/solution_parsing.cmake index dd158ef..4e5bb59 100644 --- a/Tests/RunCMake/SolutionGlobalSections/solution_parsing.cmake +++ b/Tests/RunCMake/VSSolution/solution_parsing.cmake @@ -50,6 +50,21 @@ macro(parseGlobalSections arg_out_pre arg_out_post testName) endmacro() +macro(getProjectNames arg_out_projects) + set(${arg_out_projects} "") + set(sln "${RunCMake_TEST_BINARY_DIR}/${test}.sln") + if(NOT EXISTS "${sln}") + error("Expected solution file ${sln} does not exist") + endif() + file(STRINGS "${sln}" project_lines REGEX "^Project\\(") + foreach(project_line IN LISTS project_lines) + string(REGEX REPLACE ".* = \"" "" project_line "${project_line}") + string(REGEX REPLACE "\", .*" "" project_line "${project_line}") + list(APPEND ${arg_out_projects} "${project_line}") + endforeach() +endmacro() + + macro(testGlobalSection prefix sectionName) if(NOT DEFINED ${prefix}_${sectionName}) error("Section ${sectionName} does not exist") diff --git a/Tests/RunCMake/cmake_parse_arguments/CornerCases.cmake b/Tests/RunCMake/cmake_parse_arguments/CornerCases.cmake index 72c82ab..028bfaf 100644 --- a/Tests/RunCMake/cmake_parse_arguments/CornerCases.cmake +++ b/Tests/RunCMake/cmake_parse_arguments/CornerCases.cmake @@ -29,6 +29,26 @@ macro(foo) endmacro() foo(FOO foo) +TEST(_FOO1_FOO foo) +TEST(_FOO2_FOO foo) +# Make sure a list is split +foo(FOO "foo;bar") TEST(_FOO1_FOO foo) +TEST(_FOO1_UNPARSED_ARGUMENTS "bar") TEST(_FOO2_FOO foo) +TEST(_FOO2_UNPARSED_ARGUMENTS "bar") + +# Do not split if argn is quoted +foo(FOO "foo\\;bar") +TEST(_FOO1_FOO foo) +TEST(_FOO1_UNPARSED_ARGUMENTS "bar") +TEST(_FOO2_FOO foo;bar) +TEST(_FOO2_UNPARSED_ARGUMENTS "UNDEFINED") + +# Do not split if argn is quoted +foo(FOO "foo\\\\;bar") +TEST(_FOO1_FOO foo) +TEST(_FOO1_UNPARSED_ARGUMENTS "bar") +TEST(_FOO2_FOO foo;bar) +TEST(_FOO2_UNPARSED_ARGUMENTS "UNDEFINED") diff --git a/Tests/RunCMake/cmake_parse_arguments/Initialization.cmake b/Tests/RunCMake/cmake_parse_arguments/Initialization.cmake index 462f923..b4199ea 100644 --- a/Tests/RunCMake/cmake_parse_arguments/Initialization.cmake +++ b/Tests/RunCMake/cmake_parse_arguments/Initialization.cmake @@ -25,6 +25,9 @@ TEST(pref_OPT1 TRUE) cmake_parse_arguments(pref "OPT1;OPT2" "" "" OPT1 OPT2) TEST(pref_OPT1 TRUE) TEST(pref_OPT2 TRUE) +cmake_parse_arguments(pref "OPT1;OPT2" "" "" "OPT1;OPT2") +TEST(pref_OPT1 TRUE) +TEST(pref_OPT2 TRUE) cmake_parse_arguments(pref "OPT1;OPT2" "" "") TEST(pref_OPT1 FALSE) TEST(pref_OPT2 FALSE) @@ -44,6 +47,9 @@ TEST(pref_SINGLE1 foo) cmake_parse_arguments(pref "" "SINGLE1;SINGLE2" "" SINGLE1 foo SINGLE2 bar) TEST(pref_SINGLE1 foo) TEST(pref_SINGLE2 bar) +cmake_parse_arguments(pref "" "SINGLE1;SINGLE2" "" "SINGLE1;foo;SINGLE2;bar") +TEST(pref_SINGLE1 foo) +TEST(pref_SINGLE2 bar) cmake_parse_arguments(pref "" "SINGLE1;SINGLE2" "") TEST(pref_SINGLE1 UNDEFINED) TEST(pref_SINGLE2 UNDEFINED) @@ -63,6 +69,9 @@ TEST(pref_MULTI1 foo) cmake_parse_arguments(pref "" "" "MULTI1;MULTI2" MULTI1 foo bar MULTI2 bar foo) TEST(pref_MULTI1 foo bar) TEST(pref_MULTI2 bar foo) +cmake_parse_arguments(pref "" "" "MULTI1;MULTI2" "MULTI1;foo;bar;MULTI2;bar;foo") +TEST(pref_MULTI1 foo bar) +TEST(pref_MULTI2 bar foo) cmake_parse_arguments(pref "" "" "MULTI1;MULTI2") TEST(pref_MULTI1 UNDEFINED) TEST(pref_MULTI2 UNDEFINED) diff --git a/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-result.txt b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-stderr.txt b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-stderr.txt new file mode 100644 index 0000000..406e315 --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-stderr.txt @@ -0,0 +1,12 @@ +^CMake Error at DOWNLOAD-hash-mismatch.cmake:[0-9]+ \(file\): + file DOWNLOAD HASH mismatch + + for file: \[.*/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-build/hash-mismatch.txt\] + expected hash: \[0123456789abcdef0123456789abcdef01234567\] + actual hash: \[da39a3ee5e6b4b0d3255bfef95601890afd80709\] + status: \[0;"No error"\] + +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +status='1;HASH mismatch: expected: 0123456789abcdef0123456789abcdef01234567 actual: da39a3ee5e6b4b0d3255bfef95601890afd80709'$ diff --git a/Tests/RunCMake/file/DOWNLOAD-hash-mismatch.cmake b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch.cmake new file mode 100644 index 0000000..ca72692 --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch.cmake @@ -0,0 +1,7 @@ +file(DOWNLOAD + "file://${CMAKE_CURRENT_SOURCE_DIR}/DOWNLOAD-hash-mismatch.txt" + ${CMAKE_CURRENT_BINARY_DIR}/hash-mismatch.txt + EXPECTED_HASH SHA1=0123456789abcdef0123456789abcdef01234567 + STATUS status + ) +message("status='${status}'") diff --git a/Tests/RunCMake/file/DOWNLOAD-hash-mismatch.txt b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch.txt diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index d3dfb1b..5f85bba 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -1,5 +1,6 @@ include(RunCMake) +run_cmake(DOWNLOAD-hash-mismatch) run_cmake(INSTALL-DIRECTORY) run_cmake(INSTALL-MESSAGE-bad) run_cmake(FileOpenFailRead) diff --git a/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-all-check.cmake b/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-all-check.cmake new file mode 100644 index 0000000..0368df1 --- /dev/null +++ b/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^src-all;src-all/main\.c$]]) diff --git a/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-exc-check.cmake b/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-exc-check.cmake new file mode 100644 index 0000000..41a816f --- /dev/null +++ b/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-exc-check.cmake @@ -0,0 +1 @@ +check_installed([[^src-exc;src-exc/main\.c$]]) diff --git a/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-uns-check.cmake b/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-uns-check.cmake new file mode 100644 index 0000000..68a1378 --- /dev/null +++ b/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL-uns-check.cmake @@ -0,0 +1 @@ +check_installed([[^src-all;src-all/main\.c;src-uns;src-uns/main\.c$]]) diff --git a/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL.cmake b/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL.cmake new file mode 100644 index 0000000..720299b --- /dev/null +++ b/Tests/RunCMake/install/FILES-EXCLUDE_FROM_ALL.cmake @@ -0,0 +1,3 @@ +install(FILES main.c DESTINATION src-all) +install(FILES main.c DESTINATION src-uns EXCLUDE_FROM_ALL) +install(FILES main.c DESTINATION src-exc EXCLUDE_FROM_ALL COMPONENT exc) diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake index c2347d8..45693b5 100644 --- a/Tests/RunCMake/install/RunCMakeTest.cmake +++ b/Tests/RunCMake/install/RunCMakeTest.cmake @@ -1,4 +1,46 @@ +cmake_minimum_required(VERSION 3.4) include(RunCMake) + +# Function to build and install a project. The latter step *-check.cmake +# scripts can check installed files using the check_installed function. +function(run_install_test case) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(${case}) + run_cmake_command(${case}-build ${CMAKE_COMMAND} --build . --config Debug) + # Check "all" components. + set(CMAKE_INSTALL_PREFIX ${RunCMake_TEST_BINARY_DIR}/root-all) + run_cmake_command(${case}-all ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DBUILD_TYPE=Debug -P cmake_install.cmake) + # Check unspecified component. + set(CMAKE_INSTALL_PREFIX ${RunCMake_TEST_BINARY_DIR}/root-uns) + run_cmake_command(${case}-uns ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DBUILD_TYPE=Debug -DCOMPONENT=Unspecified -P cmake_install.cmake) + # Check explicit component. + set(CMAKE_INSTALL_PREFIX ${RunCMake_TEST_BINARY_DIR}/root-exc) + run_cmake_command(${case}-exc ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DBUILD_TYPE=Debug -DCOMPONENT=exc -P cmake_install.cmake) +endfunction() + +# Function called in *-check.cmake scripts to check installed files. +function(check_installed expect) + file(GLOB_RECURSE actual + LIST_DIRECTORIES TRUE + RELATIVE ${CMAKE_INSTALL_PREFIX} + ${CMAKE_INSTALL_PREFIX}/* + ) + if(actual) + list(SORT actual) + endif() + if(NOT "${actual}" MATCHES "${expect}") + set(RunCMake_TEST_FAILED "Installed files: + ${actual} +do not match what we expected: + ${expect} +in directory: + ${CMAKE_INSTALL_PREFIX}" PARENT_SCOPE) + endif() +endfunction() + run_cmake(DIRECTORY-MESSAGE_NEVER) run_cmake(DIRECTORY-PATTERN-MESSAGE_NEVER) run_cmake(DIRECTORY-message) @@ -14,3 +56,6 @@ run_cmake(EXPORT-OldIFace) run_cmake(CMP0062-OLD) run_cmake(CMP0062-NEW) run_cmake(CMP0062-WARN) + +run_install_test(FILES-EXCLUDE_FROM_ALL) +run_install_test(TARGETS-EXCLUDE_FROM_ALL) diff --git a/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-all-check.cmake b/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-all-check.cmake new file mode 100644 index 0000000..9b538bb --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-all-check.cmake @@ -0,0 +1 @@ +check_installed([[^bin-all;bin-all/myexe(\.exe)?$]]) diff --git a/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-exc-check.cmake b/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-exc-check.cmake new file mode 100644 index 0000000..aef0d27 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-exc-check.cmake @@ -0,0 +1 @@ +check_installed([[^bin-exc;bin-exc/myexe(\.exe)?$]]) diff --git a/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-uns-check.cmake b/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-uns-check.cmake new file mode 100644 index 0000000..56fd264 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL-uns-check.cmake @@ -0,0 +1 @@ +check_installed([[^bin-all;bin-all/myexe(\.exe)?;bin-uns;bin-uns/myexe(\.exe)?$]]) diff --git a/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL.cmake b/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL.cmake new file mode 100644 index 0000000..6fb2036 --- /dev/null +++ b/Tests/RunCMake/install/TARGETS-EXCLUDE_FROM_ALL.cmake @@ -0,0 +1,5 @@ +enable_language(C) +add_executable(myexe main.c) +install(TARGETS myexe DESTINATION bin-all) +install(TARGETS myexe DESTINATION bin-uns EXCLUDE_FROM_ALL) +install(TARGETS myexe DESTINATION bin-exc EXCLUDE_FROM_ALL COMPONENT exc) diff --git a/Tests/RunCMake/install/main.c b/Tests/RunCMake/install/main.c new file mode 100644 index 0000000..78f2de1 --- /dev/null +++ b/Tests/RunCMake/install/main.c @@ -0,0 +1 @@ +int main(void) { return 0; } diff --git a/Tests/RunCMake/list/EmptyFilterRegex-result.txt b/Tests/RunCMake/list/EmptyFilterRegex-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/list/EmptyFilterRegex-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/list/EmptyFilterRegex-stderr.txt b/Tests/RunCMake/list/EmptyFilterRegex-stderr.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/list/EmptyFilterRegex-stderr.txt diff --git a/Tests/RunCMake/list/EmptyFilterRegex.cmake b/Tests/RunCMake/list/EmptyFilterRegex.cmake new file mode 100644 index 0000000..33849cd --- /dev/null +++ b/Tests/RunCMake/list/EmptyFilterRegex.cmake @@ -0,0 +1,2 @@ +set(mylist "") +list(FILTER mylist INCLUDE REGEX "^FILTER_THIS_.+") diff --git a/Tests/RunCMake/list/FILTER-NotList-result.txt b/Tests/RunCMake/list/FILTER-NotList-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/FILTER-NotList-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/FILTER-NotList-stderr.txt b/Tests/RunCMake/list/FILTER-NotList-stderr.txt new file mode 100644 index 0000000..159c28d --- /dev/null +++ b/Tests/RunCMake/list/FILTER-NotList-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at FILTER-NotList.cmake:2 \(list\): + list sub-command FILTER requires list to be present. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/FILTER-NotList.cmake b/Tests/RunCMake/list/FILTER-NotList.cmake new file mode 100644 index 0000000..1e15635 --- /dev/null +++ b/Tests/RunCMake/list/FILTER-NotList.cmake @@ -0,0 +1,2 @@ +unset(nosuchlist) +list(FILTER nosuchlist EXCLUDE REGEX "^FILTER_THIS_.+") diff --git a/Tests/RunCMake/list/FILTER-REGEX-InvalidMode-result.txt b/Tests/RunCMake/list/FILTER-REGEX-InvalidMode-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/FILTER-REGEX-InvalidMode-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/FILTER-REGEX-InvalidMode-stderr.txt b/Tests/RunCMake/list/FILTER-REGEX-InvalidMode-stderr.txt new file mode 100644 index 0000000..7f783fa --- /dev/null +++ b/Tests/RunCMake/list/FILTER-REGEX-InvalidMode-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at FILTER-REGEX-InvalidMode.cmake:2 \(list\): + list sub-command FILTER does not recognize mode NOOP +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/FILTER-REGEX-InvalidMode.cmake b/Tests/RunCMake/list/FILTER-REGEX-InvalidMode.cmake new file mode 100644 index 0000000..e02b929 --- /dev/null +++ b/Tests/RunCMake/list/FILTER-REGEX-InvalidMode.cmake @@ -0,0 +1,2 @@ +set(mylist FILTER_THIS_BIT DO_NOT_FILTER_THIS thisisanitem FILTER_THIS_THING) +list(FILTER mylist EXCLUDE NOOP "^FILTER_THIS_.+") diff --git a/Tests/RunCMake/list/FILTER-REGEX-InvalidOperator-result.txt b/Tests/RunCMake/list/FILTER-REGEX-InvalidOperator-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/FILTER-REGEX-InvalidOperator-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/FILTER-REGEX-InvalidOperator-stderr.txt b/Tests/RunCMake/list/FILTER-REGEX-InvalidOperator-stderr.txt new file mode 100644 index 0000000..94f2427 --- /dev/null +++ b/Tests/RunCMake/list/FILTER-REGEX-InvalidOperator-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at FILTER-REGEX-InvalidOperator.cmake:2 \(list\): + list sub-command FILTER does not recognize operator RM +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/FILTER-REGEX-InvalidOperator.cmake b/Tests/RunCMake/list/FILTER-REGEX-InvalidOperator.cmake new file mode 100644 index 0000000..9624622 --- /dev/null +++ b/Tests/RunCMake/list/FILTER-REGEX-InvalidOperator.cmake @@ -0,0 +1,2 @@ +set(mylist FILTER_THIS_BIT DO_NOT_FILTER_THIS thisisanitem FILTER_THIS_THING) +list(FILTER mylist RM REGEX "^FILTER_THIS_.+") diff --git a/Tests/RunCMake/list/FILTER-REGEX-InvalidRegex-result.txt b/Tests/RunCMake/list/FILTER-REGEX-InvalidRegex-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/FILTER-REGEX-InvalidRegex-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/FILTER-REGEX-InvalidRegex-stderr.txt b/Tests/RunCMake/list/FILTER-REGEX-InvalidRegex-stderr.txt new file mode 100644 index 0000000..9e98cbf --- /dev/null +++ b/Tests/RunCMake/list/FILTER-REGEX-InvalidRegex-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at FILTER-REGEX-InvalidRegex.cmake:2 \(list\): + list sub-command FILTER, mode REGEX failed to compile regex "UHOH!\)\(". +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/FILTER-REGEX-InvalidRegex.cmake b/Tests/RunCMake/list/FILTER-REGEX-InvalidRegex.cmake new file mode 100644 index 0000000..0641062 --- /dev/null +++ b/Tests/RunCMake/list/FILTER-REGEX-InvalidRegex.cmake @@ -0,0 +1,2 @@ +set(mylist FILTER_THIS_BIT DO_NOT_FILTER_THIS thisisanitem FILTER_THIS_THING) +list(FILTER mylist EXCLUDE REGEX "UHOH!)(") diff --git a/Tests/RunCMake/list/FILTER-REGEX-TooManyArguments-result.txt b/Tests/RunCMake/list/FILTER-REGEX-TooManyArguments-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/list/FILTER-REGEX-TooManyArguments-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/list/FILTER-REGEX-TooManyArguments-stderr.txt b/Tests/RunCMake/list/FILTER-REGEX-TooManyArguments-stderr.txt new file mode 100644 index 0000000..ec7f41c --- /dev/null +++ b/Tests/RunCMake/list/FILTER-REGEX-TooManyArguments-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at FILTER-REGEX-TooManyArguments.cmake:2 \(list\): + list sub-command FILTER, mode REGEX requires five arguments. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/list/FILTER-REGEX-TooManyArguments.cmake b/Tests/RunCMake/list/FILTER-REGEX-TooManyArguments.cmake new file mode 100644 index 0000000..d9cd8eb --- /dev/null +++ b/Tests/RunCMake/list/FILTER-REGEX-TooManyArguments.cmake @@ -0,0 +1,2 @@ +set(mylist FILTER_THIS_BIT DO_NOT_FILTER_THIS thisisanitem FILTER_THIS_THING) +list(FILTER mylist EXCLUDE REGEX "^FILTER_THIS_.+" one_too_many) diff --git a/Tests/RunCMake/list/FILTER-REGEX-Valid0-result.txt b/Tests/RunCMake/list/FILTER-REGEX-Valid0-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/list/FILTER-REGEX-Valid0-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/list/FILTER-REGEX-Valid0-stderr.txt b/Tests/RunCMake/list/FILTER-REGEX-Valid0-stderr.txt new file mode 100644 index 0000000..d9ba38d --- /dev/null +++ b/Tests/RunCMake/list/FILTER-REGEX-Valid0-stderr.txt @@ -0,0 +1,2 @@ +^mylist was: FILTER_THIS_BIT;DO_NOT_FILTER_THIS;thisisanitem;FILTER_THIS_THING +mylist is: DO_NOT_FILTER_THIS;thisisanitem$ diff --git a/Tests/RunCMake/list/FILTER-REGEX-Valid0.cmake b/Tests/RunCMake/list/FILTER-REGEX-Valid0.cmake new file mode 100644 index 0000000..f395e61 --- /dev/null +++ b/Tests/RunCMake/list/FILTER-REGEX-Valid0.cmake @@ -0,0 +1,4 @@ +set(mylist FILTER_THIS_BIT DO_NOT_FILTER_THIS thisisanitem FILTER_THIS_THING) +message("mylist was: ${mylist}") +list(FILTER mylist EXCLUDE REGEX "^FILTER_THIS_.+") +message("mylist is: ${mylist}") diff --git a/Tests/RunCMake/list/FILTER-REGEX-Valid1-result.txt b/Tests/RunCMake/list/FILTER-REGEX-Valid1-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/list/FILTER-REGEX-Valid1-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/list/FILTER-REGEX-Valid1-stderr.txt b/Tests/RunCMake/list/FILTER-REGEX-Valid1-stderr.txt new file mode 100644 index 0000000..5e5280d --- /dev/null +++ b/Tests/RunCMake/list/FILTER-REGEX-Valid1-stderr.txt @@ -0,0 +1,2 @@ +^mylist was: FILTER_THIS_BIT;DO_NOT_FILTER_THIS;thisisanitem;FILTER_THIS_THING +mylist is: FILTER_THIS_BIT;FILTER_THIS_THING$ diff --git a/Tests/RunCMake/list/FILTER-REGEX-Valid1.cmake b/Tests/RunCMake/list/FILTER-REGEX-Valid1.cmake new file mode 100644 index 0000000..e659281 --- /dev/null +++ b/Tests/RunCMake/list/FILTER-REGEX-Valid1.cmake @@ -0,0 +1,4 @@ +set(mylist FILTER_THIS_BIT DO_NOT_FILTER_THIS thisisanitem FILTER_THIS_THING) +message("mylist was: ${mylist}") +list(FILTER mylist INCLUDE REGEX "^FILTER_THIS_.+") +message("mylist is: ${mylist}") diff --git a/Tests/RunCMake/list/RunCMakeTest.cmake b/Tests/RunCMake/list/RunCMakeTest.cmake index 25d6a03..b002ab3 100644 --- a/Tests/RunCMake/list/RunCMakeTest.cmake +++ b/Tests/RunCMake/list/RunCMakeTest.cmake @@ -1,5 +1,6 @@ include(RunCMake) +run_cmake(EmptyFilterRegex) run_cmake(EmptyGet0) run_cmake(EmptyRemoveAt0) run_cmake(EmptyInsert-1) @@ -8,17 +9,25 @@ run_cmake(NoArguments) run_cmake(InvalidSubcommand) run_cmake(GET-CMP0007-WARN) +run_cmake(FILTER-REGEX-InvalidRegex) run_cmake(GET-InvalidIndex) run_cmake(INSERT-InvalidIndex) run_cmake(REMOVE_AT-InvalidIndex) +run_cmake(FILTER-REGEX-TooManyArguments) run_cmake(LENGTH-TooManyArguments) run_cmake(REMOVE_DUPLICATES-TooManyArguments) run_cmake(REVERSE-TooManyArguments) run_cmake(SORT-TooManyArguments) +run_cmake(FILTER-NotList) run_cmake(REMOVE_AT-NotList) run_cmake(REMOVE_DUPLICATES-NotList) run_cmake(REMOVE_ITEM-NotList) run_cmake(REVERSE-NotList) run_cmake(SORT-NotList) + +run_cmake(FILTER-REGEX-InvalidMode) +run_cmake(FILTER-REGEX-InvalidOperator) +run_cmake(FILTER-REGEX-Valid0) +run_cmake(FILTER-REGEX-Valid1) diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index 6cdbafa..43ce998 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -16,6 +16,10 @@ run_cmake(BadSources2) run_cmake(NonSourceCopyFile) run_cmake(NonSourceCompileDefinitions) +run_cmake(TargetTypeExe) +run_cmake(TargetTypeInvalid) +run_cmake(TargetTypeStatic) + run_cmake(CMP0056) if(RunCMake_GENERATOR MATCHES "Make|Ninja") diff --git a/Tests/RunCMake/try_compile/TargetTypeExe.cmake b/Tests/RunCMake/try_compile/TargetTypeExe.cmake new file mode 100644 index 0000000..9b6e727 --- /dev/null +++ b/Tests/RunCMake/try_compile/TargetTypeExe.cmake @@ -0,0 +1,14 @@ +enable_language(C) +set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE) +try_compile(result ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.c + OUTPUT_VARIABLE out + COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/copy + COPY_FILE_ERROR copy_err + ) +if(NOT result) + message(FATAL_ERROR "try_compile failed:\n${out}") +endif() +if(copy_err) + message(FATAL_ERROR "try_compile COPY_FILE failed:\n${copy_err}") +endif() diff --git a/Tests/RunCMake/try_compile/TargetTypeInvalid-result.txt b/Tests/RunCMake/try_compile/TargetTypeInvalid-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/try_compile/TargetTypeInvalid-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/TargetTypeInvalid-stderr.txt b/Tests/RunCMake/try_compile/TargetTypeInvalid-stderr.txt new file mode 100644 index 0000000..08b281a --- /dev/null +++ b/Tests/RunCMake/try_compile/TargetTypeInvalid-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at TargetTypeInvalid.cmake:2 \(try_compile\): + Invalid value 'INVALID' for CMAKE_TRY_COMPILE_TARGET_TYPE. Only + 'EXECUTABLE' and 'STATIC_LIBRARY' are allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/try_compile/TargetTypeInvalid.cmake b/Tests/RunCMake/try_compile/TargetTypeInvalid.cmake new file mode 100644 index 0000000..0bbc4ac --- /dev/null +++ b/Tests/RunCMake/try_compile/TargetTypeInvalid.cmake @@ -0,0 +1,2 @@ +set(CMAKE_TRY_COMPILE_TARGET_TYPE INVALID) +try_compile(result ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src.c) diff --git a/Tests/RunCMake/try_compile/TargetTypeStatic.cmake b/Tests/RunCMake/try_compile/TargetTypeStatic.cmake new file mode 100644 index 0000000..006b8b8 --- /dev/null +++ b/Tests/RunCMake/try_compile/TargetTypeStatic.cmake @@ -0,0 +1,14 @@ +enable_language(C) +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) +try_compile(result ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/other.c + OUTPUT_VARIABLE out + COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/copy + COPY_FILE_ERROR copy_err + ) +if(NOT result) + message(FATAL_ERROR "try_compile failed:\n${out}") +endif() +if(copy_err) + message(FATAL_ERROR "try_compile COPY_FILE failed:\n${copy_err}") +endif() diff --git a/Tests/RunCMake/try_compile/other.c b/Tests/RunCMake/try_compile/other.c new file mode 100644 index 0000000..6c24f10 --- /dev/null +++ b/Tests/RunCMake/try_compile/other.c @@ -0,0 +1 @@ +int other(void) { return 0; } |