diff options
Diffstat (limited to 'Tests')
76 files changed, 813 insertions, 78 deletions
diff --git a/Tests/CMakeCommands/target_compile_options/CMakeLists.txt b/Tests/CMakeCommands/target_compile_options/CMakeLists.txt index 1dedbae..a24cd53 100644 --- a/Tests/CMakeCommands/target_compile_options/CMakeLists.txt +++ b/Tests/CMakeCommands/target_compile_options/CMakeLists.txt @@ -8,7 +8,7 @@ add_executable(target_compile_options ) target_compile_options(target_compile_options PRIVATE $<$<CXX_COMPILER_ID:GNU>:-DMY_PRIVATE_DEFINE> - PUBLIC $<$<CXX_COMPILER_ID:GNU>:-DMY_PUBLIC_DEFINE> + PUBLIC $<$<COMPILE_LANG_AND_ID:CXX,GNU>:-DMY_PUBLIC_DEFINE> INTERFACE $<$<CXX_COMPILER_ID:GNU>:-DMY_INTERFACE_DEFINE> ) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index d992986..6901077 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -22,6 +22,7 @@ macro(ADD_TEST_MACRO NAME) endmacro() include(${CMAKE_CURRENT_SOURCE_DIR}/CheckFortran.cmake) +include(${CMAKE_CURRENT_SOURCE_DIR}/CheckSwift.cmake) # Fake a user home directory to avoid polluting the real one. if(DEFINED ENV{HOME} AND NOT CTEST_NO_TEST_HOME) @@ -365,11 +366,16 @@ if(BUILD_TESTING) ((NOT CMAKE_OSX_SDKPRODUCT STREQUAL "Mac OS X") OR (NOT CMAKE_OSX_SDKVERSION VERSION_LESS 10.10))) if(CMAKE_GENERATOR STREQUAL "Xcode") - ADD_TEST_MACRO(SwiftMix SwiftMix) - ADD_TEST_MACRO(SwiftOnly SwiftOnly) + set(CMake_TEST_XCODE_SWIFT 1) endif() endif() endif() + if(CMAKE_Swift_COMPILER OR CMake_TEST_XCODE_SWIFT) + ADD_TEST_MACRO(SwiftOnly SwiftOnly) + if(CMake_TEST_XCODE_SWIFT) + ADD_TEST_MACRO(SwiftMix SwiftMix) + endif() + endif() if(CMAKE_Fortran_COMPILER) ADD_TEST_MACRO(FortranOnly FortranOnly) endif() @@ -764,14 +770,14 @@ if(BUILD_TESTING) file(WRITE "${_TEST_DIR}/nightly-cmake.sh" "cd ${_TEST_DIR} ${CMake_BINARY_DIR}/bin/cmake -DCMAKE_CREATE_VERSION=nightly -P ${CMake_SOURCE_DIR}/Utilities/Release/${script} -${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release/upload_release.cmake +${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGHTLY_RELEASES}' ") add_test(${name} /bin/sh ${_TEST_DIR}/nightly-cmake.sh) if(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY) set_tests_properties (${name} PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) endif() endmacro() - if(CMAKE_BUILD_NIGHTLY_RELEASES) + if(CMake_BUILD_NIGHTLY_RELEASES) ADD_NIGHTLY_BUILD_TEST(CMakeNightlyWin32 win32_release.cmake) ADD_NIGHTLY_BUILD_TEST(CMakeNightlyWin64 @@ -2525,24 +2531,17 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release FAIL_REGULAR_EXPRESSION "CMakeLists.txt:5 \\(set\\):") list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset") - if("${CMAKE_GENERATOR}" MATCHES "Makefile" AND NOT WIN32) - # Ninja does not support ADDITIONAL_MAKE_CLEAN_FILES and therefore fails - # this test. (See #13371) - # Apparently Visual Studio does not support it either. As the MakeClean - # test above is only run with the Makefiles generator, only run this - # test with the Makefiles generator also. - add_test(WarnUnusedCliUnused ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/WarnUnusedCliUnused" - "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused" - ${build_generator_args} - --build-project WarnUnusedCliUnused - --build-options ${build_options} - "-DUNUSED_CLI_VARIABLE=Unused") - set_tests_properties(WarnUnusedCliUnused PROPERTIES - PASS_REGULAR_EXPRESSION "CMake Warning:.*Manually-specified variables were not used by the project:.* UNUSED_CLI_VARIABLE") - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused") - endif() + add_test(WarnUnusedCliUnused ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/WarnUnusedCliUnused" + "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused" + ${build_generator_args} + --build-project WarnUnusedCliUnused + --build-options ${build_options} + "-DUNUSED_CLI_VARIABLE=Unused") + set_tests_properties(WarnUnusedCliUnused PROPERTIES + PASS_REGULAR_EXPRESSION "CMake Warning:.*Manually-specified variables were not used by the project:.* UNUSED_CLI_VARIABLE") + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused") add_test(WarnUnusedCliUsed ${CMAKE_CTEST_COMMAND} --build-and-test diff --git a/Tests/CheckSwift.cmake b/Tests/CheckSwift.cmake new file mode 100644 index 0000000..fcbae7e --- /dev/null +++ b/Tests/CheckSwift.cmake @@ -0,0 +1,61 @@ +if(NOT CMAKE_GENERATOR MATCHES "Xcode|Ninja") + set(CMAKE_Swift_COMPILER "") + return() +endif() + +if(NOT DEFINED CMAKE_Swift_COMPILER) + set(_desc "Looking for a Swift compiler") + message(STATUS ${_desc}) + + file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckSwift) + + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckSwift/CMakeLists.txt" + "cmake_minimum_required(VERSION 3.14) +project(CheckSwift Swift) +file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\" + \"set(CMAKE_Swift_COMPILER \\\"\${CMAKE_Swift_COMPILER}\\\")\\n\" + \"set(CMAKE_Swift_FLAGS \\\"\${CMAKE_Swift_FLAGS}\\\")\\n\") +") + + if(CMAKE_GENERATOR_INSTANCE) + set(_D_CMAKE_GENERATOR_INSTANCE "-DCMAKE_GENERATOR_INSTANCE:INTERNAL=${CMAKE_GENERATOR_INSTANCE}") + else() + set(_D_CMAKE_GENERATOR_INSTANCE "") + endif() + + execute_process(WORKING_DIRECTORY + ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckSwift + COMMAND + ${CMAKE_COMMAND} . -G ${CMAKE_GENERATOR} + -A "${CMAKE_GENERATOR_PLATFORM}" + -T "${CMAKE_GENERATOR_TOOLSET}" + ${_D_CMAKE_GENERATOR_INSTANCE} + TIMEOUT + 60 + OUTPUT_VARIABLE + output + ERROR_VARIABLE + output + RESULT_VARIABLE + result) + + include(${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckSwift/result.cmake + OPTIONAL) + if(CMAKE_Swift_COMPILER AND "${result}" STREQUAL "0") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "${_desc} passed with the following output:\n" + "${output}\n") + else() + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "${_desc} failed with the following output:\n" + "${output}\n") + endif() + + message(STATUS "${_desc} - ${CMAKE_Swift_COMPILER}") + + set(CMAKE_Swift_COMPILER "${CMAKE_Swift_COMPILER}" CACHE FILEPATH "Swift compiler") + set(CMAKE_Swift_FLAGS "${CMAKE_Swift_FLAGS}" CACHE STRING "Swift flags") + + mark_as_advanced(CMAKE_Swift_COMPILER) + mark_as_advanced(CMAKE_Swift_FLAGS) +endif() diff --git a/Tests/CompileOptions/CMakeLists.txt b/Tests/CompileOptions/CMakeLists.txt index 2aa4458..1433462 100644 --- a/Tests/CompileOptions/CMakeLists.txt +++ b/Tests/CompileOptions/CMakeLists.txt @@ -25,6 +25,7 @@ set_property(TARGET CompileOptions PROPERTY COMPILE_OPTIONS "-DTEST_DEFINE" "-DNEEDS_ESCAPE=\"E$CAPE\"" "$<$<CXX_COMPILER_ID:GNU>:-DTEST_DEFINE_GNU>" + "$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-DTEST_DEFINE_CXX_AND_GNU>" "SHELL:" # produces no options ${c_tests} ${cxx_tests} diff --git a/Tests/CompileOptions/main.cpp b/Tests/CompileOptions/main.cpp index d94a169..ebc1017 100644 --- a/Tests/CompileOptions/main.cpp +++ b/Tests/CompileOptions/main.cpp @@ -10,6 +10,9 @@ # ifndef TEST_DEFINE_GNU # error Expected definition TEST_DEFINE_GNU # endif +# ifndef TEST_DEFINE_CXX_AND_GNU +# error Expected definition TEST_DEFINE_CXX_AND_GNU +# endif #endif #ifndef NO_DEF_TESTS diff --git a/Tests/EnforceConfig.cmake.in b/Tests/EnforceConfig.cmake.in index b8a6860..b7587aa 100644 --- a/Tests/EnforceConfig.cmake.in +++ b/Tests/EnforceConfig.cmake.in @@ -28,4 +28,10 @@ if(NOT CTEST_CONFIGURATION_TYPE) message("Guessing configuration ${CTEST_CONFIGURATION_TYPE}") endif() +# Isolate tests from user configuration in the environment. +unset(ENV{CMAKE_GENERATOR}) +unset(ENV{CMAKE_GENERATOR_INSTANCE}) +unset(ENV{CMAKE_GENERATOR_PLATFORM}) +unset(ENV{CMAKE_GENERATOR_TOOLSET}) + @TEST_HOME_ENV_CODE@ diff --git a/Tests/ExportImport/Export/Interface/CMakeLists.txt b/Tests/ExportImport/Export/Interface/CMakeLists.txt index fd55c42..22a4ef6 100644 --- a/Tests/ExportImport/Export/Interface/CMakeLists.txt +++ b/Tests/ExportImport/Export/Interface/CMakeLists.txt @@ -41,6 +41,8 @@ install(FILES add_library(cmakeonly INTERFACE) set_property(TARGET cmakeonly PROPERTY INTERFACE_COMPILE_DEFINITIONS [[DEF="\"\$\B"]]) +set_property(TARGET cmakeonly PROPERTY custom_property CustomPropertyValue) +set_property(TARGET cmakeonly PROPERTY EXPORT_PROPERTIES custom_property) install(TARGETS headeronly sharediface use_auto_type use_c_restrict source_target cmakeonly diff --git a/Tests/ExportImport/Import/Interface/CMakeLists.txt b/Tests/ExportImport/Import/Interface/CMakeLists.txt index c850508..a07a5b3 100644 --- a/Tests/ExportImport/Import/Interface/CMakeLists.txt +++ b/Tests/ExportImport/Import/Interface/CMakeLists.txt @@ -109,4 +109,12 @@ foreach(ns exp bld) "not\n" " " [[DEF="\"\$\B"]] "\n") endif() + get_property(custom TARGET ${ns}::cmakeonly PROPERTY custom_property) + if(NOT custom STREQUAL "CustomPropertyValue") + message(SEND_ERROR + "${ns}::cmakeonly property custom_property is:\n" + " ${custom}\n" + "not\n" + " CustomPropertyValue\n") + endif() endforeach() diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index 6c876a7..8802b73 100644 --- a/Tests/FindPackageTest/CMakeLists.txt +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -541,7 +541,41 @@ endif() set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE) unset(SortLib_VERSION) - unset(CMAKE_FIND_PACKAGE_SORT_ORDER) unset(CMAKE_FIND_PACKAGE_SORT_DIRECTION) set(CMAKE_PREFIX_PATH ) + +############################################################################ +##Test FIND_PACKAGE CMAKE_FIND_PACKAGE_PREFER_CONFIG + +set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/PreferConfig) +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/PreferConfig) + +# prefer module mode +set(CMAKE_FIND_PACKAGE_PREFER_CONFIG OFF) +unset(ABC_FOUND) +unset(ABC_CONFIG) + +find_package(ABC) +if(NOT ABC_FOUND) + message(SEND_ERROR "Did not find ABC package") +endif() +if(ABC_CONFIG) + message(SEND_ERROR "Incorrectly found ABC in CONFIG mode, expected to find it with MODULE mode") +endif() + +# Now prefer config mode +set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) +unset(ABC_FOUND) +unset(ABC_CONFIG) + +find_package(ABC) +if(NOT ABC_FOUND) + message(SEND_ERROR "Did not find ABC package") +endif() +if(NOT ABC_CONFIG) + message(SEND_ERROR "Incorrectly found ABC in MODULE mode, expected to find it with CONFIG mode") +endif() + +set(CMAKE_FIND_PACKAGE_PREFER_CONFIG OFF) +set(CMAKE_PREFIX_PATH) diff --git a/Tests/FindPackageTest/PreferConfig/ABCConfig.cmake b/Tests/FindPackageTest/PreferConfig/ABCConfig.cmake new file mode 100644 index 0000000..281a5cd --- /dev/null +++ b/Tests/FindPackageTest/PreferConfig/ABCConfig.cmake @@ -0,0 +1 @@ +set(ABC_FOUND TRUE) diff --git a/Tests/FindPackageTest/PreferConfig/FindABC.cmake b/Tests/FindPackageTest/PreferConfig/FindABC.cmake new file mode 100644 index 0000000..281a5cd --- /dev/null +++ b/Tests/FindPackageTest/PreferConfig/FindABC.cmake @@ -0,0 +1 @@ +set(ABC_FOUND TRUE) diff --git a/Tests/FindPython/CMakeLists.txt b/Tests/FindPython/CMakeLists.txt index 8dfcf40..4be2f22 100644 --- a/Tests/FindPython/CMakeLists.txt +++ b/Tests/FindPython/CMakeLists.txt @@ -1,12 +1,22 @@ if(CMake_TEST_FindPython) - add_test(NAME FindPython.Python2 COMMAND + add_test(NAME FindPython.Python2.LOCATION COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test "${CMake_SOURCE_DIR}/Tests/FindPython/Python2" - "${CMake_BINARY_DIR}/Tests/FindPython/Python2" + "${CMake_BINARY_DIR}/Tests/FindPython/Python2.LOCATION" ${build_generator_args} --build-project TestPython2 - --build-options ${build_options} + --build-options ${build_options} -DPython2_FIND_STRATEGY=LOCATION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.Python2.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python2" + "${CMake_BINARY_DIR}/Tests/FindPython/Python2.VERSION" + ${build_generator_args} + --build-project TestPython2 + --build-options ${build_options} -DPython2_FIND_STRATEGY=VERSION --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) @@ -23,14 +33,24 @@ if(CMake_TEST_FindPython) set_tests_properties(FindPython.Python2Fail PROPERTIES PASS_REGULAR_EXPRESSION "Could NOT find Python2 \\(missing: foobar\\)") - add_test(NAME FindPython.Python3 COMMAND + add_test(NAME FindPython.Python3.LOCATION COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --build-and-test "${CMake_SOURCE_DIR}/Tests/FindPython/Python3" - "${CMake_BINARY_DIR}/Tests/FindPython/Python3" + "${CMake_BINARY_DIR}/Tests/FindPython/Python3.LOCATION" ${build_generator_args} --build-project TestPython3 - --build-options ${build_options} + --build-options ${build_options} -DPython3_FIND_STRATEGY=LOCATION + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + add_test(NAME FindPython.Python3.VERSION COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/Python3" + "${CMake_BINARY_DIR}/Tests/FindPython/Python3.VERSION" + ${build_generator_args} + --build-project TestPython3 + --build-options ${build_options} -DPython3_FIND_STRATEGY=VERSION --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) diff --git a/Tests/MakeClean/ToClean/CMakeLists.txt b/Tests/MakeClean/ToClean/CMakeLists.txt index 5d84e6c..6f16d12 100644 --- a/Tests/MakeClean/ToClean/CMakeLists.txt +++ b/Tests/MakeClean/ToClean/CMakeLists.txt @@ -2,45 +2,56 @@ cmake_minimum_required(VERSION 3.14) project(ToClean) # Utility variables -set(TSD ${ToClean_SOURCE_DIR}) -set(TBD ${ToClean_BINARY_DIR}) +set(CSD ${CMAKE_CURRENT_SOURCE_DIR}) +set(CBD ${CMAKE_CURRENT_BINARY_DIR}) set(CLEAN_FILE_CONTENT "File registered for cleaning.\n") # Lists build-time-generated files that should be cleaned away -set(TOCLEAN_FILES) +set_property(GLOBAL PROPERTY TOCLEAN_FILES "") +function(addCleanFile FILENAME) + set_property(GLOBAL APPEND PROPERTY TOCLEAN_FILES "${FILENAME}") +endfunction() +function(writeCleanFile FILENAME) + file(WRITE "${FILENAME}" ${CLEAN_FILE_CONTENT}) +endfunction() # Build a simple project whose compiled objects should be cleaned. add_executable(toclean toclean.cxx) -list(APPEND TOCLEAN_FILES - "${TBD}${CMAKE_FILES_DIRECTORY}/toclean.dir/toclean.cxx${CMAKE_CXX_OUTPUT_EXTENSION}") +addCleanFile("${CBD}${CMAKE_FILES_DIRECTORY}/toclean.dir/toclean.cxx${CMAKE_CXX_OUTPUT_EXTENSION}") + +# Create a post build custom command that copies the toclean output executable +# to a custom location +function(addToCleanPostBuildCopy FILENAME) + add_custom_command(TARGET toclean POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy $<TARGET_FILE:toclean> ${FILENAME}) +endfunction() # Create a custom command whose output should be cleaned. -set(CustomCommandFile "${TBD}/CustomCommandFile.txt") +set(CustomCommandFile "${CBD}/CustomCommandFile.txt") add_custom_command(OUTPUT ${CustomCommandFile} - DEPENDS ${TSD}/toclean.cxx + DEPENDS ${CSD}/toclean.cxx COMMAND ${CMAKE_COMMAND} - ARGS -E copy ${TSD}/toclean.cxx ${CustomCommandFile}) + ARGS -E copy ${CSD}/toclean.cxx ${CustomCommandFile}) add_custom_target(generate ALL DEPENDS ${CustomCommandFile}) -list(APPEND TOCLEAN_FILES ${CustomCommandFile}) +addCleanFile(${CustomCommandFile}) ### Tests ADDITIONAL_MAKE_CLEAN_FILES directory property if("${CMAKE_GENERATOR}" MATCHES "Makefile") # Create a file that must be registered for cleaning. - set(MakeDirPropFile "${TBD}/MakeDirPropFile.txt") - file(WRITE "${MakeDirPropFile}" ${CLEAN_FILE_CONTENT}) + set(MakeDirPropFile "${CBD}/MakeDirPropFile.txt") + writeCleanFile("${MakeDirPropFile}") set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${MakeDirPropFile}") - list(APPEND TOCLEAN_FILES "${MakeDirPropFile}") + addCleanFile(${MakeDirPropFile}) # Create a custom command whose output should be cleaned, but whose name # is not known until generate-time set(MakeDirPropExpFileRel "MakeDirProp_copy${CMAKE_EXECUTABLE_SUFFIX}") set(MakeDirPropExpFile "$<TARGET_FILE_DIR:toclean>/${MakeDirPropExpFileRel}") - add_custom_command(TARGET toclean POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy $<TARGET_FILE:toclean> ${MakeDirPropExpFile}) + addToCleanPostBuildCopy("${MakeDirPropExpFile}") set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${MakeDirPropExpFile}) - list(APPEND TOCLEAN_FILES "${TBD}/${MakeDirPropExpFileRel}") + addCleanFile("${CBD}/${MakeDirPropExpFileRel}") endif() @@ -48,51 +59,52 @@ endif() # Register a file path relative to the build directory set(DirPropFileRel "DirPropFileRel.txt") -file(WRITE "${TBD}/${DirPropFileRel}" ${CLEAN_FILE_CONTENT}) +writeCleanFile("${CBD}/${DirPropFileRel}") set_directory_properties(PROPERTIES ADDITIONAL_CLEAN_FILES ${DirPropFileRel}) -list(APPEND TOCLEAN_FILES "${TBD}/${DirPropFileRel}") +addCleanFile("${CBD}/${DirPropFileRel}") # Register an absolute file path -set(DirPropFileAbs "${TBD}/DirPropFileAbs.txt") -file(WRITE "${DirPropFileAbs}" ${CLEAN_FILE_CONTENT}) +set(DirPropFileAbs "${CBD}/DirPropFileAbs.txt") +writeCleanFile("${DirPropFileAbs}") set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${DirPropFileAbs}) -list(APPEND TOCLEAN_FILES "${DirPropFileAbs}") +addCleanFile("${DirPropFileAbs}") # Create a custom command whose output should be cleaned, but whose name # is not known until generate-time set(DirPropExpFileRel "DirProp_copy${CMAKE_EXECUTABLE_SUFFIX}") set(DirPropExpFile "$<TARGET_FILE_DIR:toclean>/${DirPropExpFileRel}") -add_custom_command(TARGET toclean POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy $<TARGET_FILE:toclean> ${DirPropExpFile}) +addToCleanPostBuildCopy("${DirPropExpFile}") set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${DirPropExpFile}) -list(APPEND TOCLEAN_FILES "${TBD}/${DirPropExpFileRel}") +addCleanFile("${CBD}/${DirPropExpFileRel}") ### Tests ADDITIONAL_CLEAN_FILES target property # Register a file path relative to the build directory set(TgtPropFileRel "TargetPropFileRel.txt") -file(WRITE "${TBD}/${TgtPropFileRel}" ${CLEAN_FILE_CONTENT}) +writeCleanFile("${CBD}/${TgtPropFileRel}") set_target_properties(toclean PROPERTIES ADDITIONAL_CLEAN_FILES ${TgtPropFileRel}) -list(APPEND TOCLEAN_FILES "${TBD}/${TgtPropFileRel}") +addCleanFile("${CBD}/${TgtPropFileRel}") # Register an absolute file path -set(TgtPropFileAbs "${TBD}/TargetPropFileAbs.txt") -file(WRITE "${TgtPropFileAbs}" ${CLEAN_FILE_CONTENT}) +set(TgtPropFileAbs "${CBD}/TargetPropFileAbs.txt") +writeCleanFile("${TgtPropFileAbs}") set_property(TARGET toclean APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${TgtPropFileAbs}) -list(APPEND TOCLEAN_FILES "${TgtPropFileAbs}") +addCleanFile("${TgtPropFileAbs}") # Create a custom command whose output should be cleaned, but whose name # is not known until generate-time set(TgtPropExpFileRel "TgtProp_copy${CMAKE_EXECUTABLE_SUFFIX}") set(TgtPropExpFile "$<TARGET_FILE_DIR:toclean>/${TgtPropExpFileRel}") -add_custom_command(TARGET toclean POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy $<TARGET_FILE:toclean> ${TgtPropExpFile}) +addToCleanPostBuildCopy("${TgtPropExpFile}") set_property(TARGET toclean APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${TgtPropExpFile}) -list(APPEND TOCLEAN_FILES "${TBD}/${TgtPropExpFileRel}") +addCleanFile("${CBD}/${TgtPropExpFileRel}") + + +# Process subdirectory without targets +add_subdirectory(EmptySubDir) # Configure a file listing these build-time-generated files. -configure_file(${TSD}/ToCleanFiles.cmake.in ${TBD}/ToCleanFiles.cmake @ONLY) +get_property(TOCLEAN_FILES GLOBAL PROPERTY TOCLEAN_FILES) +configure_file(${CSD}/ToCleanFiles.cmake.in ${CBD}/ToCleanFiles.cmake @ONLY) diff --git a/Tests/MakeClean/ToClean/EmptySubDir/CMakeLists.txt b/Tests/MakeClean/ToClean/EmptySubDir/CMakeLists.txt new file mode 100644 index 0000000..55893ae --- /dev/null +++ b/Tests/MakeClean/ToClean/EmptySubDir/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.14) + +# Subdirectory CMakeLists.txt without targets +set(CSD ${CMAKE_CURRENT_SOURCE_DIR}) +set(CBD ${CMAKE_CURRENT_BINARY_DIR}) + +# Register a file path relative to the build directory +set(DirPropFileRel "DirPropFileRel.txt") +writeCleanFile("${CBD}/${DirPropFileRel}") +set_directory_properties(PROPERTIES ADDITIONAL_CLEAN_FILES ${DirPropFileRel}) +addCleanFile("${CBD}/${DirPropFileRel}") + +# Register an absolute file path +set(DirPropFileAbs "${CBD}/DirPropFileAbs.txt") +writeCleanFile("${DirPropFileAbs}") +set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${DirPropFileAbs}) +addCleanFile("${DirPropFileAbs}") diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 2b78171..0ccfca8 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -205,7 +205,7 @@ if(UNIX AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG AND CMAKE_EXECUTABLE_FORMAT STRE add_RunCMake_test(RuntimePath) endif() add_RunCMake_test(ScriptMode) -add_RunCMake_test(Swift) +add_RunCMake_test(Swift -DCMAKE_Swift_COMPILER=${CMAKE_Swift_COMPILER}) add_RunCMake_test(TargetObjects) add_RunCMake_test(TargetSources) add_RunCMake_test(ToolchainFile) @@ -360,7 +360,10 @@ if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") endif() if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([^9]|9[0-9])") - add_RunCMake_test(VS10Project) + add_RunCMake_test(VS10Project + -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} + -DCMAKE_C_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION} + ) if( vs12 AND wince ) add_RunCMake_test( VS10ProjectWinCE "-DRunCMake_GENERATOR_PLATFORM=${wince_sdk}") endif() diff --git a/Tests/RunCMake/CommandLine/EnvGenerator/CMakeLists.txt b/Tests/RunCMake/CommandLine/EnvGenerator/CMakeLists.txt new file mode 100644 index 0000000..2b8c65c --- /dev/null +++ b/Tests/RunCMake/CommandLine/EnvGenerator/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.14) +project(EnvGenerator C) +if(CMAKE_GENERATOR MATCHES "Visual Studio") + message(STATUS "CMAKE_VS_PLATFORM_NAME='${CMAKE_VS_PLATFORM_NAME}'") +endif() +add_custom_command( + OUTPUT output.txt + COMMAND ${CMAKE_COMMAND} -E echo CustomCommand > output.txt + ) +add_custom_target(CustomTarget ALL DEPENDS output.txt) diff --git a/Tests/RunCMake/CommandLine/Envgen-A-platform-result.txt b/Tests/RunCMake/CommandLine/Envgen-A-platform-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-A-platform-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/Envgen-A-platform-stderr-vs9.txt b/Tests/RunCMake/CommandLine/Envgen-A-platform-stderr-vs9.txt new file mode 100644 index 0000000..4eae6aa --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-A-platform-stderr-vs9.txt @@ -0,0 +1,2 @@ +^CMake Error at CMakeLists.+ + No CMAKE_C_COMPILER could be found. diff --git a/Tests/RunCMake/CommandLine/Envgen-A-platform-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-A-platform-stderr.txt new file mode 100644 index 0000000..09c2d2b --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-A-platform-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error at CMakeLists.+ +.+Platform='fromcli'.+ diff --git a/Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt b/Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt new file mode 100644 index 0000000..4dd6be1 --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt @@ -0,0 +1 @@ +-- CMAKE_VS_PLATFORM_NAME='(x64|Win32)' diff --git a/Tests/RunCMake/CommandLine/Envgen-T-toolset-result.txt b/Tests/RunCMake/CommandLine/Envgen-T-toolset-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-T-toolset-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/Envgen-T-toolset-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-T-toolset-stderr.txt new file mode 100644 index 0000000..b432c19 --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-T-toolset-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error at CMakeLists.+ +.+(Platform Toolset = 'fromcli'|Specified platform toolset \(fromcli\) is not installed or invalid).+ diff --git a/Tests/RunCMake/CommandLine/Envgen-bad-result.txt b/Tests/RunCMake/CommandLine/Envgen-bad-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-bad-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/Envgen-bad-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-bad-stderr.txt new file mode 100644 index 0000000..4a1215e --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-bad-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error: No generator specified for -G +CMake Error: CMAKE_GENERATOR was set but the specified generator doesn't exist. Using CMake default. + +Generators.* +\* (Unix Makefiles|Visual Studio).* diff --git a/Tests/RunCMake/CommandLine/Envgen-instance-invalid-result.txt b/Tests/RunCMake/CommandLine/Envgen-instance-invalid-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-instance-invalid-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/Envgen-instance-invalid-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-instance-invalid-stderr.txt new file mode 100644 index 0000000..d53daa5 --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-instance-invalid-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error at CMakeLists.+ + could not find specified instance of Visual Studio.+ diff --git a/Tests/RunCMake/CommandLine/Envgen-ninja-result.txt b/Tests/RunCMake/CommandLine/Envgen-ninja-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-ninja-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/Envgen-ninja-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-ninja-stderr.txt new file mode 100644 index 0000000..0d455db --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-ninja-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error: No generator specified for -G + +Generators.* +\* Ninja.* diff --git a/Tests/RunCMake/CommandLine/Envgen-platform-invalid-result.txt b/Tests/RunCMake/CommandLine/Envgen-platform-invalid-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-platform-invalid-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr-vs9.txt b/Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr-vs9.txt new file mode 100644 index 0000000..4eae6aa --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr-vs9.txt @@ -0,0 +1,2 @@ +^CMake Error at CMakeLists.+ + No CMAKE_C_COMPILER could be found. diff --git a/Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr.txt new file mode 100644 index 0000000..76a8f1c --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error at CMakeLists.+ +.+Platform='invalid'.+ diff --git a/Tests/RunCMake/CommandLine/Envgen-toolset-invalid-result.txt b/Tests/RunCMake/CommandLine/Envgen-toolset-invalid-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-toolset-invalid-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/Envgen-toolset-invalid-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-toolset-invalid-stderr.txt new file mode 100644 index 0000000..51fce60 --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-toolset-invalid-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error at CMakeLists.+ +.+(Platform Toolset = 'invalid'|Specified platform toolset \(invalid\) is not installed or invalid).+ diff --git a/Tests/RunCMake/CommandLine/Envgen-unset-result.txt b/Tests/RunCMake/CommandLine/Envgen-unset-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-unset-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/Envgen-unset-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-unset-stderr.txt new file mode 100644 index 0000000..ec6ec92 --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-unset-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error: No generator specified for -G + +Generators.* +\* (Unix Makefiles|Visual Studio).* diff --git a/Tests/RunCMake/CommandLine/Envgen-warnings-result.txt b/Tests/RunCMake/CommandLine/Envgen-warnings-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-warnings-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/Envgen-warnings-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-warnings-stderr.txt new file mode 100644 index 0000000..47f9c9e --- /dev/null +++ b/Tests/RunCMake/CommandLine/Envgen-warnings-stderr.txt @@ -0,0 +1,7 @@ +^Warning: Environment variable CMAKE_GENERATOR_INSTANCE will be ignored, because CMAKE_GENERATOR is not set. +Warning: Environment variable CMAKE_GENERATOR_PLATFORM will be ignored, because CMAKE_GENERATOR is not set. +Warning: Environment variable CMAKE_GENERATOR_TOOLSET will be ignored, because CMAKE_GENERATOR is not set. +CMake Error: No generator specified for -G + +Generators.* +\* (Unix Makefiles|Visual Studio).* diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index b9aa536..cee996c 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -172,6 +172,74 @@ function(run_BuildDir) endfunction() run_BuildDir() +function(run_EnvironmentGenerator) + set(source_dir ${RunCMake_SOURCE_DIR}/EnvGenerator) + + set(ENV{CMAKE_GENERATOR_INSTANCE} "instance") + set(ENV{CMAKE_GENERATOR_PLATFORM} "platform") + set(ENV{CMAKE_GENERATOR_TOOLSET} "toolset") + run_cmake_command(Envgen-warnings ${CMAKE_COMMAND} -G) + unset(ENV{CMAKE_GENERATOR_INSTANCE}) + unset(ENV{CMAKE_GENERATOR_PLATFORM}) + unset(ENV{CMAKE_GENERATOR_TOOLSET}) + + # Test CMAKE_GENERATOR without actual configuring + run_cmake_command(Envgen-unset ${CMAKE_COMMAND} -G) + set(ENV{CMAKE_GENERATOR} "Ninja") + run_cmake_command(Envgen-ninja ${CMAKE_COMMAND} -G) + set(ENV{CMAKE_GENERATOR} "NoSuchGenerator") + run_cmake_command(Envgen-bad ${CMAKE_COMMAND} -G) + unset(ENV{CMAKE_GENERATOR}) + + if(RunCMake_GENERATOR MATCHES "Visual Studio.*") + set(ENV{CMAKE_GENERATOR} "${RunCMake_GENERATOR}") + run_cmake_command(Envgen ${CMAKE_COMMAND} ${source_dir}) + # Toolset is available since VS 2010. + if(RunCMake_GENERATOR MATCHES "Visual Studio [1-9][0-9]") + set(ENV{CMAKE_GENERATOR_TOOLSET} "invalid") + # Envvar shouldn't affect existing build tree + run_cmake_command(Envgen-toolset-existing ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build Envgen-build) + run_cmake_command(Envgen-toolset-invalid ${CMAKE_COMMAND} ${source_dir}) + # Command line -G implies -T"" + run_cmake_command(Envgen-G-implicit-toolset ${CMAKE_COMMAND} -G "${RunCMake_GENERATOR}" ${source_dir}) + run_cmake_command(Envgen-T-toolset ${CMAKE_COMMAND} -T "fromcli" ${source_dir}) + unset(ENV{CMAKE_GENERATOR_TOOLSET}) + endif() + # Platform can be set only if not in generator name. + if(RunCMake_GENERATOR MATCHES "^Visual Studio [0-9]+ [0-9]+$") + set(ENV{CMAKE_GENERATOR_PLATFORM} "invalid") + # Envvar shouldn't affect existing build tree + run_cmake_command(Envgen-platform-existing ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build Envgen-build) + if(RunCMake_GENERATOR MATCHES "^Visual Studio 9 ") + set(RunCMake-stderr-file "Envgen-platform-invalid-stderr-vs9.txt") + endif() + run_cmake_command(Envgen-platform-invalid ${CMAKE_COMMAND} ${source_dir}) + unset(RunCMake-stderr-file) + # Command line -G implies -A"" + run_cmake_command(Envgen-G-implicit-platform ${CMAKE_COMMAND} -G "${RunCMake_GENERATOR}" ${source_dir}) + if(RunCMake_GENERATOR MATCHES "^Visual Studio 9 ") + set(RunCMake-stderr-file "Envgen-A-platform-stderr-vs9.txt") + endif() + run_cmake_command(Envgen-A-platform ${CMAKE_COMMAND} -A "fromcli" ${source_dir}) + unset(RunCMake-stderr-file) + unset(ENV{CMAKE_GENERATOR_PLATFORM}) + endif() + # Instance is available since VS 2017. + if(RunCMake_GENERATOR MATCHES "Visual Studio (15|16).*") + set(ENV{CMAKE_GENERATOR_INSTANCE} "invalid") + # Envvar shouldn't affect existing build tree + run_cmake_command(Envgen-instance-existing ${CMAKE_COMMAND} -E chdir .. + ${CMAKE_COMMAND} --build Envgen-build) + run_cmake_command(Envgen-instance-invalid ${CMAKE_COMMAND} ${source_dir}) + unset(ENV{CMAKE_GENERATOR_INSTANCE}) + endif() + unset(ENV{CMAKE_GENERATOR}) + endif() +endfunction() +run_EnvironmentGenerator() + if(RunCMake_GENERATOR STREQUAL "Ninja") # Use a single build tree for a few tests without cleaning. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Build-build) diff --git a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake index 5deb110..4d1b396 100644 --- a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake @@ -30,3 +30,6 @@ run_cmake(pax-xz) run_cmake(paxr) run_cmake(paxr-bz2) run_cmake(zip) + +# Extracting only selected files or directories +run_cmake(zip-filtered) diff --git a/Tests/RunCMake/CommandLineTar/roundtrip.cmake b/Tests/RunCMake/CommandLineTar/roundtrip.cmake index dc1c885..fa63d12 100644 --- a/Tests/RunCMake/CommandLineTar/roundtrip.cmake +++ b/Tests/RunCMake/CommandLineTar/roundtrip.cmake @@ -47,7 +47,11 @@ file(REMOVE_RECURSE ${FULL_DECOMPRESS_DIR}) file(MAKE_DIRECTORY ${FULL_DECOMPRESS_DIR}) run_tar(${CMAKE_CURRENT_BINARY_DIR} ${COMPRESSION_FLAGS} ${FULL_OUTPUT_NAME} ${COMPRESSION_OPTIONS} ${COMPRESS_DIR}) -run_tar(${FULL_DECOMPRESS_DIR} ${DECOMPRESSION_FLAGS} ${FULL_OUTPUT_NAME} ${DECOMPRESSION_OPTIONS}) +run_tar(${FULL_DECOMPRESS_DIR} ${DECOMPRESSION_FLAGS} ${FULL_OUTPUT_NAME} ${DECOMPRESSION_OPTIONS} -- ${DECOMPRESSION_PATHNAMES}) + +if(CUSTOM_CHECK_FILES) + set(CHECK_FILES ${CUSTOM_CHECK_FILES}) +endif() foreach(file ${CHECK_FILES}) set(input ${FULL_COMPRESS_DIR}/${file}) @@ -69,6 +73,14 @@ foreach(file ${CHECK_FILES}) endif() endforeach() +foreach(file ${NOT_EXISTING_FILES_CHECK}) + set(output ${FULL_DECOMPRESS_DIR}/${COMPRESS_DIR}/${file}) + + if(EXISTS ${output}) + message(SEND_ERROR "File ${output} exists but it shouldn't") + endif() +endforeach() + function(check_magic EXPECTED) file(READ ${FULL_OUTPUT_NAME} ACTUAL ${ARGN} diff --git a/Tests/RunCMake/CommandLineTar/zip-filtered.cmake b/Tests/RunCMake/CommandLineTar/zip-filtered.cmake new file mode 100644 index 0000000..c13210e --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/zip-filtered.cmake @@ -0,0 +1,28 @@ +set(OUTPUT_NAME "test.zip") + +set(COMPRESSION_FLAGS cvf) +set(COMPRESSION_OPTIONS --format=zip) + +set(DECOMPRESSION_FLAGS xvf) +set(LIST_ARCHIVE TRUE) +set(DECOMPRESSION_PATHNAMES + compress_dir/f1.txt # Decompress only file + compress_dir/d1 # and whole directory +) + +set(CUSTOM_CHECK_FILES + "f1.txt" + "d1/f1.txt" +) + +# This files shouldn't exists +set(NOT_EXISTING_FILES_CHECK + "d 2/f1.txt" + "d + 3/f1.txt" + "d_4/f1.txt" + "d-4/f1.txt" +) + +include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake) + +check_magic("504b0304" LIMIT 4 HEX) diff --git a/Tests/RunCMake/Framework/FrameworkLayout.cmake b/Tests/RunCMake/Framework/FrameworkLayout.cmake index 4f42459..84012aa 100644 --- a/Tests/RunCMake/Framework/FrameworkLayout.cmake +++ b/Tests/RunCMake/Framework/FrameworkLayout.cmake @@ -11,8 +11,11 @@ add_library(Framework ${FRAMEWORK_TYPE} flatresource.txt deepresource.txt some.txt) +if("${CMAKE_FRAMEWORK}" STREQUAL "") + set_target_properties(Framework PROPERTIES + FRAMEWORK TRUE) +endif() set_target_properties(Framework PROPERTIES - FRAMEWORK TRUE PUBLIC_HEADER foo.h RESOURCE "res.txt") set_source_files_properties(flatresource.txt PROPERTIES MACOSX_PACKAGE_LOCATION Resources) diff --git a/Tests/RunCMake/Framework/RunCMakeTest.cmake b/Tests/RunCMake/Framework/RunCMakeTest.cmake index e705a31..c7e1319 100644 --- a/Tests/RunCMake/Framework/RunCMakeTest.cmake +++ b/Tests/RunCMake/Framework/RunCMakeTest.cmake @@ -20,11 +20,14 @@ framework_layout_test(iOSFrameworkLayout-build ios STATIC) framework_layout_test(OSXFrameworkLayout-build osx SHARED) framework_layout_test(OSXFrameworkLayout-build osx STATIC) -function(framework_type_test Toolchain Type) +function(framework_type_test Toolchain Type UseProperty) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${Toolchain}${Type}FrameworkType-build) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/${Toolchain}.cmake") list(APPEND RunCMake_TEST_OPTIONS "-DFRAMEWORK_TYPE=${Type}") + if(NOT ${UseProperty}) + list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_FRAMEWORK=YES") + endif() file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") @@ -33,7 +36,12 @@ function(framework_type_test Toolchain Type) run_cmake_command(FrameworkType${Type}-build ${CMAKE_COMMAND} --build .) endfunction() -framework_type_test(ios SHARED) -framework_type_test(ios STATIC) -framework_type_test(osx SHARED) -framework_type_test(osx STATIC) +framework_type_test(ios SHARED NO) +framework_type_test(ios STATIC NO) +framework_type_test(osx SHARED NO) +framework_type_test(osx STATIC NO) + +framework_type_test(ios SHARED YES) +framework_type_test(ios STATIC YES) +framework_type_test(osx SHARED YES) +framework_type_test(osx STATIC YES) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command-result.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command-stderr.txt new file mode 100644 index 0000000..fc3c3de --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at COMPILE_LANG_AND_ID-add_custom_command.cmake:2 \(add_custom_command\): + Error evaluating generator expression: + + \$<COMPILE_LANG_AND_ID> + + \$<COMPILE_LANG_AND_ID> expression requires 2 comma separated parameters, + but got 0 instead. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command.cmake new file mode 100644 index 0000000..9bd5e8e --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command.cmake @@ -0,0 +1,4 @@ +add_custom_target(drive) +add_custom_command(TARGET drive PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E echo $<COMPILE_LANG_AND_ID> +) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target-result.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target-stderr.txt new file mode 100644 index 0000000..589e64b --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at COMPILE_LANG_AND_ID-add_custom_target.cmake:2 \(add_custom_target\): + Error evaluating generator expression: + + \$<COMPILE_LANG_AND_ID:LANG,ID> + + \$<COMPILE_LANG_AND_ID:lang,id> may only be used with binary targets to + specify include directories, compile definitions, and compile options. It + may not be used with the add_custom_command, add_custom_target, or + file\(GENERATE\) commands. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target.cmake new file mode 100644 index 0000000..398db19 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target.cmake @@ -0,0 +1,4 @@ + +add_custom_target(drive + COMMAND ${CMAKE_COMMAND} -E echo $<COMPILE_LANG_AND_ID:LANG,ID> +) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable-result.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable-stderr.txt new file mode 100644 index 0000000..3b3f38d --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at COMPILE_LANG_AND_ID-add_executable.cmake:1 \(add_executable\): + Error evaluating generator expression: + + \$<COMPILE_LANG_AND_ID:C,MSVC> + + \$<COMPILE_LANG_AND_ID:lang,id> may only be used with binary targets to + specify include directories, compile definitions, and compile options. It + may not be used with the add_custom_command, add_custom_target, or + file\(GENERATE\) commands. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable.cmake new file mode 100644 index 0000000..2245f50 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable.cmake @@ -0,0 +1,5 @@ +add_executable(empty main.c + $<$<COMPILE_LANG_AND_ID:C,MSVC>:empty.c> + $<$<COMPILE_LANG_AND_ID:C,GNU>:empty2.c> + $<$<COMPILE_LANG_AND_ID:C,Clang>:empty3.c> + ) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library-result.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library-stderr.txt new file mode 100644 index 0000000..4cbf000 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at COMPILE_LANG_AND_ID-add_library.cmake:2 \(add_library\): + Error evaluating generator expression: + + \$<COMPILE_LANG_AND_ID:C,MSVC> + + \$<COMPILE_LANG_AND_ID:lang,id> may only be used with binary targets to + specify include directories, compile definitions, and compile options. It + may not be used with the add_custom_command, add_custom_target, or + file\(GENERATE\) commands. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library.cmake new file mode 100644 index 0000000..044962a --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library.cmake @@ -0,0 +1,2 @@ + +add_library(empty empty.$<COMPILE_LANG_AND_ID:C,MSVC>) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test-result.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test-stderr.txt new file mode 100644 index 0000000..26a5940 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at COMPILE_LANG_AND_ID-add_test.cmake:5 \(add_test\): + Error evaluating generator expression: + + \$<COMPILE_LANG_AND_ID:CXX,GNU> + + \$<COMPILE_LANG_AND_ID:lang,id> may only be used with binary targets to + specify include directories, compile definitions, and compile options. It + may not be used with the add_custom_command, add_custom_target, or + file\(GENERATE\) commands. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test.cmake new file mode 100644 index 0000000..b5b6c2b --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test.cmake @@ -0,0 +1,5 @@ + +include(CTest) +enable_testing() + +add_test(NAME dummy COMMAND ${CMAKE_COMMAND} -E echo $<COMPILE_LANG_AND_ID:CXX,GNU>) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install-result.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install-stderr.txt new file mode 100644 index 0000000..0c4ecd0 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install-stderr.txt @@ -0,0 +1,9 @@ +CMake Error: + Error evaluating generator expression: + + \$<COMPILE_LANG_AND_ID:C,MSVC> + + \$<COMPILE_LANG_AND_ID:lang,id> may only be used with binary targets to + specify include directories, compile definitions, and compile options. It + may not be used with the add_custom_command, add_custom_target, or + file\(GENERATE\) commands. diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install.cmake new file mode 100644 index 0000000..c13eda6 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install.cmake @@ -0,0 +1,5 @@ + +install(FILES + empty.$<COMPILE_LANG_AND_ID:C,MSVC> + DESTINATION src +) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources-result.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources-stderr.txt new file mode 100644 index 0000000..44d8684 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at COMPILE_LANG_AND_ID-target_sources.cmake:2 \(target_sources\): + Error evaluating generator expression: + + \$<COMPILE_LANG_AND_ID> + + \$<COMPILE_LANG_AND_ID> expression requires 2 comma separated parameters, + but got 0 instead. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources.cmake new file mode 100644 index 0000000..a2c9b03 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources.cmake @@ -0,0 +1,2 @@ +add_library(empty) +target_sources(empty PRIVATE empty.$<COMPILE_LANG_AND_ID>) diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-unknown-lang.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-unknown-lang.cmake new file mode 100644 index 0000000..b9e840b --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-unknown-lang.cmake @@ -0,0 +1,4 @@ + +enable_language(C) +add_executable(empty empty.c) +target_compile_options(empty PRIVATE $<$<COMPILE_LANG_AND_ID:CXX,GNU>:$<TARGET_EXISTS:too,many,parameters>>) diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index a491e99..68a0172 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -31,6 +31,14 @@ run_cmake(COMPILE_LANGUAGE-add_executable) run_cmake(COMPILE_LANGUAGE-add_library) run_cmake(COMPILE_LANGUAGE-add_test) run_cmake(COMPILE_LANGUAGE-unknown-lang) +run_cmake(COMPILE_LANG_AND_ID-add_custom_target) +run_cmake(COMPILE_LANG_AND_ID-add_custom_command) +run_cmake(COMPILE_LANG_AND_ID-install) +run_cmake(COMPILE_LANG_AND_ID-target_sources) +run_cmake(COMPILE_LANG_AND_ID-add_executable) +run_cmake(COMPILE_LANG_AND_ID-add_library) +run_cmake(COMPILE_LANG_AND_ID-add_test) +run_cmake(COMPILE_LANG_AND_ID-unknown-lang) run_cmake(TARGET_FILE-recursion) run_cmake(OUTPUT_NAME-recursion) run_cmake(TARGET_FILE_PREFIX) @@ -45,6 +53,7 @@ run_cmake_with_options(TARGET_FILE_BASE_NAME -DCMAKE_BUILD_TYPE:STRING=Debug) run_cmake_with_options(TARGET_FILE_BASE_NAME-imported-target -DCMAKE_BUILD_TYPE:STRING=Debug) run_cmake(TARGET_FILE_BASE_NAME-non-valid-target) run_cmake(TARGET_LINKER_FILE_BASE_NAME-non-valid-target) +run_cmake(TARGET_PROPERTY-INCLUDE_DIRECTORIES) run_cmake(TARGET_PROPERTY-LOCATION) run_cmake(TARGET_PROPERTY-SOURCES) run_cmake(LINK_ONLY-not-linking) diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-INCLUDE_DIRECTORIES.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-INCLUDE_DIRECTORIES.cmake new file mode 100644 index 0000000..cb6f4d8 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-INCLUDE_DIRECTORIES.cmake @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.14) +enable_language(C) + +add_library(foo1 STATIC empty.c) +target_include_directories(foo1 PUBLIC include) +target_link_libraries(foo1 PRIVATE foo2 foo3 foo4) + +add_library(foo2 STATIC empty.c) +target_include_directories(foo2 PUBLIC $<TARGET_PROPERTY:foo1,INCLUDE_DIRECTORIES>) + +add_library(foo3 STATIC empty.c) +target_include_directories(foo3 PUBLIC $<TARGET_PROPERTY:foo2,INCLUDE_DIRECTORIES>) + +add_library(foo4 STATIC empty.c) +target_include_directories(foo4 PUBLIC $<TARGET_PROPERTY:foo3,INCLUDE_DIRECTORIES>) + +# Evaluate a genex that looks up INCLUDE_DIRECTORIES on multiple targets. +file(GENERATE OUTPUT out.txt CONTENT "$<TARGET_PROPERTY:foo4,INCLUDE_DIRECTORIES>") diff --git a/Tests/RunCMake/Swift/RunCMakeTest.cmake b/Tests/RunCMake/Swift/RunCMakeTest.cmake index 4864295..de99042 100644 --- a/Tests/RunCMake/Swift/RunCMakeTest.cmake +++ b/Tests/RunCMake/Swift/RunCMakeTest.cmake @@ -4,6 +4,10 @@ if(RunCMake_GENERATOR STREQUAL Xcode) if(XCODE_BELOW_6_1) run_cmake(XcodeTooOld) endif() +elseif(RunCMake_GENERATOR STREQUAL Ninja) + if(CMAKE_Swift_COMPILER) + # Add Ninja-specific Swift tests here. + endif() else() run_cmake(NotSupported) endif() diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index 0ac589d..9a0b7a9 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -1,4 +1,5 @@ include(RunCMake) +cmake_policy(SET CMP0054 NEW) run_cmake(VsCSharpCompilerOpts) run_cmake(ExplicitCMakeLists) @@ -20,3 +21,7 @@ run_cmake(VSCSharpDefines) run_cmake(VsSdkDirectories) run_cmake(VsGlobals) run_cmake(VsProjectImport) + +if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05) + run_cmake(VsJustMyCode) +endif() diff --git a/Tests/RunCMake/VS10Project/VsJustMyCode-check.cmake b/Tests/RunCMake/VS10Project/VsJustMyCode-check.cmake new file mode 100644 index 0000000..7119976 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsJustMyCode-check.cmake @@ -0,0 +1,38 @@ +macro(VsJustMyCode_check tgt jmc_expect) + set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${tgt}.vcxproj") + if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not exist.") + return() + endif() + + set(HAVE_JMC 0) + + file(STRINGS "${vcProjectFile}" lines) + foreach(line IN LISTS lines) + if(line MATCHES "^ *<SupportJustMyCode>([^<>]+)</SupportJustMyCode>") + set(jmc_actual "${CMAKE_MATCH_1}") + if(NOT "${jmc_actual}" STREQUAL "${jmc_expect}") + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj has <SupportJustMyCode> '${jmc_actual}', not '${jmc_expect}'.") + return() + endif() + set(HAVE_JMC 1) + break() + endif() + endforeach() + + if(NOT HAVE_JMC AND NOT "${jmc_expect}" STREQUAL "") + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not have a <SupportJustMyCode> property group.") + return() + endif() +endmacro() + +VsJustMyCode_check(JMC-default-C "") +VsJustMyCode_check(JMC-default-CXX "") +VsJustMyCode_check(JMC-ON-C true) +VsJustMyCode_check(JMC-ON-CXX true) +VsJustMyCode_check(JMC-OFF-C "") +VsJustMyCode_check(JMC-OFF-CXX "") +VsJustMyCode_check(JMC-TGT-ON-C true) +VsJustMyCode_check(JMC-TGT-ON-CXX true) +VsJustMyCode_check(JMC-TGT-OFF-C "") +VsJustMyCode_check(JMC-TGT-OFF-CXX "") diff --git a/Tests/RunCMake/VS10Project/VsJustMyCode.cmake b/Tests/RunCMake/VS10Project/VsJustMyCode.cmake new file mode 100644 index 0000000..b39f30f --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsJustMyCode.cmake @@ -0,0 +1,24 @@ +set(CMAKE_CONFIGURATION_TYPES Debug) +enable_language(C) +enable_language(CXX) + +add_library(JMC-default-C empty.c) +add_library(JMC-default-CXX empty.cxx) + +set(CMAKE_VS_JUST_MY_CODE_DEBUGGING OFF) +add_library(JMC-OFF-C empty.c) +add_library(JMC-OFF-CXX empty.cxx) + +set(CMAKE_VS_JUST_MY_CODE_DEBUGGING ON) +add_library(JMC-ON-C empty.c) +add_library(JMC-ON-CXX empty.cxx) + +set(CMAKE_VS_JUST_MY_CODE_DEBUGGING OFF) +add_library(JMC-TGT-ON-C empty.c) +set_property(TARGET JMC-TGT-ON-C PROPERTY VS_JUST_MY_CODE_DEBUGGING ON) +add_library(JMC-TGT-ON-CXX empty.cxx) +set_property(TARGET JMC-TGT-ON-CXX PROPERTY VS_JUST_MY_CODE_DEBUGGING ON) +add_library(JMC-TGT-OFF-C empty.c) +set_property(TARGET JMC-TGT-OFF-C PROPERTY VS_JUST_MY_CODE_DEBUGGING OFF) +add_library(JMC-TGT-OFF-CXX empty.cxx) +set_property(TARGET JMC-TGT-OFF-CXX PROPERTY VS_JUST_MY_CODE_DEBUGGING OFF) diff --git a/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN.cmake b/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN.cmake new file mode 100644 index 0000000..d8a12eb --- /dev/null +++ b/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN.cmake @@ -0,0 +1,168 @@ +file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/dest1") + +file(TOUCH "${CMAKE_BINARY_DIR}/file1.txt") +file(CREATE_LINK file1.txt "${CMAKE_BINARY_DIR}/file1.txt.sym" SYMBOLIC) +file(TOUCH "${CMAKE_BINARY_DIR}/dest1/file1.txt.sym") + +file(TOUCH "${CMAKE_BINARY_DIR}/file2.txt") +file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/file2") +file(CREATE_LINK ../file2.txt "${CMAKE_BINARY_DIR}/file2/file2.txt.sym" SYMBOLIC) + +file(TOUCH "${CMAKE_BINARY_DIR}/file3.txt") +file(CREATE_LINK "${CMAKE_BINARY_DIR}/file3.txt" "${CMAKE_BINARY_DIR}/file3.txt.sym" SYMBOLIC) + +file(TOUCH "${CMAKE_BINARY_DIR}/file4.txt") +file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/file4") +file(CREATE_LINK "${CMAKE_BINARY_DIR}/file4.txt" "${CMAKE_BINARY_DIR}/file4/file4.txt.sym" SYMBOLIC) + +file(TOUCH "${CMAKE_BINARY_DIR}/file5.txt") + +file(TOUCH "${CMAKE_BINARY_DIR}/file6.txt") +file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/file6/file6") +file(CREATE_LINK file6.txt "${CMAKE_BINARY_DIR}/file6.txt.sym.1" SYMBOLIC) +file(CREATE_LINK ../file6.txt.sym.1 "${CMAKE_BINARY_DIR}/file6/file6.txt.sym.2" SYMBOLIC) +file(CREATE_LINK "${CMAKE_BINARY_DIR}/file6/file6.txt.sym.2" "${CMAKE_BINARY_DIR}/file6/file6/file6.txt.sym.3" SYMBOLIC) +file(CREATE_LINK file6.txt.sym.3 "${CMAKE_BINARY_DIR}/file6/file6/file6.txt.sym.4" SYMBOLIC) + +file(TOUCH "${CMAKE_BINARY_DIR}/file7.txt") +file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/file7") + +file(TOUCH "${CMAKE_BINARY_DIR}/file8.txt") +file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/file8") +file(CREATE_LINK "${CMAKE_BINARY_DIR}/file8/../file8.txt" "${CMAKE_BINARY_DIR}/file8/file8.txt.sym" SYMBOLIC) + +file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/file9") +file(TOUCH "${CMAKE_BINARY_DIR}/file9/file9.txt") +file(CREATE_LINK "${CMAKE_BINARY_DIR}/file9" "${CMAKE_BINARY_DIR}/file9.sym" SYMBOLIC) + +file(TOUCH "${CMAKE_BINARY_DIR}/file10.txt") +file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/file10") +file(CREATE_LINK "." "${CMAKE_BINARY_DIR}/file10/file10" SYMBOLIC) +file(CREATE_LINK "${CMAKE_BINARY_DIR}/file10/file10/../file10.txt" "${CMAKE_BINARY_DIR}/file10/file10.txt.sym" SYMBOLIC) + +file(INSTALL + "${CMAKE_BINARY_DIR}/file1.txt.sym" + DESTINATION "${CMAKE_BINARY_DIR}/dest1" + FOLLOW_SYMLINK_CHAIN + ) + +file(INSTALL + "${CMAKE_BINARY_DIR}/file1.txt.sym" + "${CMAKE_BINARY_DIR}/file2/file2.txt.sym" + "${CMAKE_BINARY_DIR}/file3.txt.sym" + "${CMAKE_BINARY_DIR}/file4/file4.txt.sym" + "${CMAKE_BINARY_DIR}/file5.txt" + "${CMAKE_BINARY_DIR}/file6/file6/file6.txt.sym.4" + "${CMAKE_BINARY_DIR}/file8/file8.txt.sym" + "${CMAKE_BINARY_DIR}/file7/../file7.txt" + "${CMAKE_BINARY_DIR}/file8.txt" + "${CMAKE_BINARY_DIR}/file9.sym/file9.txt" + "${CMAKE_BINARY_DIR}/file10/file10/file10.txt.sym" + DESTINATION "${CMAKE_BINARY_DIR}/dest2" + FOLLOW_SYMLINK_CHAIN + ) + +set(resolved_file1.txt.sym file1.txt) +set(resolved_file10.txt.sym file10.txt) +set(resolved_file2.txt.sym file2.txt) +set(resolved_file3.txt.sym file3.txt) +set(resolved_file4.txt.sym file4.txt) +set(resolved_file6.txt.sym.1 file6.txt) +set(resolved_file6.txt.sym.2 file6.txt.sym.1) +set(resolved_file6.txt.sym.3 file6.txt.sym.2) +set(resolved_file6.txt.sym.4 file6.txt.sym.3) +set(resolved_file8.txt.sym file8.txt) +set(syms) +foreach(f + file1.txt + file1.txt.sym + file10.txt + file10.txt.sym + file2.txt + file2.txt.sym + file3.txt + file3.txt.sym + file4.txt + file4.txt.sym + file5.txt + file6.txt + file6.txt.sym.1 + file6.txt.sym.2 + file6.txt.sym.3 + file6.txt.sym.4 + file7.txt + file8.txt + file8.txt.sym + file9.txt + ) + string(REPLACE "." "\\." r "${f}") + list(APPEND syms "[^;]*/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN-build/dest2/${r}") + set(filename "${CMAKE_BINARY_DIR}/dest2/${f}") + if(DEFINED resolved_${f}) + file(READ_SYMLINK "${filename}" resolved) + if(NOT resolved STREQUAL "${resolved_${f}}") + message(SEND_ERROR "Expected symlink resolution for ${f}: ${resolved_${f}}\nActual resolution: ${resolved}") + endif() + elseif(NOT EXISTS "${filename}" OR IS_SYMLINK "${filename}" OR IS_DIRECTORY "${filename}") + message(SEND_ERROR "${f} should be a regular file") + endif() +endforeach() + +file(GLOB_RECURSE actual_syms LIST_DIRECTORIES true "${CMAKE_BINARY_DIR}/dest2/*") +if(NOT actual_syms MATCHES "^${syms}$") + message(SEND_ERROR "Expected files:\n\n ^${syms}$\n\nActual files:\n\n ${actual_syms}") +endif() + +file(INSTALL + "${CMAKE_BINARY_DIR}/file1.txt.sym" + "${CMAKE_BINARY_DIR}/file2/file2.txt.sym" + "${CMAKE_BINARY_DIR}/file3.txt.sym" + "${CMAKE_BINARY_DIR}/file4/file4.txt.sym" + "${CMAKE_BINARY_DIR}/file5.txt" + "${CMAKE_BINARY_DIR}/file6/file6/file6.txt.sym.4" + "${CMAKE_BINARY_DIR}/file8/file8.txt.sym" + "${CMAKE_BINARY_DIR}/file7/../file7.txt" + "${CMAKE_BINARY_DIR}/file8.txt" + "${CMAKE_BINARY_DIR}/file9.sym/file9.txt" + "${CMAKE_BINARY_DIR}/file10/file10/file10.txt.sym" + DESTINATION "${CMAKE_BINARY_DIR}/dest3" + ) + +set(resolved_file1.txt.sym [[^file1\.txt$]]) +set(resolved_file10.txt.sym [[/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN-build/file10/file10/\.\./file10\.txt$]]) +set(resolved_file2.txt.sym [[^\.\./file2\.txt$]]) +set(resolved_file3.txt.sym [[/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN-build/file3\.txt$]]) +set(resolved_file4.txt.sym [[/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN-build/file4\.txt$]]) +set(resolved_file6.txt.sym.4 [[^file6\.txt\.sym\.3$]]) +set(resolved_file8.txt.sym [[/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN-build/file8/\.\./file8\.txt$]]) +set(syms) +foreach(f + file1.txt.sym + file10.txt.sym + file2.txt.sym + file3.txt.sym + file4.txt.sym + file5.txt + file6.txt.sym.4 + file7.txt + file8.txt + file8.txt.sym + file9.txt + ) + string(REPLACE "." "\\." r "${f}") + list(APPEND syms "[^;]*/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN-build/dest3/${r}") + set(filename "${CMAKE_BINARY_DIR}/dest3/${f}") + if(DEFINED resolved_${f}) + file(READ_SYMLINK "${filename}" resolved) + if(NOT resolved MATCHES "${resolved_${f}}") + message(SEND_ERROR "Expected symlink resolution for ${f}: ${resolved_${f}}\nActual resolution: ${resolved}") + endif() + elseif(NOT EXISTS "${filename}" OR IS_SYMLINK "${filename}" OR IS_DIRECTORY "${filename}") + message(SEND_ERROR "${f} should be a regular file") + endif() +endforeach() + +file(GLOB_RECURSE actual_syms LIST_DIRECTORIES true "${CMAKE_BINARY_DIR}/dest3/*") +if(NOT actual_syms MATCHES "^${syms}$") + message(SEND_ERROR "Expected files:\n\n ^${syms}$\n\nActual files:\n\n ${actual_syms}") +endif() diff --git a/Tests/RunCMake/file/REMOVE-empty-stderr.txt b/Tests/RunCMake/file/REMOVE-empty-stderr.txt new file mode 100644 index 0000000..898a6e1 --- /dev/null +++ b/Tests/RunCMake/file/REMOVE-empty-stderr.txt @@ -0,0 +1,11 @@ +^CMake Warning \(dev\) at REMOVE-empty.cmake:1 \(file\): + Ignoring empty file name in REMOVE. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9] \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. ++ +CMake Warning \(dev\) at REMOVE-empty.cmake:2 \(file\): + Ignoring empty file name in REMOVE_RECURSE. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9] \(include\) +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/file/REMOVE-empty.cmake b/Tests/RunCMake/file/REMOVE-empty.cmake new file mode 100644 index 0000000..38046fb --- /dev/null +++ b/Tests/RunCMake/file/REMOVE-empty.cmake @@ -0,0 +1,2 @@ +file(REMOVE "") +file(REMOVE_RECURSE "") diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index 128e8f3..5db4b3b 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -43,6 +43,8 @@ run_cmake(GLOB_RECURSE-noexp-FOLLOW_SYMLINKS) run_cmake(SIZE) run_cmake(SIZE-error-does-not-exist) +run_cmake(REMOVE-empty) + # tests are valid both for GLOB and GLOB_RECURSE run_cmake(GLOB-sort-dedup) run_cmake(GLOB-error-LIST_DIRECTORIES-not-boolean) @@ -64,6 +66,7 @@ if(NOT WIN32 OR CYGWIN) run_cmake(READ_SYMLINK) run_cmake(READ_SYMLINK-noexist) run_cmake(READ_SYMLINK-notsymlink) + run_cmake(INSTALL-FOLLOW_SYMLINK_CHAIN) endif() if(RunCMake_GENERATOR STREQUAL "Ninja") diff --git a/Tests/WarnUnusedCliUnused/CMakeLists.txt b/Tests/WarnUnusedCliUnused/CMakeLists.txt index 7ed69bf..a149f04 100644 --- a/Tests/WarnUnusedCliUnused/CMakeLists.txt +++ b/Tests/WarnUnusedCliUnused/CMakeLists.txt @@ -1,9 +1,9 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.14) project(WarnUnusedCliUnused) -set_directory_properties(PROPERTIES - ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_BINARY_DIR}/CMakeCache.txt" -) +# Remove UNUSED_CLI_VARIABLE from the cache to trigger the +# CMake warning message on re-builds as well. +unset(UNUSED_CLI_VARIABLE CACHE) add_library(dummy empty.cpp) |