diff options
Diffstat (limited to 'Tests')
63 files changed, 646 insertions, 136 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 6e35df9..112455b 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -271,14 +271,6 @@ if(BUILD_TESTING) find_package(Qt5Widgets QUIET NO_MODULE) endif() - if(NOT CMake_TEST_EXTERNAL_CMAKE) - add_subdirectory(CMakeLib) - endif() - add_subdirectory(CMakeOnly) - add_subdirectory(RunCMake) - - add_subdirectory(FindPackageModeMakefileTest) - # Collect a list of all test build directories. set(TEST_BUILD_DIRS) @@ -342,6 +334,27 @@ if(BUILD_TESTING) endif() endif() + if(CMake_TEST_XCODE_VERSION AND CMAKE_OSX_SDKVERSION AND CMAKE_OSX_SDKPRODUCT) + if((NOT CMake_TEST_XCODE_VERSION VERSION_LESS 6.1) AND + ((NOT CMAKE_OSX_SDKPRODUCT STREQUAL "Mac OS X") OR + (NOT CMAKE_OSX_SDKVERSION VERSION_LESS 10.10))) + if(CMAKE_GENERATOR STREQUAL "Xcode") + set(CMake_TEST_XCODE_SWIFT 1) + endif() + endif() + endif() + if(NOT DEFINED CMake_TEST_Swift) + if(CMAKE_Swift_COMPILER OR CMake_TEST_XCODE_SWIFT) + set(CMake_TEST_Swift 1) + endif() + endif() + + if(NOT DEFINED CMake_TEST_OBJC) + if(APPLE AND CMAKE_C_COMPILER_ID MATCHES "Clang|GNU") + set(CMake_TEST_OBJC 1) + endif() + endif() + # Use 1500 or CTEST_TEST_TIMEOUT for long test timeout value, # whichever is greater. set(CMAKE_LONG_TEST_TIMEOUT 1500) @@ -352,6 +365,14 @@ if(BUILD_TESTING) set(CMAKE_LONG_TEST_TIMEOUT 1500) endif() + if(NOT CMake_TEST_EXTERNAL_CMAKE) + add_subdirectory(CMakeLib) + endif() + add_subdirectory(CMakeOnly) + add_subdirectory(RunCMake) + + add_subdirectory(FindPackageModeMakefileTest) + add_test(NAME CMake.Copyright COMMAND ${CMAKE_CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/CMakeCopyright.cmake) @@ -380,16 +401,7 @@ if(BUILD_TESTING) ADD_TEST_MACRO(MissingSourceFile MissingSourceFile) set_tests_properties(MissingSourceFile PROPERTIES PASS_REGULAR_EXPRESSION "CMake Error at CMakeLists.txt:3 \\(add_executable\\):[ \r\n]*Cannot find source file:[ \r\n]*DoesNotExist/MissingSourceFile.c") - if(CMake_TEST_XCODE_VERSION AND CMAKE_OSX_SDKVERSION AND CMAKE_OSX_SDKPRODUCT) - if((NOT CMake_TEST_XCODE_VERSION VERSION_LESS 6.1) AND - ((NOT CMAKE_OSX_SDKPRODUCT STREQUAL "Mac OS X") OR - (NOT CMAKE_OSX_SDKVERSION VERSION_LESS 10.10))) - if(CMAKE_GENERATOR STREQUAL "Xcode") - set(CMake_TEST_XCODE_SWIFT 1) - endif() - endif() - endif() - if(CMAKE_Swift_COMPILER OR CMake_TEST_XCODE_SWIFT) + if(CMake_TEST_Swift) ADD_TEST_MACRO(SwiftOnly SwiftOnly) if(CMake_TEST_XCODE_SWIFT) ADD_TEST_MACRO(SwiftMix SwiftMix) @@ -432,6 +444,11 @@ if(BUILD_TESTING) endif() endif() + if(CMake_TEST_OBJC) + add_subdirectory(ObjC) + add_subdirectory(ObjCXX) + endif() + if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([^9]|[9][0-9])") ADD_TEST_MACRO(CSharpOnly CSharpOnly) if(NOT CMAKE_VS_PLATFORM_NAME STREQUAL "ARM64") @@ -2500,9 +2517,6 @@ if(BUILD_TESTING) -Dgen=${CMAKE_GENERATOR} -P ${CMake_SOURCE_DIR}/Tests/CFBundleTest/VerifyResult.cmake) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CFBundleTest") - - add_subdirectory(ObjC) - add_subdirectory(ObjCXX) endif() endif() diff --git a/Tests/CMakeTests/String-TIMESTAMP-TimeZone.cmake b/Tests/CMakeTests/String-TIMESTAMP-TimeZone.cmake new file mode 100644 index 0000000..eb2eb42 --- /dev/null +++ b/Tests/CMakeTests/String-TIMESTAMP-TimeZone.cmake @@ -0,0 +1,22 @@ +string(TIMESTAMP output "%z") + +STRING(LENGTH output output_length) + +message("~${output}~") + +set(expected_output_length 6) + +if(NOT(${output_length} EQUAL ${expected_output_length})) + message(FATAL_ERROR "expected ${expected_output_length} entries in output with all specifiers; found ${output_length}") +endif() + +string(SUBSTRING ${output} 0 1 output0) +string(SUBSTRING ${output} 4 1 output4) + +if(NOT((${output0} STREQUAL "-") OR (${output0} STREQUAL "+"))) + message(FATAL_ERROR "expected output[0] equ '+' or '-'; found: '${output0}'") +endif() + +if(NOT((${output4} STREQUAL "0") OR (${output4} STREQUAL "5"))) + message(FATAL_ERROR "expected output[4] equ '0' or '5'; found: '${output4}'") +endif() diff --git a/Tests/CMakeTests/StringTest.cmake.in b/Tests/CMakeTests/StringTest.cmake.in index 154afa7..5f8b111 100644 --- a/Tests/CMakeTests/StringTest.cmake.in +++ b/Tests/CMakeTests/StringTest.cmake.in @@ -44,6 +44,8 @@ set(TIMESTAMP-IncompleteSpecifier-RESULT 0) set(TIMESTAMP-IncompleteSpecifier-STDERR "~foobar%~") set(TIMESTAMP-AllSpecifiers-RESULT 0) set(TIMESTAMP-AllSpecifiers-STDERR "~[0-9]+(;[0-9]+)*~") +set(TIMESTAMP-TimeZone-RESULT 0) +set(TIMESTAMP-TimeZone-STDERR "~[-,+][0-9][0-9][0-9][0-9]~") set(TIMESTAMP-MonthWeekNames-RESULT 0) set(TIMESTAMP-MonthWeekNames-STDERR "~[^%]+;[^%]+~") set(TIMESTAMP-UnixTime-RESULT 0) @@ -75,6 +77,7 @@ check_cmake_test(String TIMESTAMP-IncompleteSpecifier TIMESTAMP-AllSpecifiers TIMESTAMP-MonthWeekNames + TIMESTAMP-TimeZone TIMESTAMP-UnixTime ) diff --git a/Tests/CheckSourceTree/check.cmake b/Tests/CheckSourceTree/check.cmake index c2e3529..6341bd6 100644 --- a/Tests/CheckSourceTree/check.cmake +++ b/Tests/CheckSourceTree/check.cmake @@ -3,6 +3,14 @@ if(DEFINED ENV{CTEST_REAL_HOME}) set(ENV{HOME} "$ENV{CTEST_REAL_HOME}") endif() +file(GLOB known_files + "${CMake_SOURCE_DIR}/Tests/JavaExportImport/InstallExport/hs_err_pid*.log" + "${CMake_SOURCE_DIR}/Tests/JavaNativeHeaders/hs_err_pid*.log" + ) +if(known_files) + file(REMOVE ${known_files}) +endif() + execute_process( COMMAND "${GIT_EXECUTABLE}" status WORKING_DIRECTORY "${CMake_SOURCE_DIR}" diff --git a/Tests/CustomCommandByproducts/CMakeLists.txt b/Tests/CustomCommandByproducts/CMakeLists.txt index 08c897c..e391a6f 100644 --- a/Tests/CustomCommandByproducts/CMakeLists.txt +++ b/Tests/CustomCommandByproducts/CMakeLists.txt @@ -149,6 +149,29 @@ set_property(TARGET ExternalLibraryWithSubstitution PROPERTY IMPORTED_LOCATION ${binary_dir}${cfg}/${CMAKE_STATIC_LIBRARY_PREFIX}ExternalLibrary${CMAKE_STATIC_LIBRARY_SUFFIX}) add_dependencies(ExternalLibraryWithSubstitution ExtTargetSubst) +# Generate the library file of an imported target as an install byproduct +# of an external project. The byproduct uses <INSTALL_DIR> that is substituted +# by the real install path +if(_isMultiConfig) + set(cfg /${CMAKE_CFG_INTDIR}) +else() + set(cfg) +endif() +include(ExternalProject) +ExternalProject_Add(ExtTargetInstallSubst + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/External" + DOWNLOAD_COMMAND "" + INSTALL_COMMAND + "${CMAKE_COMMAND}" -E copy_directory "<BINARY_DIR>${cfg}" "<INSTALL_DIR>${cfg}" + BUILD_BYPRODUCTS "<BINARY_DIR>${cfg}/${CMAKE_STATIC_LIBRARY_PREFIX}ExternalLibrary${CMAKE_STATIC_LIBRARY_SUFFIX}" + INSTALL_BYPRODUCTS "<INSTALL_DIR>${cfg}/${CMAKE_STATIC_LIBRARY_PREFIX}ExternalLibrary${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) +ExternalProject_Get_Property(ExtTargetInstallSubst install_dir) +add_library(ExternalLibraryWithInstallDirSubstitution STATIC IMPORTED) +set_property(TARGET ExternalLibraryWithInstallDirSubstitution PROPERTY IMPORTED_LOCATION + ${install_dir}${cfg}/${CMAKE_STATIC_LIBRARY_PREFIX}ExternalLibrary${CMAKE_STATIC_LIBRARY_SUFFIX}) +add_dependencies(ExternalLibraryWithInstallDirSubstitution ExtTargetInstallSubst) + # Add an executable consuming all the byproducts. add_executable(CustomCommandByproducts CustomCommandByproducts.c @@ -169,6 +192,18 @@ add_dependencies(CustomCommandByproducts Producer2) target_link_libraries(CustomCommandByproducts ExternalLibrary) +add_executable(ExternalLibraryByproducts ExternalLibraryByproducts.c) +target_link_libraries(ExternalLibraryByproducts ExternalLibrary) + +add_executable(ExternalLibraryByproducts_WithSubstitution ExternalLibraryByproducts.c) +target_link_libraries(ExternalLibraryByproducts_WithSubstitution ExternalLibraryWithSubstitution) + +add_executable(ExternalLibraryByproducts_WithInstallDirSubstitution ExternalLibraryByproducts.c) +target_link_libraries( + ExternalLibraryByproducts_WithInstallDirSubstitution + ExternalLibraryWithInstallDirSubstitution +) + if(CMAKE_GENERATOR STREQUAL "Ninja") add_custom_target(CheckNinja ALL COMMENT "Checking build.ninja" diff --git a/Tests/CustomCommandByproducts/ExternalLibraryByproducts.c b/Tests/CustomCommandByproducts/ExternalLibraryByproducts.c new file mode 100644 index 0000000..3588e53 --- /dev/null +++ b/Tests/CustomCommandByproducts/ExternalLibraryByproducts.c @@ -0,0 +1,5 @@ +extern int ExternalLibrary(void); +int main(void) +{ + return (ExternalLibrary() + 1); +} diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index ebbe288..6187966 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -261,13 +261,24 @@ else() set(test_shell_path2 /shell/path /another/path) endif() +set(test_shell_path_genex "$<SHELL_PATH:${test_shell_path}>") +set(test_shell_path2_genex "$<SHELL_PATH:${test_shell_path2}>") +if(msys1_prefix) + # Add a prefix to the value produced by the genex so that the path does + # not look absolute, thus suppressing conversion by MSYS 1.0 bash. + set(test_shell_path_genex "${msys1_prefix}${test_shell_path_genex}") + # There is no way to suppress conversion of the second path in + # MSYS 1.0 bash, so do the comparison at generate time instead. + set(test_shell_path2_genex "$<STREQUAL:${test_shell_path2_genex},/c/shell/path:/d/another/path>") +endif() + add_custom_target(check-part4 ALL COMMAND ${msys2_no_conv} ${CMAKE_COMMAND} # Prefix path to bypass its further conversion when being processed by # CMake as command-line argument -Dmsys1_prefix=${msys1_prefix} - -Dtest_shell_path=${msys1_prefix}$<SHELL_PATH:${test_shell_path}> - "-Dtest_shell_path2=$<SHELL_PATH:${test_shell_path2}>" + "-Dtest_shell_path=${test_shell_path_genex}" + "-Dtest_shell_path2=${test_shell_path2_genex}" -Dif_1=$<IF:1,a,b> -Dif_2=$<IF:0,a,b> -Dif_3=$<IF:$<EQUAL:10,30>,a,b> diff --git a/Tests/GeneratorExpression/check-part4.cmake b/Tests/GeneratorExpression/check-part4.cmake index a7e0944..28f3699 100644 --- a/Tests/GeneratorExpression/check-part4.cmake +++ b/Tests/GeneratorExpression/check-part4.cmake @@ -16,8 +16,13 @@ else() check(test_shell_path [[/shell/path]]) endif() if(WIN32) - if(CMAKE_GENERATOR STREQUAL "MSYS Makefiles" AND NOT msys1_prefix) - check(test_shell_path2 [[/c/shell/path:/d/another/path]]) + if(CMAKE_GENERATOR STREQUAL "MSYS Makefiles") + if(msys1_prefix) + # The comparison was done at generate time with the STREQUAL genex. + check(test_shell_path2 [[1]]) + else() + check(test_shell_path2 [[/c/shell/path:/d/another/path]]) + endif() elseif(CMAKE_GENERATOR STREQUAL "Unix Makefiles") check(test_shell_path2 [[c:/shell/path;d:/another/path]]) else() 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 3038ed8..ad5cbb2 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -299,8 +299,8 @@ if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja") add_RunCMake_test(CompilerChange) endif() add_RunCMake_test(CompilerNotFound) -if (APPLE AND CMAKE_C_COMPILER_ID MATCHES "Clang|GNU") - list(APPEND CompilerTest_ARGS -DCMake_TEST_OBJC=1) +if(DEFINED CMake_TEST_OBJC) + list(APPEND CompilerTest_ARGS -DCMake_TEST_OBJC=${CMake_TEST_OBJC}) endif() if(CMAKE_Fortran_COMPILER) list(APPEND CompilerTest_ARGS -DCMake_TEST_Fortran=1) @@ -361,7 +361,7 @@ if(XCODE_VERSION) set(GeneratorToolset_ARGS -DXCODE_VERSION=${XCODE_VERSION}) endif() add_RunCMake_test(GeneratorToolset) -add_RunCMake_test(GetPrerequisites) +add_RunCMake_test(GetPrerequisites -DSAMPLE_EXE=$<TARGET_FILE:exit_code>) add_RunCMake_test(GNUInstallDirs -DSYSTEM_NAME=${CMAKE_SYSTEM_NAME}) add_RunCMake_test(GoogleTest) # Note: does not actually depend on Google Test add_RunCMake_test(Graphviz) @@ -502,64 +502,15 @@ if(APPLE) endif() function(add_RunCMake_test_try_compile) - if(CMAKE_VERSION VERSION_LESS 3.9.20170907 AND "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC") - # Older CMake versions do not know about MSVC language standards. - # Approximate our logic from MSVC-CXX.cmake. - if ((NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.24215.1 AND - CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10) OR - NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10.25017) - set(CMAKE_CXX_STANDARD_DEFAULT 14) - elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16.0) - set(CMAKE_CXX_STANDARD_DEFAULT "") - else() - unset(CMAKE_CXX_STANDARD_DEFAULT) - endif() - endif() - if(CMAKE_VERSION VERSION_LESS 3.18.20200813 AND "x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC") - # Older CMake versions do not know about MSVC language standards. - # Approximate our logic from MSVC-C.cmake. - if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 19.27) - set(CMAKE_C_STANDARD_DEFAULT 99) - else() - set(CMAKE_C_STANDARD_DEFAULT "") - endif() - endif() - if(CMAKE_VERSION VERSION_LESS 3.20.20210225 AND "x${CMAKE_C_COMPILER_ID}" STREQUAL "xClang") - # Older CMake versions do not know about Clang MSVC compatibility mode - # standards. Approximate the logic from Clang-C.cmake. - if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0) - set(CMAKE_C_STANDARD_DEFAULT 17) - elseif(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 3.5.2) - set(CMAKE_C_STANDARD_DEFAULT 11) - endif() - endif() - if(CMAKE_VERSION VERSION_LESS 3.20.6 AND "x${CMAKE_C_COMPILER_ID}" STREQUAL "xIntelLLVM" AND "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC") - # Older CMake versions accidentally set the default standards to empty when - # IntelLLVM targets the MSVC ABI, thus not activating standard selection. - # Approximate the logic from IntelLLVM-{C,CXX}.cmake. - if(DEFINED CMAKE_C_STANDARD_DEFAULT AND "${CMAKE_C_STANDARD_DEFAULT}" STREQUAL "") - set(CMAKE_C_STANDARD_DEFAULT 17) - endif() - if(DEFINED CMAKE_CXX_STANDARD_DEFAULT AND "${CMAKE_CXX_STANDARD_DEFAULT}" STREQUAL "") - set(CMAKE_CXX_STANDARD_DEFAULT 14) - endif() - endif() foreach( var IN ITEMS CMAKE_SYSTEM_NAME - CMAKE_C_COMPILER_ID - CMAKE_C_COMPILER_VERSION - CMAKE_C_STANDARD_DEFAULT - CMAKE_CXX_COMPILER_ID - CMAKE_CXX_COMPILER_VERSION - CMAKE_CXX_STANDARD_DEFAULT CMake_TEST_CUDA CMake_TEST_ISPC CMake_TEST_HIP + CMake_TEST_OBJC CMake_TEST_FILESYSTEM_1S - CMAKE_OBJC_STANDARD_DEFAULT - CMAKE_OBJCXX_STANDARD_DEFAULT ) if(DEFINED ${var}) list(APPEND try_compile_ARGS -D${var}=${${var}}) @@ -752,11 +703,13 @@ add_RunCMake_test(target_sources) add_RunCMake_test(CheckCompilerFlag -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(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}) @@ -896,13 +849,13 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") if(DEFINED CMake_TEST_ISPC) list(APPEND CompilerLauncher_ARGS -DCMake_TEST_ISPC=${CMake_TEST_ISPC}) endif() + if(DEFINED CMake_TEST_OBJC) + list(APPEND CompilerLauncher_ARGS -DCMake_TEST_OBJC=${CMake_TEST_OBJC}) + list(APPEND LinkerLauncher_ARGS -DCMake_TEST_OBJC=${CMake_TEST_OBJC}) + endif() if(CMAKE_Fortran_COMPILER) list(APPEND CompilerLauncher_ARGS -DCMake_TEST_Fortran=1) endif() - if (APPLE AND CMAKE_C_COMPILER_ID MATCHES "Clang|GNU") - list(APPEND CompilerLauncher_ARGS -DCMake_TEST_OBJC=1) - list(APPEND LinkerLauncher_ARGS -DCMake_TEST_OBJC=1) - endif() add_RunCMake_test(CompilerLauncher) set_property(TEST RunCMake.CompilerLauncher APPEND PROPERTY LABELS "CUDA;HIP;ISPC") 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/CheckCompilerFlag/CheckCompilerFlagSwift.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagSwift.cmake new file mode 100644 index 0000000..23b3006 --- /dev/null +++ b/Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagSwift.cmake @@ -0,0 +1,21 @@ +enable_language (Swift) +include(CheckCompilerFlag) + +set(Swift 1) + +# test that the check uses an isolated locale +set(_env_LC_ALL "${LC_ALL}") +set(ENV{LC_ALL} "BAD") + +check_compiler_flag(Swift "-foo-as-blarpy" SHOULD_FAIL) +if(SHOULD_FAIL) + message(SEND_ERROR "invalid Swift compile flag didn't fail.") +endif() + +check_compiler_flag(Swift "-parseable-output" SHOULD_WORK) +if(NOT SHOULD_WORK) + message(SEND_ERROR "Swift compiler flag '-parseable-output' check failed") +endif() + +# Reset locale +set(ENV{LC_ALL} ${_env_LC_ALL}) diff --git a/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake b/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake index b0e025c..81429a6 100644 --- a/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake +++ b/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake @@ -32,3 +32,7 @@ endif() if(APPLE) run_cmake(HeaderpadWorkaround) endif() + +if(CMake_TEST_Swift) + run_cmake(CheckCompilerFlagSwift) +endif() 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/compare_files/.gitattributes b/Tests/RunCMake/CommandLine/compare_files/.gitattributes index 91d5c10..d03da96 100644 --- a/Tests/RunCMake/CommandLine/compare_files/.gitattributes +++ b/Tests/RunCMake/CommandLine/compare_files/.gitattributes @@ -1,2 +1,2 @@ -crlf eol=crlf -lf eol=lf +crlf -text -whitespace +lf -text diff --git a/Tests/RunCMake/CommandLine/compare_files/crlf b/Tests/RunCMake/CommandLine/compare_files/crlf index a29bdeb..495181c 100644 --- a/Tests/RunCMake/CommandLine/compare_files/crlf +++ b/Tests/RunCMake/CommandLine/compare_files/crlf @@ -1 +1 @@ -line1 +line1
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/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake index f149d99..69ab4da 100644 --- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake @@ -113,23 +113,33 @@ message(STATUS "Verifying target \"${tgt}\"") if (NOT TARGET ${tgt}) message(FATAL_ERROR "No import target for fake link options package") endif() -get_target_property(link_options ${tgt} INTERFACE_LINK_OPTIONS) -if (NOT link_options STREQUAL expected_link_options) - message(FATAL_ERROR - "Additional link options not present in INTERFACE_LINK_OPTIONS property\n" - "expected: \"${expected_link_options}\", but got \"${link_options}\"" - ) -endif() -get_target_property(inc_dirs ${tgt} INTERFACE_INCLUDE_DIRECTORIES) -set(expected_inc_dirs "/special" "/other" "/more") +# Some versions of pkg-config on Windows don't parse the Libs and Cflags +# correctly. The pkg-config that comes with Strawberry perl is one example. +# It appears to treat the dummymain part of Libs as a library and only returns +# -e. It also doesn't recognize "-isystem /other", presumably because it doesn't +# support having a space between "-isystem" and the directory after it (it does +# give us the "-isystem/more" flag). Since we can't reliably test for these, +# we don't enable these checks on Windows. +if(NOT WIN32) + get_target_property(link_options ${tgt} INTERFACE_LINK_OPTIONS) + if (NOT link_options STREQUAL expected_link_options) + message(FATAL_ERROR + "Additional link options not present in INTERFACE_LINK_OPTIONS property\n" + "expected: \"${expected_link_options}\", but got \"${link_options}\"" + ) + endif() -if (NOT inc_dirs STREQUAL expected_inc_dirs) - message(FATAL_ERROR - "Additional include directories not correctly present in INTERFACE_INCLUDE_DIRECTORIES property\n" - "expected: \"${expected_inc_dirs}\", got \"${inc_dirs}\"" - ) -endif () + get_target_property(inc_dirs ${tgt} INTERFACE_INCLUDE_DIRECTORIES) + set(expected_inc_dirs "/special" "/other" "/more") + + if (NOT inc_dirs STREQUAL expected_inc_dirs) + message(FATAL_ERROR + "Additional include directories not correctly present in INTERFACE_INCLUDE_DIRECTORIES property\n" + "expected: \"${expected_inc_dirs}\", got \"${inc_dirs}\"" + ) + endif () +endif() get_target_property(c_opts ${tgt} INTERFACE_COMPILE_OPTIONS) set(expected_c_opts "-DA-isystem/foo") # this is an invalid option, but a good testcase diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_VERSION_OPERATORS.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_VERSION_OPERATORS.cmake index 2a505c6..f7a9815 100644 --- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_VERSION_OPERATORS.cmake +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_VERSION_OPERATORS.cmake @@ -20,14 +20,15 @@ Libs: -lcmakeinternalfakepackage # Always find the .pc file in the calls further below so that we can test that # the import target find_library() calls handle the NO...PATH options correctly -set(ENV{PKG_CONFIG_PATH} ${fakePkgDir}/lib/pkgconfig) +cmake_path(CONVERT "${fakePkgDir}/lib/pkgconfig" TO_NATIVE_PATH_LIST confPath) +set(ENV{PKG_CONFIG_PATH} "${confPath}") -pkg_check_modules(FakePackageGE REQUIRED QUIET "cmakeinternalfakepackage >= 8") +pkg_check_modules(FakePackageGE REQUIRED QUIET "cmakeinternalfakepackage>=8") if (NOT FakePackageGE_FOUND) message(FATAL_ERROR "fake package >= 8 not found") endif() -pkg_check_modules(FakePackageGE_FAIL QUIET "cmakeinternalfakepackage >= 8.10") +pkg_check_modules(FakePackageGE_FAIL QUIET "cmakeinternalfakepackage>=8.10") if (FakePackageGE_FAIL_FOUND) message(FATAL_ERROR "fake package >= 8.10 found") endif() @@ -37,17 +38,17 @@ if (NOT FakePackageLE_FOUND) message(FATAL_ERROR "fake package <= 9 not found") endif() -pkg_check_modules(FakePackageLE_FAIL QUIET "cmakeinternalfakepackage <= 8.1") +pkg_check_modules(FakePackageLE_FAIL QUIET "cmakeinternalfakepackage<=8.1") if (FakePackageLE_FAIL_FOUND) message(FATAL_ERROR "fake package <= 8.1 found") endif() -pkg_check_modules(FakePackageGT REQUIRED QUIET "cmakeinternalfakepackage > 8") +pkg_check_modules(FakePackageGT REQUIRED QUIET "cmakeinternalfakepackage>8") if (NOT FakePackageGT_FOUND) message(FATAL_ERROR "fake package > 8 not found") endif() -pkg_check_modules(FakePackageGT_FAIL QUIET "cmakeinternalfakepackage > 8.9") +pkg_check_modules(FakePackageGT_FAIL QUIET "cmakeinternalfakepackage>8.9") if (FakePackageGT_FAIL_FOUND) message(FATAL_ERROR "fake package > 8.9 found") endif() @@ -57,7 +58,7 @@ if (NOT FakePackageLT_FOUND) message(FATAL_ERROR "fake package < 9 not found") endif() -pkg_check_modules(FakePackageLT_FAIL QUIET "cmakeinternalfakepackage < 8.9") +pkg_check_modules(FakePackageLT_FAIL QUIET "cmakeinternalfakepackage<8.9") if (FakePackageLT_FAIL_FOUND) message(FATAL_ERROR "fake package < 8.9 found") endif() @@ -67,17 +68,17 @@ if (NOT FakePackageEQ_FOUND) message(FATAL_ERROR "fake package = 8.9 not found") endif() -pkg_check_modules(FakePackageEQ_FAIL QUIET "cmakeinternalfakepackage = 8.8") +pkg_check_modules(FakePackageEQ_FAIL QUIET "cmakeinternalfakepackage=8.8") if (FakePackageEQ_FAIL_FOUND) message(FATAL_ERROR "fake package = 8.8 found") endif() -pkg_check_modules(FakePackageEQ_INV QUIET "cmakeinternalfakepackage == 8.9") +pkg_check_modules(FakePackageEQ_INV QUIET "cmakeinternalfakepackage==8.9") if (FakePackageEQ_FAIL_FOUND) message(FATAL_ERROR "fake package == 8.9 found") endif() -pkg_check_modules(FakePackageLLT_INV QUIET "cmakeinternalfakepackage <<= 9") +pkg_check_modules(FakePackageLLT_INV QUIET "cmakeinternalfakepackage<<=9") if (FakePackageLLT_FAIL_FOUND) message(FATAL_ERROR "fake package <<= 9 found") endif() diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake index 661ae3f..6b8e884 100644 --- a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake @@ -7,13 +7,18 @@ set(ENV{CMAKE_FRAMEWORK_PATH} "") run_cmake(PkgConfigDoesNotExist) -run_cmake(FindPkgConfig_CMP0126_NEW) -run_cmake(FindPkgConfig_NO_PKGCONFIG_PATH) -run_cmake(FindPkgConfig_PKGCONFIG_PATH) -run_cmake(FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH) -run_cmake(FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH) +if(NOT WIN32) + # FIXME: The Windows implementation of these tests do not work. + # They are disabled until they can be updated to a working state. + run_cmake(FindPkgConfig_CMP0126_NEW) + run_cmake(FindPkgConfig_NO_PKGCONFIG_PATH) + run_cmake(FindPkgConfig_PKGCONFIG_PATH) + run_cmake(FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH) + run_cmake(FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH) + run_cmake(FindPkgConfig_GET_MATCHING_ARGN) +endif() + run_cmake(FindPkgConfig_extract_frameworks) -run_cmake(FindPkgConfig_GET_MATCHING_ARGN) if(APPLE) run_cmake(FindPkgConfig_extract_frameworks_target) diff --git a/Tests/RunCMake/GetPrerequisites/ExecutableScripts.cmake b/Tests/RunCMake/GetPrerequisites/ExecutableScripts.cmake index d1bc9b1..9cc05d0 100644 --- a/Tests/RunCMake/GetPrerequisites/ExecutableScripts.cmake +++ b/Tests/RunCMake/GetPrerequisites/ExecutableScripts.cmake @@ -10,7 +10,9 @@ endfunction() # Should not throw any errors # Regular executable -get_prerequisites(${CMAKE_COMMAND} cmake_prereqs 1 1 "" "") +if(SAMPLE_EXE) + get_prerequisites("${SAMPLE_EXE}" cmake_prereqs 1 1 "" "") +endif() # Shell script check_script(${CMAKE_CURRENT_LIST_DIR}/script.sh) # Batch script diff --git a/Tests/RunCMake/GetPrerequisites/RunCMakeTest.cmake b/Tests/RunCMake/GetPrerequisites/RunCMakeTest.cmake index a635e38..5550c02 100644 --- a/Tests/RunCMake/GetPrerequisites/RunCMakeTest.cmake +++ b/Tests/RunCMake/GetPrerequisites/RunCMakeTest.cmake @@ -1,4 +1,4 @@ include(RunCMake) run_cmake_command(TargetMissing ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/TargetMissing.cmake) -run_cmake_command(ExecutableScripts ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/ExecutableScripts.cmake) +run_cmake_command(ExecutableScripts ${CMAKE_COMMAND} -DSAMPLE_EXE=${SAMPLE_EXE} -P ${RunCMake_SOURCE_DIR}/ExecutableScripts.cmake) diff --git a/Tests/RunCMake/NinjaMultiConfig/CompileCommands-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CompileCommands-check.cmake index a1ae6ac..30b24bf 100644 --- a/Tests/RunCMake/NinjaMultiConfig/CompileCommands-check.cmake +++ b/Tests/RunCMake/NinjaMultiConfig/CompileCommands-check.cmake @@ -7,7 +7,8 @@ set(expected_compile_commands ]*Debug[^ ]*", "file": "[^ -]*(/Tests/RunCMake/NinjaMultiConfig/main\.c|\\\\Tests\\\\RunCMake\\\\NinjaMultiConfig\\\\main\.c)" +]*(/Tests/RunCMake/NinjaMultiConfig/main\.c|\\\\Tests\\\\RunCMake\\\\NinjaMultiConfig\\\\main\.c)", + "output": "(CMakeFiles/exe\.dir/Debug/main\.c\.o|CMakeFiles\\\\exe\.dir\\\\Debug\\\\main\.c\.obj)" }, { "directory": "[^ @@ -16,7 +17,8 @@ set(expected_compile_commands ]*Release[^ ]*", "file": "[^ -]*(/Tests/RunCMake/NinjaMultiConfig/main\.c|\\\\Tests\\\\RunCMake\\\\NinjaMultiConfig\\\\main\.c)" +]*(/Tests/RunCMake/NinjaMultiConfig/main\.c|\\\\Tests\\\\RunCMake\\\\NinjaMultiConfig\\\\main\.c)", + "output": "(CMakeFiles/exe\.dir/Release/main\.c\.o|CMakeFiles\\\\exe\.dir\\\\Release\\\\main\.c\.obj)" } ]$]==]) diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index f027e94..ed74896 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -89,3 +89,10 @@ run_cmake(VsDotnetTargetFramework) run_cmake(VsDotnetTargetFrameworkVersion) run_cmake(VsNoCompileBatching) run_cmake(DebugInformationFormat) +run_cmake(VsCLREmpty) +run_cmake(VsCLRPure) +run_cmake(VsCLRSafe) + +if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.20) + run_cmake(VsCLRNetcore) +endif() diff --git a/Tests/RunCMake/VS10Project/VsCLREmpty-check.cmake b/Tests/RunCMake/VS10Project/VsCLREmpty-check.cmake new file mode 100644 index 0000000..990da46 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsCLREmpty-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 "^ *<CompileAsManaged>(.*)</CompileAsManaged>$") + set(propertyFound TRUE) + set(expectedValue "true") + set(actualValue ${CMAKE_MATCH_1}) + if(NOT (${actualValue} STREQUAL ${expectedValue})) + set(RunCMake_TEST_FAILED "CompileAsManaged \"${actualValue}\" differs from expected value \"${expectedValue}\".") + return() + endif() + endif() +endforeach() + +if(NOT propertyFound) + set(RunCMake_TEST_FAILED "Property CompileAsManaged not found in project file.") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsCLREmpty.cmake b/Tests/RunCMake/VS10Project/VsCLREmpty.cmake new file mode 100644 index 0000000..a622f26 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsCLREmpty.cmake @@ -0,0 +1,6 @@ +enable_language(CXX) + +add_library(foo foo.cpp) + +set_target_properties(foo PROPERTIES + COMMON_LANGUAGE_RUNTIME "") diff --git a/Tests/RunCMake/VS10Project/VsCLRNetcore-check.cmake b/Tests/RunCMake/VS10Project/VsCLRNetcore-check.cmake new file mode 100644 index 0000000..a5058d7 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsCLRNetcore-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 "^ *<CLRSupport>(.*)</CLRSupport>$") + set(propertyFound TRUE) + set(expectedValue "NetCore") + set(actualValue ${CMAKE_MATCH_1}) + if(NOT (${actualValue} STREQUAL ${expectedValue})) + set(RunCMake_TEST_FAILED "CLRSupport \"${actualValue}\" differs from expected value \"${expectedValue}\".") + return() + endif() + endif() +endforeach() + +if(NOT propertyFound) + set(RunCMake_TEST_FAILED "Property CLRSupport not found in project file.") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsCLRNetcore.cmake b/Tests/RunCMake/VS10Project/VsCLRNetcore.cmake new file mode 100644 index 0000000..c5ec2bc --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsCLRNetcore.cmake @@ -0,0 +1,6 @@ +enable_language(CXX) + +add_library(foo foo.cpp) + +set_target_properties(foo PROPERTIES + COMMON_LANGUAGE_RUNTIME "netcore") diff --git a/Tests/RunCMake/VS10Project/VsCLRPure-check.cmake b/Tests/RunCMake/VS10Project/VsCLRPure-check.cmake new file mode 100644 index 0000000..8ae73eb --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsCLRPure-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 "^ *<CompileAsManaged>(.*)</CompileAsManaged>$") + set(propertyFound TRUE) + set(expectedValue "Pure") + set(actualValue ${CMAKE_MATCH_1}) + if(NOT (${actualValue} STREQUAL ${expectedValue})) + set(RunCMake_TEST_FAILED "CompileAsManaged \"${actualValue}\" differs from expected value \"${expectedValue}\".") + return() + endif() + endif() +endforeach() + +if(NOT propertyFound) + set(RunCMake_TEST_FAILED "Property CompileAsManaged not found in project file.") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsCLRPure.cmake b/Tests/RunCMake/VS10Project/VsCLRPure.cmake new file mode 100644 index 0000000..f919a1c --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsCLRPure.cmake @@ -0,0 +1,6 @@ +enable_language(CXX) + +add_library(foo foo.cpp) + +set_target_properties(foo PROPERTIES + COMMON_LANGUAGE_RUNTIME "pure") diff --git a/Tests/RunCMake/VS10Project/VsCLRSafe-check.cmake b/Tests/RunCMake/VS10Project/VsCLRSafe-check.cmake new file mode 100644 index 0000000..ebb1f71 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsCLRSafe-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 "^ *<CompileAsManaged>(.*)</CompileAsManaged>$") + set(propertyFound TRUE) + set(expectedValue "Safe") + set(actualValue ${CMAKE_MATCH_1}) + if(NOT (${actualValue} STREQUAL ${expectedValue})) + set(RunCMake_TEST_FAILED "CompileAsManaged \"${actualValue}\" differs from expected value \"${expectedValue}\".") + return() + endif() + endif() +endforeach() + +if(NOT propertyFound) + set(RunCMake_TEST_FAILED "Property CompileAsManaged not found in project file.") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsCLRSafe.cmake b/Tests/RunCMake/VS10Project/VsCLRSafe.cmake new file mode 100644 index 0000000..5f114bf --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsCLRSafe.cmake @@ -0,0 +1,6 @@ +enable_language(CXX) + +add_library(foo foo.cpp) + +set_target_properties(foo PROPERTIES + COMMON_LANGUAGE_RUNTIME "safe") 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\)$ diff --git a/Tests/RunCMake/try_compile/Inspect.cmake b/Tests/RunCMake/try_compile/Inspect.cmake index added41..2977d02 100644 --- a/Tests/RunCMake/try_compile/Inspect.cmake +++ b/Tests/RunCMake/try_compile/Inspect.cmake @@ -1,4 +1,25 @@ +enable_language(C) enable_language(CXX) -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/info.cmake" " -set(CMAKE_CXX_EXTENSIONS_DEFAULT \"${CMAKE_CXX_EXTENSIONS_DEFAULT}\") -") +if(CMake_TEST_OBJC) + enable_language(OBJC) + enable_language(OBJCXX) +endif() + +set(info "") +foreach(var + CMAKE_C_COMPILER_ID + CMAKE_C_COMPILER_VERSION + CMAKE_C_STANDARD_DEFAULT + CMAKE_CXX_COMPILER_ID + CMAKE_CXX_COMPILER_VERSION + CMAKE_CXX_STANDARD_DEFAULT + CMAKE_CXX_EXTENSIONS_DEFAULT + CMAKE_OBJC_STANDARD_DEFAULT + CMAKE_OBJCXX_STANDARD_DEFAULT + ) + if(DEFINED ${var}) + string(APPEND info "set(${var} \"${${var}}\")\n") + endif() +endforeach() + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/info.cmake" "${info}") diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index 7245471..ad1cc29 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -1,5 +1,20 @@ include(RunCMake) +# Detect information from the toolchain: +# - CMAKE_C_COMPILER_ID +# - CMAKE_C_COMPILER_VERSION +# - CMAKE_C_STANDARD_DEFAULT +# - CMAKE_CXX_COMPILER_ID +# - CMAKE_CXX_COMPILER_VERSION +# - CMAKE_CXX_STANDARD_DEFAULT +# - CMAKE_CXX_EXTENSIONS_DEFAULT +# - CMAKE_OBJC_STANDARD_DEFAULT +# - CMAKE_OBJCXX_STANDARD_DEFAULT +run_cmake_with_options(Inspect + -DCMake_TEST_OBJC=${CMake_TEST_OBJC} + ) +include("${RunCMake_BINARY_DIR}/Inspect-build/info.cmake") + run_cmake(NoArgs) run_cmake(OneArg) run_cmake(TwoArgs) @@ -88,12 +103,6 @@ if(RunCMake_GENERATOR MATCHES "Make|Ninja") unset(RunCMake_TEST_NO_CLEAN) endif() -# Lookup CMAKE_CXX_EXTENSIONS_DEFAULT. -# FIXME: Someday we could move this to the top of the file and use it in -# place of some of the values passed by 'Tests/RunCMake/CMakeLists.txt'. -run_cmake(Inspect) -include("${RunCMake_BINARY_DIR}/Inspect-build/info.cmake") - # FIXME: Support more compilers and default standard levels. if (DEFINED CMAKE_CXX_STANDARD_DEFAULT AND DEFINED CMAKE_CXX_EXTENSIONS_DEFAULT AND ( diff --git a/Tests/SwiftMixLib/CMakeLists.txt b/Tests/SwiftMixLib/CMakeLists.txt index 40d3498..a52fc94 100644 --- a/Tests/SwiftMixLib/CMakeLists.txt +++ b/Tests/SwiftMixLib/CMakeLists.txt @@ -4,3 +4,6 @@ project(SwiftMixLib C CXX Swift) add_library(SwiftMixedLib lib.c lib.cpp lib.swift) add_executable(Swifty main.swift) target_link_libraries(Swifty PUBLIC SwiftMixedLib) + +add_executable(c_main main.c) +target_link_libraries(c_main PUBLIC SwiftMixedLib) diff --git a/Tests/SwiftMixLib/main.c b/Tests/SwiftMixLib/main.c new file mode 100644 index 0000000..6ecf984 --- /dev/null +++ b/Tests/SwiftMixLib/main.c @@ -0,0 +1,3 @@ +int main(int argc, char* argv[]) +{ +} diff --git a/Tests/UseSWIG/BasicPerl/CMakeLists.txt b/Tests/UseSWIG/BasicPerl/CMakeLists.txt index 671d529..1151739 100644 --- a/Tests/UseSWIG/BasicPerl/CMakeLists.txt +++ b/Tests/UseSWIG/BasicPerl/CMakeLists.txt @@ -4,7 +4,9 @@ project(TestBasicPerl CXX) include(CTest) -set(language "perl") +if(NOT DEFINED language) + set(language "perl") +endif() include (../BasicConfiguration.cmake) diff --git a/Tests/UseSWIG/CMakeLists.txt b/Tests/UseSWIG/CMakeLists.txt index c76e8a0..7c4925e 100644 --- a/Tests/UseSWIG/CMakeLists.txt +++ b/Tests/UseSWIG/CMakeLists.txt @@ -20,6 +20,16 @@ add_test(NAME UseSWIG.LegacyPerl COMMAND --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) +add_test(NAME UseSWIG.LegacyPerl5 COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/UseSWIG/LegacyPerl" + "${CMake_BINARY_DIR}/Tests/UseSWIG/LegacyPerl5" + ${build_generator_args} + --build-project TestLegacyPerl + --build-options ${build_options} -Dlanguage=perl5 + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) include(CheckLanguage) check_language(CSharp) @@ -66,6 +76,16 @@ add_test(NAME UseSWIG.BasicPerl COMMAND --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) +add_test(NAME UseSWIG.BasicPerl5 COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/UseSWIG/BasicPerl" + "${CMake_BINARY_DIR}/Tests/UseSWIG/BasicPerl5" + ${build_generator_args} + --build-project TestBasicPerl + --build-options ${build_options} -Dlanguage=perl5 + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) if(SWIG_FOUND AND NOT SWIG_VERSION VERSION_LESS "4.0.2" AND CMAKE_GENERATOR MATCHES "Make|Ninja|Xcode|Visual Studio (1[1-9]|[2-9][0-9])") add_test(NAME UseSWIG.Depfile.BasicPython COMMAND @@ -89,6 +109,16 @@ if(SWIG_FOUND AND NOT SWIG_VERSION VERSION_LESS "4.0.2" --build-options ${build_options} -DSWIG_USE_SWIG_DEPENDENCIES=ON --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) + add_test(NAME UseSWIG.Depfile.BasicPerl5 COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/UseSWIG/BasicPerl" + "${CMake_BINARY_DIR}/Tests/UseSWIG/BasicPerl5.Depfile" + ${build_generator_args} + --build-project TestBasicPerl + --build-options ${build_options} -DSWIG_USE_SWIG_DEPENDENCIES=ON -Dlanguage=perl5 + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) endif() if (CMake_TEST_UseSWIG_Fortran) diff --git a/Tests/UseSWIG/LegacyPerl/CMakeLists.txt b/Tests/UseSWIG/LegacyPerl/CMakeLists.txt index 90d92f4..be0b465 100644 --- a/Tests/UseSWIG/LegacyPerl/CMakeLists.txt +++ b/Tests/UseSWIG/LegacyPerl/CMakeLists.txt @@ -4,7 +4,9 @@ project(TestLegacyPerl CXX) include(CTest) -set(language "perl") +if(NOT DEFINED language) + set(language "perl") +endif() include (../LegacyConfiguration.cmake) |