diff options
Diffstat (limited to 'Tests')
551 files changed, 5116 insertions, 477 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index faa199d..6ceb832 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -294,26 +294,6 @@ if(BUILD_TESTING) mark_as_advanced(CTEST_TEST_CTEST) endif () - # Should tests that use CVS be run? - # - set(do_cvs_tests 0) - - if(EXISTS ${CMAKE_ROOT}/Modules/FindCVS.cmake) - find_package(CVS QUIET) - else() - find_program(CVS_EXECUTABLE NAMES cvs) - endif() - - if(CVS_EXECUTABLE) - set(do_cvs_tests 1) - endif() - - if(do_cvs_tests AND NOT UNIX) - if("${CVS_EXECUTABLE}" MATCHES "cygwin") - set(do_cvs_tests 0) - endif() - endif() - # Should CPack tests be run? By default, yes, but... # # Disable packaging test on Apple 10.3 and below. PackageMaker starts @@ -1475,6 +1455,7 @@ if(BUILD_TESTING) ICU Intl Jasper + JNI JPEG JsonCpp LAPACK @@ -1562,18 +1543,33 @@ if(BUILD_TESTING) endif() set(FindMatlab.basic_checks_BUILD_OPTIONS ${FindMatlab_additional_test_options}) ADD_TEST_MACRO(FindMatlab.basic_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) + set_property(TEST FindMatlab.basic_checks APPEND PROPERTY LABELS "Matlab") set(FindMatlab.versions_checks_BUILD_OPTIONS ${FindMatlab_additional_test_options}) ADD_TEST_MACRO(FindMatlab.versions_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) + set_property(TEST FindMatlab.versions_checks APPEND PROPERTY LABELS "Matlab") set(FindMatlab.components_checks_BUILD_OPTIONS ${FindMatlab_additional_test_options}) ADD_TEST_MACRO(FindMatlab.components_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) + set_property(TEST FindMatlab.components_checks APPEND PROPERTY LABELS "Matlab") set(FindMatlab.failure_reports_BUILD_OPTIONS ${FindMatlab_additional_test_options}) ADD_TEST_MACRO(FindMatlab.failure_reports ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) + set_property(TEST FindMatlab.failure_reports APPEND PROPERTY LABELS "Matlab") set(FindMatlab.r2018a_check_BUILD_OPTIONS ${FindMatlab_additional_test_options}) ADD_TEST_MACRO(FindMatlab.r2018a_check ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) + set_property(TEST FindMatlab.r2018a_check APPEND PROPERTY LABELS "Matlab") set(FindMatlab.targets_checks_BUILD_OPTIONS ${FindMatlab_additional_test_options}) ADD_TEST_MACRO(FindMatlab.targets_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) + set_property(TEST FindMatlab.targets_checks APPEND PROPERTY LABELS "Matlab") + set(FindMatlab.no_implicit_link_checks_BUILD_OPTIONS ${FindMatlab_additional_test_options}) + ADD_TEST_MACRO(FindMatlab.no_implicit_link_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) + set_property(TEST FindMatlab.no_implicit_link_checks APPEND PROPERTY LABELS "Matlab") endif() + set(ExternalProject_BUILD_OPTIONS "") + foreach(vcs CVS SVN GIT HG) + if(DEFINED CMake_TEST_ExternalProject_${vcs}) + list(APPEND ExternalProject_BUILD_OPTIONS -DEP_TEST_${vcs}=${CMake_TEST_ExternalProject_${vcs}}) + endif() + endforeach() add_test(ExternalProject ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/ExternalProject" @@ -1582,6 +1578,7 @@ if(BUILD_TESTING) --build-project ExternalProjectTest --build-exe-dir "${CMake_BINARY_DIR}/Tests/ExternalProject" --force-new-ctest-process + --build-options ${ExternalProject_BUILD_OPTIONS} --test-command ${CMAKE_CTEST_COMMAND} -V ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProject") @@ -2332,7 +2329,7 @@ if(BUILD_TESTING) endmacro() macro(add_test_GhsMulti_rename_install test_name) add_test_GhsMulti( ${test_name} GhsMultiRenameInstall ${test_name} - "-DCMAKE_INSTALL_PREFIX=. -DRUN_TEST=${test_name}" ${CMAKE_CMAKE_COMMAND} --build . --target install) + "-DCMAKE_INSTALL_PREFIX=. -DRUN_TEST=${test_name}" ${CMAKE_CMAKE_COMMAND} --build . --target INSTALL) endmacro() #unset ghs config variables unset(ghs_config_name) @@ -2562,27 +2559,8 @@ if(BUILD_TESTING) # -S "${CMake_BINARY_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake" # ) - # A test for ctest_build() with targets in subdirectories - set(ctest_configure_options) - if(CMAKE_GENERATOR_PLATFORM) - list(APPEND ctest_configure_options -A ${CMAKE_GENERATOR_PLATFORM}) - endif() - if(CMAKE_GENERATOR_TOOLSET) - list(APPEND ctest_configure_options -T ${CMAKE_GENERATOR_TOOLSET}) - endif() - if(CMake_TEST_EXPLICIT_MAKE_PROGRAM) - list(APPEND ctest_configure_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}) - endif() - configure_file("${CMake_SOURCE_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in" - "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake" @ONLY) - unset(ctest_configure_options) - add_test(CTest.BuildCommand.ProjectInSubdir - ${CMAKE_CTEST_COMMAND} -S "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake") - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/Nested") - - set(CTEST_TEST_UPDATE 1) - if(CTEST_TEST_UPDATE) - # Test CTest Update with Subversion + # Test CTest Update with Subversion + if(NOT DEFINED CMake_TEST_CTestUpdate_SVN OR CMake_TEST_CTestUpdate_SVN) find_package(Subversion QUIET) if(Subversion_FOUND) get_filename_component(_Subversion_BIN_DIR @@ -2595,129 +2573,131 @@ if(BUILD_TESTING) set(Subversion_FOUND FALSE) endif() endif() - if(Subversion_FOUND) - set(CTestUpdateSVN_DIR "CTest UpdateSVN") - configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateSVN.cmake.in" - "${CMake_BINARY_DIR}/Tests/CTestUpdateSVN.cmake" @ONLY) - add_test(CTest.UpdateSVN ${CMAKE_CMAKE_COMMAND} - -P "${CMake_BINARY_DIR}/Tests/CTestUpdateSVN.cmake" - ) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateSVN_DIR}") + endif() + if(NOT DEFINED CMake_TEST_CTestUpdate_SVN AND Subversion_FOUND) + set(CMake_TEST_CTestUpdate_SVN 1) + endif() + if(CMake_TEST_CTestUpdate_SVN) + if(NOT Subversion_FOUND) + message(FATAL_ERROR "CMake_TEST_CTestUpdate_SVN enabled but Subversion is not found.") endif() + set(CTestUpdateSVN_DIR "CTest UpdateSVN") + configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateSVN.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestUpdateSVN.cmake" @ONLY) + add_test(CTest.UpdateSVN ${CMAKE_CMAKE_COMMAND} + -P "${CMake_BINARY_DIR}/Tests/CTestUpdateSVN.cmake" + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateSVN_DIR}") + endif() - # Test CTest Update with CVS - if(EXISTS ${CMAKE_ROOT}/Modules/FindCVS.cmake) - find_package(CVS QUIET) - else() - find_program(CVS_EXECUTABLE NAMES cvs) - set(CVS_FOUND ${CVS_EXECUTABLE}) - endif() - set(CTEST_TEST_UPDATE_CVS ${CVS_FOUND}) - if(CTEST_TEST_UPDATE_CVS AND NOT UNIX) - if("${CVS_EXECUTABLE}" MATCHES "cygwin") - message(STATUS "No CTest.UpdateCVS test with cygwin cvs.exe outside cygwin!") - set(CTEST_TEST_UPDATE_CVS 0) - endif() - endif() - if(CTEST_TEST_UPDATE_CVS) - set(CTestUpdateCVS_DIR "CTest UpdateCVS") - configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateCVS.cmake.in" - "${CMake_BINARY_DIR}/Tests/CTestUpdateCVS.cmake" @ONLY) - add_test(CTest.UpdateCVS ${CMAKE_CMAKE_COMMAND} - -P "${CMake_BINARY_DIR}/Tests/CTestUpdateCVS.cmake" - ) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateCVS_DIR}") + # Test CTest Update with CVS + if(NOT DEFINED CMake_TEST_CTestUpdate_CVS OR CMake_TEST_CTestUpdate_CVS) + find_program(CVS_EXECUTABLE NAMES cvs) + mark_as_advanced(CVS_EXECUTABLE) + endif() + if(NOT DEFINED CMake_TEST_CTestUpdate_CVS AND CVS_EXECUTABLE + AND (UNIX OR NOT "${CVS_EXECUTABLE}" MATCHES "cygwin")) + set(CMake_TEST_CTestUpdate_CVS 1) + endif() + if(CMake_TEST_CTestUpdate_CVS) + if(NOT CVS_EXECUTABLE) + message(FATAL_ERROR "CMake_TEST_CTestUpdate_CVS enabled but CVS_EXECUTABLE is not found.") endif() + set(CTestUpdateCVS_DIR "CTest UpdateCVS") + configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateCVS.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestUpdateCVS.cmake" @ONLY) + add_test(CTest.UpdateCVS ${CMAKE_CMAKE_COMMAND} + -P "${CMake_BINARY_DIR}/Tests/CTestUpdateCVS.cmake" + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateCVS_DIR}") + endif() - # Test CTest Update with BZR + # Test CTest Update with BZR + if(CMake_TEST_CTestUpdate_BZR) + if(TEST_HOME) + file(MAKE_DIRECTORY "${TEST_HOME}/.bazaar") + endif() find_program(BZR_EXECUTABLE NAMES bzr) mark_as_advanced(BZR_EXECUTABLE) - set(CTEST_TEST_UPDATE_BZR 0) - if(BZR_EXECUTABLE) - if(NOT "${BZR_EXECUTABLE}" MATCHES "cygwin" OR UNIX) - set(CTEST_TEST_UPDATE_BZR 1) - endif() - endif() - if(CTEST_TEST_UPDATE_BZR) - # Check if xmloutput plugin is there - execute_process(COMMAND ${BZR_EXECUTABLE} xmlplugins RESULT_VARIABLE xmlplugres - OUTPUT_QUIET ERROR_QUIET) - if( NOT ${xmlplugres} ) - set(CTestUpdateBZR_DIR "CTest UpdateBZR") - configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateBZR.cmake.in" - "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR.cmake" @ONLY) - add_test(CTest.UpdateBZR ${CMAKE_CMAKE_COMMAND} - -P "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR.cmake" - ) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateBZR_DIR}") - set(CTestUpdateBZR_DIR "CTest UpdateBZR_CLocale") - configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateBZR.cmake.in" - "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR_CLocale.cmake" @ONLY) - add_test(CTest.UpdateBZR.CLocale ${CMAKE_CMAKE_COMMAND} - -P "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR_CLocale.cmake" - ) - set_tests_properties(CTest.UpdateBZR.CLocale PROPERTIES ENVIRONMENT LC_ALL=C) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateBZR_DIR}") - endif() - endif() + if(NOT BZR_EXECUTABLE) + message(FATAL_ERROR "CMake_TEST_CTestUpdate_BZR enabled but BZR_EXECUTABLE is not found.") + endif() + set(CTestUpdateBZR_DIR "CTest UpdateBZR") + configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateBZR.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR.cmake" @ONLY) + add_test(CTest.UpdateBZR ${CMAKE_CMAKE_COMMAND} + -P "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR.cmake" + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateBZR_DIR}") + set(CTestUpdateBZR_DIR "CTest UpdateBZR_CLocale") + configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateBZR.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR_CLocale.cmake" @ONLY) + add_test(CTest.UpdateBZR.CLocale ${CMAKE_CMAKE_COMMAND} + -P "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR_CLocale.cmake" + ) + set_tests_properties(CTest.UpdateBZR.CLocale PROPERTIES ENVIRONMENT LC_ALL=C) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateBZR_DIR}") + endif() - # Test CTest Update with GIT + # Test CTest Update with GIT + if(NOT DEFINED CMake_TEST_CTestUpdate_GIT OR CMake_TEST_CTestUpdate_GIT) find_program(GIT_EXECUTABLE NAMES git) mark_as_advanced(GIT_EXECUTABLE) - set(CTEST_TEST_UPDATE_GIT 0) - if(GIT_EXECUTABLE) - if(NOT "${GIT_EXECUTABLE}" MATCHES "cygwin" OR UNIX) - set(CTEST_TEST_UPDATE_GIT 1) - endif() - endif() - if(CTEST_TEST_UPDATE_GIT) - set(CTestUpdateGIT_DIR "CTest UpdateGIT") - configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateGIT.cmake.in" - "${CMake_BINARY_DIR}/Tests/CTestUpdateGIT.cmake" @ONLY) - add_test(CTest.UpdateGIT ${CMAKE_CMAKE_COMMAND} - -P "${CMake_BINARY_DIR}/Tests/CTestUpdateGIT.cmake" - ) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateGIT_DIR}") + endif() + if(NOT DEFINED CMake_TEST_CTestUpdate_GIT AND GIT_EXECUTABLE + AND (UNIX OR NOT "${GIT_EXECUTABLE}" MATCHES "cygwin")) + set(CMake_TEST_CTestUpdate_GIT 1) + endif() + if(CMake_TEST_CTestUpdate_GIT) + if(NOT GIT_EXECUTABLE) + message(FATAL_ERROR "CMake_TEST_CTestUpdate_GIT enabled but GIT_EXECUTABLE is not found.") endif() + set(CTestUpdateGIT_DIR "CTest UpdateGIT") + configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateGIT.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestUpdateGIT.cmake" @ONLY) + add_test(CTest.UpdateGIT ${CMAKE_CMAKE_COMMAND} + -P "${CMake_BINARY_DIR}/Tests/CTestUpdateGIT.cmake" + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateGIT_DIR}") + endif() - # Test CTest Update with HG + # Test CTest Update with HG + if(NOT DEFINED CMake_TEST_CTestUpdate_HG OR CMake_TEST_CTestUpdate_HG) find_program(HG_EXECUTABLE NAMES hg) mark_as_advanced(HG_EXECUTABLE) - set(CTEST_TEST_UPDATE_HG 0) - if(HG_EXECUTABLE) - if(NOT "${HG_EXECUTABLE}" MATCHES "cygwin" OR UNIX) - set(CTEST_TEST_UPDATE_HG 1) - endif() - endif() - if(CTEST_TEST_UPDATE_HG) - set(CTestUpdateHG_DIR "CTest UpdateHG") - configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateHG.cmake.in" - "${CMake_BINARY_DIR}/Tests/CTestUpdateHG.cmake" @ONLY) - add_test(CTest.UpdateHG ${CMAKE_CMAKE_COMMAND} - -P "${CMake_BINARY_DIR}/Tests/CTestUpdateHG.cmake" - ) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateHG_DIR}") + endif() + if(NOT DEFINED CMake_TEST_CTestUpdate_HG AND HG_EXECUTABLE + AND (UNIX OR NOT "${HG_EXECUTABLE}" MATCHES "cygwin")) + set(CMake_TEST_CTestUpdate_HG 1) + endif() + if(CMake_TEST_CTestUpdate_HG) + if(NOT HG_EXECUTABLE) + message(FATAL_ERROR "CMake_TEST_CTestUpdate_HG enabled but HG_EXECUTABLE is not found.") endif() + set(CTestUpdateHG_DIR "CTest UpdateHG") + configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateHG.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestUpdateHG.cmake" @ONLY) + add_test(CTest.UpdateHG ${CMAKE_CMAKE_COMMAND} + -P "${CMake_BINARY_DIR}/Tests/CTestUpdateHG.cmake" + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateHG_DIR}") + endif() - # Test CTest Update with P4 + # Test CTest Update with P4 + if(CMake_TEST_CTestUpdate_P4) find_program(P4_EXECUTABLE NAMES p4) find_program(P4D_EXECUTABLE NAMES p4d) mark_as_advanced(P4_EXECUTABLE P4D_EXECUTABLE) - set(CTEST_TEST_UPDATE_P4 0) - if(P4_EXECUTABLE AND P4D_EXECUTABLE) - if(NOT "${P4_EXECUTABLE};${P4D_EXECUTABLE}" MATCHES "cygwin" OR UNIX) - set(CTEST_TEST_UPDATE_P4 1) - endif() - endif() - if(CTEST_TEST_UPDATE_P4) - set(CTestUpdateP4_DIR "CTest UpdateP4") - configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateP4.cmake.in" - "${CMake_BINARY_DIR}/Tests/CTestUpdateP4.cmake" @ONLY) - add_test(CTest.UpdateP4 ${CMAKE_CMAKE_COMMAND} - -P "${CMake_BINARY_DIR}/Tests/CTestUpdateP4.cmake" - ) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateP4_DIR}") - endif() + if(NOT P4_EXECUTABLE OR NOT P4D_EXECUTABLE) + message(FATAL_ERROR "CMake_TEST_CTestUpdate_HG enabled but P4_EXECUTABLE and P4D_EXECUTABLE are not both not found.") + endif() + set(CTestUpdateP4_DIR "CTest UpdateP4") + configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateP4.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestUpdateP4.cmake" @ONLY) + add_test(CTest.UpdateP4 ${CMAKE_CMAKE_COMMAND} + -P "${CMake_BINARY_DIR}/Tests/CTestUpdateP4.cmake" + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateP4_DIR}") endif() configure_file( @@ -3029,7 +3009,7 @@ if(BUILD_TESTING) -C "\${CTestTest_CONFIG}" ) set_property(TEST CTestTestVerboseOutput PROPERTY PASS_REGULAR_EXPRESSION - "Environment variables:.*foo=bar.*this=that" + "Test command:.*Working Directory:.*Environment variables:.*foo=bar.*this=that" ) configure_file( @@ -3589,6 +3569,8 @@ if(BUILD_TESTING) --test-command InterfaceLinkLibraries) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/InterfaceLinkLibraries") + ADD_TEST_MACRO(InterfaceLinkLibrariesDirect) + if(NOT CMake_TEST_EXTERNAL_CMAKE) add_subdirectory(CMakeTests) endif() diff --git a/Tests/CMakeTests/FileDownloadTest.cmake.in b/Tests/CMakeTests/FileDownloadTest.cmake.in index e0ce99a..255909d 100644 --- a/Tests/CMakeTests/FileDownloadTest.cmake.in +++ b/Tests/CMakeTests/FileDownloadTest.cmake.in @@ -179,3 +179,51 @@ if(EXISTS TIMEOUT) message(SEND_ERROR "TIMEOUT argument was incorrectly interpreted as a filename") endif() message(STATUS "${status}") + +message(STATUS "FileDownload:14") +file(DOWNLOAD + ${url} + ${dir}/file14.bin + TIMEOUT ${timeout} + STATUS status + RANGE_START 0 + EXPECTED_MD5 dbd330d52f4dbd60115d4191904ded92 + ) +__reportIfWrongStatus("${status}" 0) + +message(STATUS "FileDownload:15") +file(DOWNLOAD + ${url} + ${dir}/file15.bin + TIMEOUT ${timeout} + STATUS status + RANGE_END 50 + EXPECTED_MD5 8592e5665b839b5d23825dc84c135b61 + ) +__reportIfWrongStatus("${status}" 0) + +message(STATUS "FileDownload:16") +file(DOWNLOAD + ${url} + ${dir}/file16.bin + TIMEOUT ${timeout} + STATUS status + RANGE_START 10 + RANGE_END 50 + EXPECTED_MD5 36cd52681e6c6c8fef85fcd9e86fc30d + ) +__reportIfWrongStatus("${status}" 0) + +message(STATUS "FileDownload:17") +file(DOWNLOAD + ${url} + ${dir}/file17.bin + TIMEOUT ${timeout} + STATUS status + RANGE_START 0 + RANGE_END 50 + RANGE_START 60 + RANGE_END 100 + EXPECTED_MD5 c5c9e74e82d493dd901eecccd659cebc + ) +__reportIfWrongStatus("${status}" 0) diff --git a/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in b/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in deleted file mode 100644 index 0f56781..0000000 --- a/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required(VERSION 2.8.10) - -set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/VSProjectInSubdir") -set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestBuildCommandProjectInSubdir/Nested") -set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") -set(CTEST_BUILD_CONFIGURATION "@CTestTest_CONFIG@") - -ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY}) -ctest_start(Experimental) -ctest_configure(OPTIONS "@ctest_configure_options@") -ctest_build(TARGET test) diff --git a/Tests/CTestUpdateP4.cmake.in b/Tests/CTestUpdateP4.cmake.in index 5eef9fb..8a99e67 100644 --- a/Tests/CTestUpdateP4.cmake.in +++ b/Tests/CTestUpdateP4.cmake.in @@ -66,6 +66,7 @@ for i in 1 2 3 4 5 6 7 8 9 10; do fi done echo 'Gave up waiting for server to start.' +sed 's/^/ /' '${P4_ROOT}/p4.log' " ) endif() @@ -258,4 +259,4 @@ message("Shutting down p4d") run_child( WORKING_DIRECTORY ${TOP} COMMAND ${P4CMD} admin stop -)
\ No newline at end of file +) diff --git a/Tests/CudaOnly/All/CMakeLists.txt b/Tests/CudaOnly/ArchSpecial/CMakeLists.txt index ba32e9a..46f4ada 100644 --- a/Tests/CudaOnly/All/CMakeLists.txt +++ b/Tests/CudaOnly/ArchSpecial/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.20) -project(CudaOnlyAll CUDA) +project(ArchSpecial CUDA) if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" AND CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) @@ -25,6 +25,7 @@ function(verify_output flag) endforeach() list(SORT command_archs) + list(REMOVE_DUPLICATES command_archs) if(NOT "${command_archs}" STREQUAL "${architectures}") message(FATAL_ERROR "Architectures used for \"${flag}\" don't match the reference (\"${command_archs}\" != \"${architectures}\").") endif() @@ -50,7 +51,17 @@ try_compile(all_major_archs_compiles ) verify_output(all-major) -if(all_archs_compiles AND all_major_archs_compiles) - add_executable(CudaOnlyAll main.cu) - target_compile_options(CudaOnlyAll PRIVATE ${compile_options}) +set(CMAKE_CUDA_ARCHITECTURES native) +try_compile(native_archs_compiles + ${CMAKE_CURRENT_BINARY_DIR}/try_compile/native_archs_compiles + ${CMAKE_CURRENT_SOURCE_DIR}/main.cu + COMPILE_DEFINITIONS ${try_compile_flags} + OUTPUT_VARIABLE output + ) +verify_output(native) + +if(all_archs_compiles AND all_major_archs_compiles AND native_archs_compiles) + set(CMAKE_CUDA_ARCHITECTURES all) + add_executable(CudaOnlyArchSpecial main.cu) + target_compile_options(CudaOnlyArchSpecial PRIVATE ${compile_options}) endif() diff --git a/Tests/CudaOnly/All/main.cu b/Tests/CudaOnly/ArchSpecial/main.cu index 5047a34..5047a34 100644 --- a/Tests/CudaOnly/All/main.cu +++ b/Tests/CudaOnly/ArchSpecial/main.cu diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt index cacfb76..aa4755d 100644 --- a/Tests/CudaOnly/CMakeLists.txt +++ b/Tests/CudaOnly/CMakeLists.txt @@ -4,8 +4,8 @@ macro (add_cuda_test_macro name) PROPERTY LABELS "CUDA") endmacro () -add_cuda_test_macro(CudaOnly.All CudaOnlyAll) add_cuda_test_macro(CudaOnly.Architecture Architecture) +add_cuda_test_macro(CudaOnly.ArchSpecial CudaOnlyArchSpecial) add_cuda_test_macro(CudaOnly.CompileFlags CudaOnlyCompileFlags) add_cuda_test_macro(CudaOnly.EnableStandard CudaOnlyEnableStandard) diff --git a/Tests/CudaOnly/WithDefs/CMakeLists.txt b/Tests/CudaOnly/WithDefs/CMakeLists.txt index 02f043f..39bcd91 100644 --- a/Tests/CudaOnly/WithDefs/CMakeLists.txt +++ b/Tests/CudaOnly/WithDefs/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.18) project(WithDefs CUDA) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + set(release_compile_defs DEFREL) #Goal for this example: diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index a79efd0..c9e41f5 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -163,6 +163,16 @@ install( cmake_policy(PUSH) cmake_policy(SET CMP0022 NEW) + +# Test control over direct linking. +include(../../InterfaceLinkLibrariesDirect/testStaticLibPlugin.cmake) +include(../../InterfaceLinkLibrariesDirect/testSharedLibWithHelper.cmake) +include(../../InterfaceLinkLibrariesDirect/testExeWithPluginHelper.cmake) +if(NOT maybe_OBJECTS_DESTINATION) + target_compile_definitions(testSharedLibHelperObj INTERFACE testSharedLibHelperObj_NO_OBJECT) + target_compile_definitions(testExePluginHelperObj INTERFACE testExePluginHelperObj_NO_OBJECT) +endif() + # Test exporting dependent libraries into different exports add_library(testLibRequired testLibRequired.c) add_library(testLibDepends testLibDepends.c) @@ -544,6 +554,9 @@ install( testLibDeprecation testLibCycleA testLibCycleB testLibNoSONAME + testStaticLibWithPlugin testStaticLibPluginExtra testStaticLibPlugin + testSharedLibWithHelper testSharedLibHelperObj + testExeWithPluginHelper testExePluginHelperObj testMod1 testMod2 cmp0022NEW cmp0022OLD TopDirLib SubDirLinkA @@ -619,6 +632,9 @@ export(TARGETS testExe2 testLib4 testLib5 testLib6 testLib7 testExe3 testExe4 te testLib4lib testLib4libdbg testLib4libopt testLibCycleA testLibCycleB testLibNoSONAME + testStaticLibWithPlugin testStaticLibPluginExtra testStaticLibPlugin + testSharedLibWithHelper testSharedLibHelperObj + testExeWithPluginHelper testExePluginHelperObj testMod1 testMod2 testLibPerConfigDest NAMESPACE bld_ diff --git a/Tests/ExportImport/Export/SubDirLinkA/CMakeLists.txt b/Tests/ExportImport/Export/SubDirLinkA/CMakeLists.txt index 1aa41d2..ccba264 100644 --- a/Tests/ExportImport/Export/SubDirLinkA/CMakeLists.txt +++ b/Tests/ExportImport/Export/SubDirLinkA/CMakeLists.txt @@ -1,6 +1,9 @@ add_library(SubDirLinkAImported IMPORTED INTERFACE) target_compile_definitions(SubDirLinkAImported INTERFACE DEF_SubDirLinkAImportedForExport) -target_link_libraries(TopDirLib PUBLIC debug "$<1:SubDirLinkAImported;SubDirLinkAImported>" optimized "$<1:SubDirLinkAImported;SubDirLinkAImported>") +target_link_libraries(TopDirLib PUBLIC + debug "$<1:$<TARGET_NAME:SubDirLinkAImported>;$<TARGET_NAME:SubDirLinkAImported>>" + optimized "$<1:$<TARGET_NAME:SubDirLinkAImported>;$<TARGET_NAME:SubDirLinkAImported>>" +) add_library(SubDirLinkA STATIC SubDirLinkA.c) diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index d6cc8d0..272c7a9 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -68,16 +68,23 @@ target_link_libraries(imp_testExe1 exp_testLib7 exp_testLibCycleA exp_testLibPerConfigDest + exp_testStaticLibWithPlugin ) add_library(imp_testInterfaceInclude1 STATIC imp_testInterfaceInclude1.c) target_include_directories(imp_testInterfaceInclude1 SYSTEM PRIVATE testInterfaceIncludeSystem) target_link_libraries(imp_testInterfaceInclude1 PRIVATE exp_testInterfaceIncludeUser) +add_executable(imp_UseSharedLibWithHelper1 ../../../InterfaceLinkLibrariesDirect/UseSharedLibWithHelper.c) +target_link_libraries(imp_UseSharedLibWithHelper1 PRIVATE exp_testSharedLibWithHelper testSharedLibHelperExclude) + # Try building a plugin to an executable imported from the install tree. add_library(imp_mod1 MODULE imp_mod1.c) target_link_libraries(imp_mod1 exp_testExe2) +add_library(imp_ExePlugin1 MODULE ../../../InterfaceLinkLibrariesDirect/ExePlugin.c) +target_link_libraries(imp_ExePlugin1 PRIVATE exp_testExeWithPluginHelper testExePluginHelperExclude) + # Try referencing an executable imported from the build tree. add_custom_command( OUTPUT ${Import_BINARY_DIR}/bld_generated.c @@ -112,6 +119,7 @@ target_link_libraries(imp_testExe1b bld_testLib7 bld_testLibCycleA bld_testLibPerConfigDest + bld_testStaticLibWithPlugin ) add_library(imp_testInterfaceInclude1b STATIC imp_testInterfaceInclude1.c) @@ -183,10 +191,16 @@ target_link_libraries(SubDirLink_bld PRIVATE bld_TopDirLib bld_SubDirLinkA) add_executable(SubDirLink_exp SubDirLink.c) target_link_libraries(SubDirLink_exp PRIVATE exp_TopDirLib exp_SubDirLinkA) +add_executable(imp_UseSharedLibWithHelper1b ../../../InterfaceLinkLibrariesDirect/UseSharedLibWithHelper.c) +target_link_libraries(imp_UseSharedLibWithHelper1b PRIVATE bld_testSharedLibWithHelper testSharedLibHelperExclude) + # Try building a plugin to an executable imported from the build tree. add_library(imp_mod1b MODULE imp_mod1.c) target_link_libraries(imp_mod1b bld_testExe2) +add_library(imp_ExePlugin1b MODULE ../../../InterfaceLinkLibrariesDirect/ExePlugin.c) +target_link_libraries(imp_ExePlugin1b PRIVATE bld_testExeWithPluginHelper testExePluginHelperExclude) + # Export/CMakeLists.txt pretends the RelWithDebInfo (as well as Debug) # configuration should link to debug libs. foreach(c DEBUG RELWITHDEBINFO) diff --git a/Tests/ExportImport/Import/A/imp_testExe1.c b/Tests/ExportImport/Import/A/imp_testExe1.c index 8173557..7490a80 100644 --- a/Tests/ExportImport/Import/A/imp_testExe1.c +++ b/Tests/ExportImport/Import/A/imp_testExe1.c @@ -10,6 +10,7 @@ extern int testLib6(void); extern int testLib7(void); extern int testLibCycleA1(void); extern int testLibPerConfigDest(void); +extern int testStaticLibPlugin(void); /* Switch a symbol between debug and optimized builds to make sure the proper library is found from the testLib4 link interface. */ @@ -24,6 +25,7 @@ int main() { return (testLib2() + generated_by_testExe1() + testLib3() + testLib4() + testLib5() + testLib6() + testLib7() + testLibCycleA1() + - testLibPerConfigDest() + generated_by_testExe3() + - generated_by_testExe4() + testLib4lib() + testLib4libcfg()); + testLibPerConfigDest() + testStaticLibPlugin() + + generated_by_testExe3() + generated_by_testExe4() + testLib4lib() + + testLib4libcfg()); } diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt index 59e3bcc..e4c6c66 100644 --- a/Tests/ExternalProject/CMakeLists.txt +++ b/Tests/ExternalProject/CMakeLists.txt @@ -8,10 +8,50 @@ include(ExternalProject) # Test ExternalProject, especially with checkouts from VCS -find_package(CVS) -find_package(Subversion) -find_package(Git) -find_package(Hg) +if(NOT DEFINED EP_TEST_CVS OR EP_TEST_CVS) + find_package(CVS) +endif() +if(NOT DEFINED EP_TEST_CVS AND CVS_FOUND AND (UNIX OR NOT "${CVS_EXECUTABLE}" MATCHES "cygwin")) + set(EP_TEST_CVS 1) +endif() + +if(NOT DEFINED EP_TEST_SVN OR EP_TEST_SVN) + find_package(Subversion) + if(Subversion_FOUND AND Subversion_VERSION_SVN VERSION_LESS 1.2) + message(STATUS "No ExternalProject svn tests with svn client less than version 1.2") + set(Subversion_FOUND 0) + endif() + # Only do svn tests in cygwin/cygwin or not-cygwin/not-cygwin arrangements: + if(Subversion_FOUND AND CMAKE_CURRENT_BINARY_DIR MATCHES "cygdrive/" AND NOT "${Subversion_SVN_EXECUTABLE}" MATCHES "cygwin") + message(STATUS "No ExternalProject svn tests with non-cygwin svn client in a /cygdrive based build") + set(Subversion_FOUND 0) + endif() +endif() +if(NOT DEFINED EP_TEST_SVN AND Subversion_FOUND) + set(EP_TEST_SVN 1) +endif() + +if(NOT DEFINED EP_TEST_GIT OR EP_TEST_GIT) + find_package(Git) +endif() +if(NOT DEFINED EP_TEST_GIT AND Git_FOUND) + message(STATUS "GIT_VERSION_STRING='${GIT_VERSION_STRING}'") + if(NOT "${GIT_VERSION_STRING}" VERSION_LESS 1.6.5) + set(EP_TEST_GIT 1) + endif() +endif() + +if(NOT DEFINED EP_TEST_HG OR EP_TEST_HG) + find_package(Hg) +endif() +if(NOT DEFINED EP_TEST_HG AND Hg_FOUND) + set(EP_TEST_HG 1) +endif() + +message(STATUS "EP_TEST_CVS='${EP_TEST_CVS}' CVS_EXECUTABLE='${CVS_EXECUTABLE}'") +message(STATUS "EP_TEST_SVN='${EP_TEST_SVN}' Subversion_SVN_EXECUTABLE='${Subversion_SVN_EXECUTABLE}'") +message(STATUS "EP_TEST_GIT='${EP_TEST_GIT}' GIT_EXECUTABLE='${GIT_EXECUTABLE}'") +message(STATUS "EP_TEST_HG='${EP_TEST_HG}' HG_EXECUTABLE='${HG_EXECUTABLE}'") option(ExternalProjectTest_USE_FOLDERS "Enable folder grouping in IDEs." ON) if(ExternalProjectTest_USE_FOLDERS) @@ -115,20 +155,7 @@ ExternalProject_Add(${proj} # CVS-based tests: # -set(do_cvs_tests 0) - -if(CVS_EXECUTABLE) - set(do_cvs_tests 1) -endif() - -if(do_cvs_tests AND NOT UNIX) - if("${CVS_EXECUTABLE}" MATCHES "cygwin") - message(STATUS "No ExternalProject cvs tests with cygwin cvs.exe outside cygwin!") - set(do_cvs_tests 0) - endif() -endif() - -if(do_cvs_tests) +if(EP_TEST_CVS) # Unzip/untar the CVS repository in our source folder so that other # projects below may use it to test CVS args of ExternalProject_Add # @@ -207,32 +234,7 @@ endif() # SVN-based tests: # -set(do_svn_tests 0) - -if(Subversion_SVN_EXECUTABLE) - set(do_svn_tests 1) -endif() - -# Only do svn tests with svn >= version 1.2 -# -if(do_svn_tests) - if(Subversion_VERSION_SVN VERSION_LESS 1.2) - message(STATUS "No ExternalProject svn tests with svn client less than version 1.2") - set(do_svn_tests 0) - endif() -endif() - -# Only do svn tests in cygwin/cygwin or not-cygwin/not-cygwin arrangements: -# -if(do_svn_tests) - if(CMAKE_CURRENT_BINARY_DIR MATCHES "cygdrive/" AND - NOT "${Subversion_SVN_EXECUTABLE}" MATCHES "cygwin") - message(STATUS "No ExternalProject svn tests with non-cygwin svn client in a /cygdrive based build") - set(do_svn_tests 0) - endif() -endif() - -if(do_svn_tests) +if(EP_TEST_SVN) # Unzip/untar the SVN repository in our source folder so that other # projects below may use it to test SVN args of ExternalProject_Add # @@ -292,22 +294,7 @@ if(do_svn_tests) set_property(TARGET ${proj} PROPERTY FOLDER "SVN") endif() - -set(do_git_tests 0) - -if(GIT_EXECUTABLE) - set(do_git_tests 1) - - message(STATUS "GIT_VERSION_STRING='${GIT_VERSION_STRING}'") - - if("${GIT_VERSION_STRING}" VERSION_LESS 1.6.5) - message(STATUS "No ExternalProject git tests with git client less than version 1.6.5") - set(do_git_tests 0) - endif() -endif() - - -if(do_git_tests) +if(EP_TEST_GIT) set(local_git_repo "../../LocalRepositories/GIT") # Unzip/untar the git repository in our source folder so that other @@ -444,7 +431,9 @@ if(do_git_tests) set_property(TARGET ${proj} PROPERTY FOLDER "GIT") set(proj TS1-GIT-all-GIT_SUBMODULES-via-CMP0097-OLD) + set(CMAKE_WARN_DEPRECATED FALSE) # we are testing CMP0097 OLD behavior cmake_policy(SET CMP0097 OLD) + unset(CMAKE_WARN_DEPRECATED) ExternalProject_Add(${proj} GIT_REPOSITORY "${local_git_repo}" GIT_SUBMODULES "" @@ -552,20 +541,7 @@ if(do_git_tests) endif() -set(do_hg_tests 0) - -if(HG_EXECUTABLE) - set(do_hg_tests 1) -endif() - -if(do_hg_tests AND NOT UNIX) - if("${HG_EXECUTABLE}" MATCHES "cygwin") - message(STATUS "No ExternalProject hg tests with cygwin hg outside cygwin!") - set(do_hg_tests 0) - endif() -endif() - -if(do_hg_tests) +if(EP_TEST_HG) set(local_hg_repo "../../LocalRepositories/HG") # Unzip/untar the hg repository in our source folder so that other @@ -640,7 +616,7 @@ enable_testing() # # BuildTree tests: # -if(do_cvs_tests) +if(EP_TEST_CVS) add_test(TutorialStep1-CVS-20090626-BuildTreeTest "${binary_base}/TutorialStep1-CVS-20090626/Tutorial" 4) @@ -651,7 +627,7 @@ if(do_cvs_tests) "${binary_base}/TutorialStep1-CVS-HEAD/Tutorial" 81) endif() -if(do_svn_tests) +if(EP_TEST_SVN) add_test(TutorialStep1-SVN-20090626-BuildTreeTest "${binary_base}/TutorialStep1-SVN-20090626/Tutorial" 100) @@ -662,7 +638,7 @@ if(do_svn_tests) "${binary_base}/TutorialStep1-SVN-trunk/Tutorial" 98) endif() -if(do_git_tests) +if(EP_TEST_GIT) add_test(TutorialStep1-GIT-byhash ${CMAKE_COMMAND} -P "${binary_base}/TutorialStep1-GIT-byhash/example.cmake") @@ -684,13 +660,6 @@ if(do_git_tests) endif() endif() - -message(STATUS "do_cvs_tests='${do_cvs_tests}'") -message(STATUS "do_svn_tests='${do_svn_tests}'") -message(STATUS "do_git_tests='${do_git_tests}' GIT_EXECUTABLE='${GIT_EXECUTABLE}'") -message(STATUS "do_hg_tests='${do_hg_tests}' HG_EXECUTABLE='${HG_EXECUTABLE}'") - - # Test if log works when the first arguments of *_COMMAND is "COMMAND". set(proj ExternalProject-no-log) set(download_cmd "") diff --git a/Tests/FindJNI/AWT/AWTTgt.java b/Tests/FindJNI/AWT/AWTTgt.java new file mode 100644 index 0000000..dce37f3 --- /dev/null +++ b/Tests/FindJNI/AWT/AWTTgt.java @@ -0,0 +1,7 @@ +class AWTTgt +{ + public static void main(String[] args) + { + System.loadLibrary("AWTTgt"); + } +} diff --git a/Tests/FindJNI/AWT/AWTVar.java b/Tests/FindJNI/AWT/AWTVar.java new file mode 100644 index 0000000..a918c28 --- /dev/null +++ b/Tests/FindJNI/AWT/AWTVar.java @@ -0,0 +1,7 @@ +class AWTVar +{ + public static void main(String[] args) + { + System.loadLibrary("AWTVar"); + } +} diff --git a/Tests/FindJNI/AWT/CMakeLists.txt b/Tests/FindJNI/AWT/CMakeLists.txt new file mode 100644 index 0000000..bdf49ea --- /dev/null +++ b/Tests/FindJNI/AWT/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required (VERSION 3.23) +project (TestAWT) + +find_package (JNI REQUIRED COMPONENTS AWT) +find_package (Java REQUIRED COMPONENTS Runtime Development) + +add_library (AWTTgt MODULE awt.cxx) +target_link_libraries (AWTTgt PRIVATE JNI::AWT) + +add_library (AWTVar MODULE awt.cxx) +target_include_directories (AWTVar PRIVATE ${JNI_INCLUDE_DIRS}) +target_link_libraries (AWTVar PRIVATE ${JNI_LIBRARIES}) + +enable_testing () + +foreach (test AWTTgt AWTVar) + add_test (NAME Compile${test} COMMAND ${Java_JAVAC_EXECUTABLE} + ${TestAWT_SOURCE_DIR}/${test}.java) + add_test (NAME Remove${test} COMMAND ${CMAKE_COMMAND} -E remove + ${TestAWT_SOURCE_DIR}/${test}.class) + + add_test (NAME ${test} COMMAND ${Java_JAVA_EXECUTABLE} + -cp ${TestAWT_SOURCE_DIR} + -Djava.library.path=$<TARGET_FILE_DIR:${test}> + ${test} + ) + + set_tests_properties (Compile${test} PROPERTIES FIXTURES_SETUP Init${test}) + set_tests_properties (Remove${test} PROPERTIES FIXTURES_CLEANUP Init${test}) + set_tests_properties (${test} PROPERTIES FIXTURES_REQUIRED Init${test}) +endforeach () diff --git a/Tests/FindJNI/AWT/awt.cxx b/Tests/FindJNI/AWT/awt.cxx new file mode 100644 index 0000000..64e7652 --- /dev/null +++ b/Tests/FindJNI/AWT/awt.cxx @@ -0,0 +1,23 @@ +#include <jawt.h> + +extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) +{ + void* tmp; + + if (vm->GetEnv(&tmp, JNI_VERSION_1_2) != JNI_OK) { + return -1; + } + + JAWT awt; + awt.version = JAWT_VERSION_1_3; + + if (JAWT_GetAWT(static_cast<JNIEnv*>(tmp), &awt) == JNI_FALSE) { + return -1; + } + + return JNI_VERSION_1_2; +} + +extern "C" JNIEXPORT void JNICALL JNI_OnUnload(JavaVM* vm, void* reserved) +{ +} diff --git a/Tests/FindJNI/CMakeLists.txt b/Tests/FindJNI/CMakeLists.txt new file mode 100644 index 0000000..0a0f756 --- /dev/null +++ b/Tests/FindJNI/CMakeLists.txt @@ -0,0 +1,12 @@ +foreach(test IN ITEMS Minimal JVM AWT) + add_test(NAME FindJNI.${test} COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindJNI/${test}" + "${CMake_BINARY_DIR}/Tests/FindJNI/${test}" + ${build_generator_args} + --build-project Test${test} + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) +endforeach() diff --git a/Tests/FindJNI/JVM/CMakeLists.txt b/Tests/FindJNI/JVM/CMakeLists.txt new file mode 100644 index 0000000..cead6ae --- /dev/null +++ b/Tests/FindJNI/JVM/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required (VERSION 3.23) +project (TestJVM) + +find_package (JNI REQUIRED COMPONENTS JVM) +find_package (Java REQUIRED COMPONENTS Runtime Development) + +add_library (JVMTgt MODULE jvm.cxx) +target_link_libraries (JVMTgt PRIVATE JNI::JVM) + +add_library (JVMVar MODULE jvm.cxx) +target_include_directories (JVMVar PRIVATE ${JNI_INCLUDE_DIRS}) +target_link_libraries (JVMVar PRIVATE ${JNI_LIBRARIES}) + +enable_testing () + +foreach (test JVMTgt JVMVar) + add_test (NAME Compile${test} COMMAND ${Java_JAVAC_EXECUTABLE} + ${TestJVM_SOURCE_DIR}/${test}.java) + add_test (NAME Remove${test} COMMAND ${CMAKE_COMMAND} -E remove + ${TestJVM_SOURCE_DIR}/${test}.class) + + add_test (NAME ${test} COMMAND ${Java_JAVA_EXECUTABLE} + -cp ${TestJVM_SOURCE_DIR} + -Djava.library.path=$<TARGET_FILE_DIR:${test}> + ${test} + ) + + set_tests_properties (Compile${test} PROPERTIES FIXTURES_SETUP Init${test}) + set_tests_properties (Remove${test} PROPERTIES FIXTURES_CLEANUP Init${test}) + set_tests_properties (${test} PROPERTIES FIXTURES_REQUIRED Init${test}) +endforeach () diff --git a/Tests/FindJNI/JVM/JVMTgt.java b/Tests/FindJNI/JVM/JVMTgt.java new file mode 100644 index 0000000..aa5dbb8 --- /dev/null +++ b/Tests/FindJNI/JVM/JVMTgt.java @@ -0,0 +1,7 @@ +class JVMTgt +{ + public static void main(String[] args) + { + System.loadLibrary("JVMTgt"); + } +} diff --git a/Tests/FindJNI/JVM/JVMVar.java b/Tests/FindJNI/JVM/JVMVar.java new file mode 100644 index 0000000..0e84a6f --- /dev/null +++ b/Tests/FindJNI/JVM/JVMVar.java @@ -0,0 +1,7 @@ +class JVMVar +{ + public static void main(String[] args) + { + System.loadLibrary("JVMVar"); + } +} diff --git a/Tests/FindJNI/JVM/jvm.cxx b/Tests/FindJNI/JVM/jvm.cxx new file mode 100644 index 0000000..f79ccce --- /dev/null +++ b/Tests/FindJNI/JVM/jvm.cxx @@ -0,0 +1,15 @@ +#include <jni.h> + +extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) +{ + jsize n = 0; + if (JNI_GetCreatedJavaVMs(nullptr, 0, &n) != JNI_OK || n <= 0) { + return -1; + } + + return JNI_VERSION_1_2; +} + +extern "C" JNIEXPORT void JNICALL JNI_OnUnload(JavaVM* vm, void* reserved) +{ +} diff --git a/Tests/FindJNI/Minimal/CMakeLists.txt b/Tests/FindJNI/Minimal/CMakeLists.txt new file mode 100644 index 0000000..f499c0a --- /dev/null +++ b/Tests/FindJNI/Minimal/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required (VERSION 3.23) +project (TestMinimal) + +set (CMAKE_CXX_VISIBILITY_PRESET hidden) + +find_package (JNI REQUIRED) +find_package (Java REQUIRED COMPONENTS Runtime Development) + +add_library (MinimalTgt MODULE minimal.cxx) +target_link_libraries (MinimalTgt PRIVATE JNI::JNI) + +add_library (MinimalVar MODULE minimal.cxx) +target_include_directories (MinimalVar PRIVATE ${JNI_INCLUDE_DIRS}) +target_link_libraries (MinimalVar PRIVATE ${JNI_LIBRARIES}) + +enable_testing () + +foreach (test MinimalTgt MinimalVar) + add_test (NAME Compile${test} COMMAND ${Java_JAVAC_EXECUTABLE} + ${TestMinimal_SOURCE_DIR}/${test}.java) + add_test (NAME Remove${test} COMMAND ${CMAKE_COMMAND} -E remove + ${TestMinimal_SOURCE_DIR}/${test}.class) + + add_test (NAME ${test} COMMAND ${Java_JAVA_EXECUTABLE} + -cp ${TestMinimal_SOURCE_DIR} + -Djava.library.path=$<TARGET_FILE_DIR:${test}> + ${test} + ) + + set_tests_properties (Compile${test} PROPERTIES FIXTURES_SETUP Init${test}) + set_tests_properties (Remove${test} PROPERTIES FIXTURES_CLEANUP Init${test}) + set_tests_properties (${test} PROPERTIES FIXTURES_REQUIRED Init${test}) + + set_tests_properties (${test} PROPERTIES PASS_REGULAR_EXPRESSION "^FindJNI\n$") +endforeach () diff --git a/Tests/FindJNI/Minimal/MinimalTgt.java b/Tests/FindJNI/Minimal/MinimalTgt.java new file mode 100644 index 0000000..d9c98b5 --- /dev/null +++ b/Tests/FindJNI/Minimal/MinimalTgt.java @@ -0,0 +1,7 @@ +class MinimalTgt +{ + public static void main(String[] args) + { + System.loadLibrary("MinimalTgt"); + } +} diff --git a/Tests/FindJNI/Minimal/MinimalVar.java b/Tests/FindJNI/Minimal/MinimalVar.java new file mode 100644 index 0000000..9f05c74 --- /dev/null +++ b/Tests/FindJNI/Minimal/MinimalVar.java @@ -0,0 +1,7 @@ +class MinimalVar +{ + public static void main(String[] args) + { + System.loadLibrary("MinimalVar"); + } +} diff --git a/Tests/FindJNI/Minimal/minimal.cxx b/Tests/FindJNI/Minimal/minimal.cxx new file mode 100644 index 0000000..4423613 --- /dev/null +++ b/Tests/FindJNI/Minimal/minimal.cxx @@ -0,0 +1,38 @@ +#include <cassert> + +#include <jni.h> + +extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) +{ + void* tmp; + if (vm->GetEnv(&tmp, JNI_VERSION_1_2) != JNI_OK) { + return -1; + } + + // The following lines do: + // + // System.out.println("FindJNI"); + // + JNIEnv* env = static_cast<JNIEnv*>(tmp); + + jclass clzS = env->FindClass("java/lang/System"); + jclass clzP = env->FindClass("java/io/PrintStream"); + + jfieldID outF = env->GetStaticFieldID(clzS, "out", "Ljava/io/PrintStream;"); + jobject out = env->GetStaticObjectField(clzS, outF); + jmethodID println = + env->GetMethodID(clzP, "println", "(Ljava/lang/String;)V"); + + env->CallVoidMethod(out, println, env->NewStringUTF("FindJNI")); + + return JNI_VERSION_1_2; +} + +extern "C" JNIEXPORT void JNICALL JNI_OnUnload(JavaVM* vm, void* reserved) +{ + void* env; + jint result = vm->GetEnv(&env, JNI_VERSION_1_2); + assert(result == JNI_OK); + + assert(static_cast<JNIEnv*>(env)->GetVersion() == JNI_VERSION_1_2); +} diff --git a/Tests/FindMatlab/cmake_matlab_unit_tests4.m b/Tests/FindMatlab/cmake_matlab_unit_tests4.m index 6a7b04d..c2bf270 100644 --- a/Tests/FindMatlab/cmake_matlab_unit_tests4.m +++ b/Tests/FindMatlab/cmake_matlab_unit_tests4.m @@ -1,4 +1,3 @@ - classdef cmake_matlab_unit_tests4 < matlab.unittest.TestCase % Testing R2017b and R2018a APIs properties @@ -12,11 +11,7 @@ classdef cmake_matlab_unit_tests4 < matlab.unittest.TestCase function testR2018a(testCase) ret = cmake_matlab_mex2b(5+6i); - v = version; - n = find(v=='.'); - v = str2double(v(1:n(2)-1)); - disp(v) - if v>= 9.4 % R2018a + if not(verLessThan('matlab','9.4')) % R2018a testCase.verifyEqual(ret, 16); disp('TESTING version >= 9.4') else diff --git a/Tests/FindMatlab/no_implicit_link_checks/CMakeLists.txt b/Tests/FindMatlab/no_implicit_link_checks/CMakeLists.txt new file mode 100644 index 0000000..bceeba1 --- /dev/null +++ b/Tests/FindMatlab/no_implicit_link_checks/CMakeLists.txt @@ -0,0 +1,70 @@ + +cmake_minimum_required (VERSION 2.8.12) +enable_testing() +project(no_implicit_links_checks) + +set(MATLAB_FIND_DEBUG TRUE) + +if(IS_MCR) + set(RUN_UNIT_TESTS FALSE) +else() + set(RUN_UNIT_TESTS TRUE) + set(components MAIN_PROGRAM) +endif() + +if(NOT "${MCR_ROOT}" STREQUAL "") + set(Matlab_ROOT_DIR "${MCR_ROOT}") + if(NOT EXISTS "${MCR_ROOT}") + message(FATAL_ERROR "MCR does not exist ${MCR_ROOT}") + endif() +endif() + +find_package(Matlab REQUIRED COMPONENTS ${components}) + + +matlab_add_mex( + # target name + NAME cmake_matlab_test_wrapper1 + # output name + OUTPUT_NAME cmake_matlab_mex1 + SRC ${CMAKE_CURRENT_SOURCE_DIR}/../matlab_wrapper1.cpp + DOCUMENTATION ${CMAKE_CURRENT_SOURCE_DIR}/../help_text1.m.txt + NO_IMPLICIT_LINK_TO_MATLAB_LIBRARIES + ) + +# Inspect the LINK_LIBRARIES properties to check if mex or mx are present +get_target_property(MATLAB_TEST_WRAPPER1_LINK_LIBRARIES + cmake_matlab_test_wrapper1 LINK_LIBRARIES) + +string(FIND "${MATLAB_TEST_WRAPPER1_LINK_LIBRARIES}" "mx" SEARCH_RESULT) +if(NOT "${SEARCH_RESULT}" EQUAL "-1") + message(FATAL_ERROR "Matlab::mx linked even if NO_IMPLICIT_LINK_TO_MATLAB_LIBRARIES was passed") +endif() + +string(FIND "${MATLAB_TEST_WRAPPER1_LINK_LIBRARIES}" "mex" SEARCH_RESULT) +if(NOT "${SEARCH_RESULT}" EQUAL "-1") + message(FATAL_ERROR "Matlab::mex linked even if NO_IMPLICIT_LINK_TO_MATLAB_LIBRARIES was passed") +endif() + +string(FIND "${MATLAB_TEST_WRAPPER1_LINK_LIBRARIES}" "MatlabEngine" SEARCH_RESULT) +if(NOT "${SEARCH_RESULT}" EQUAL "-1") + message(FATAL_ERROR "Matlab::MatlabEngine linked even if NO_IMPLICIT_LINK_TO_MATLAB_LIBRARIES was passed") +endif() + +string(FIND "${MATLAB_TEST_WRAPPER1_LINK_LIBRARIES}" "MatlabDataArray" SEARCH_RESULT) +if(NOT "${SEARCH_RESULT}" EQUAL "-1") + message(FATAL_ERROR "Matlab::MatlabDataArray linked even if NO_IMPLICIT_LINK_TO_MATLAB_LIBRARIES was passed") +endif() + +# Link separately with Matlab::mx and Matlab::mex to ensure that compilation +# and run of the test is successful +target_link_libraries(cmake_matlab_test_wrapper1 PRIVATE Matlab::mx Matlab::mex) + +if(RUN_UNIT_TESTS) + matlab_add_unit_test( + NAME ${PROJECT_NAME}_matlabtest-1 + TIMEOUT 300 + UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests1.m + ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1> + ) +endif() diff --git a/Tests/FindX11/Test/CMakeLists.txt b/Tests/FindX11/Test/CMakeLists.txt index 5b304d9..18a73a3 100644 --- a/Tests/FindX11/Test/CMakeLists.txt +++ b/Tests/FindX11/Test/CMakeLists.txt @@ -33,8 +33,11 @@ test_x11_component(x11_components Xaw) test_x11_component(x11_components xcb) test_x11_component(x11_components X11_xcb) test_x11_component(x11_components xcb_icccm) +test_x11_component(x11_components xcb_randr) test_x11_component(x11_components xcb_util) test_x11_component(x11_components xcb_xfixes) +test_x11_component(x11_components xcb_xtest) +test_x11_component(x11_components xcb_keysyms) test_x11_component(x11_components xcb_xkb) test_x11_component(x11_components Xcomposite) test_x11_component(x11_components Xdamage) @@ -74,6 +77,7 @@ foreach(lib xcb X11_xcb xcb_icccm + xcb_randr xcb_util xcb_xfixes Xcomposite diff --git a/Tests/FindX11/Test/main.c b/Tests/FindX11/Test/main.c index b44ae28..653a2be 100644 --- a/Tests/FindX11/Test/main.c +++ b/Tests/FindX11/Test/main.c @@ -336,6 +336,20 @@ static void test_xcb(void) xcb_disconnect(connection); } +# ifdef HAVE_xcb_randr +# include <xcb/randr.h> + +static void test_xcb_randr(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_randr_query_version_cookie_t cookie = + xcb_randr_query_version(connection, 0, 0); + xcb_disconnect(connection); +} + +# endif + # ifdef HAVE_xcb_util # include <xcb/xcb_aux.h> @@ -362,6 +376,34 @@ static void test_xcb_xfixes(void) # endif +# ifdef HAVE_xcb_xtest +# include <xcb/xtest.h> + +static void test_xcb_xtest(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_test_get_version_unchecked(connection, 1, 0); + xcb_disconnect(connection); +} + +# endif + +# ifdef HAVE_xcb_keysyms +# include <xcb/xcb_keysyms.h> + +static void test_xcb_keysyms(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_key_symbols_t* symbols = xcb_key_symbols_alloc(connection); + if (symbols != NULL) + xcb_key_symbols_free(symbols); + xcb_disconnect(connection); +} + +# endif + #endif #include <stddef.h> @@ -455,6 +497,9 @@ int main(int argc, char* argv[]) test_xcb, #endif #ifdef HAVE_xcb_util + test_xcb_randr, +#endif +#ifdef HAVE_xcb_util test_xcb_util, #endif #ifdef HAVE_xcb_xfixes diff --git a/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt b/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt index 4a3f5c2..9250709 100644 --- a/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt @@ -27,8 +27,7 @@ try_compile(RESULT message("Output from build:\n${OUTPUT}") if (RUN_TEST STREQUAL "RELEASE_FLAGS") find_file (fileName test_none.gpj - ${CMAKE_CURRENT_BINARY_DIR}/build - ${CMAKE_CURRENT_BINARY_DIR}/build/test_none + ${CMAKE_CURRENT_BINARY_DIR}/build/test_none.dir ) message("Parsing project file: ${fileName}") file(STRINGS ${fileName} fileText) @@ -40,8 +39,7 @@ if (RUN_TEST STREQUAL "RELEASE_FLAGS") else() unset(fileName CACHE) find_file (fileName K1.gpj - ${CMAKE_CURRENT_BINARY_DIR}/build - ${CMAKE_CURRENT_BINARY_DIR}/build/K1 + ${CMAKE_CURRENT_BINARY_DIR}/build/K1.dir ) message("Parsing project file: ${fileName}") file(STRINGS ${fileName} fileText) @@ -53,8 +51,7 @@ else() unset(fileName CACHE) find_file (fileName K2.gpj - ${CMAKE_CURRENT_BINARY_DIR}/build - ${CMAKE_CURRENT_BINARY_DIR}/build/K2 + ${CMAKE_CURRENT_BINARY_DIR}/build/K2.dir ) message("Parsing project file: ${fileName}") file(STRINGS ${fileName} fileText) @@ -66,8 +63,7 @@ else() unset(fileName CACHE) find_file (fileName K3.gpj - ${CMAKE_CURRENT_BINARY_DIR}/build - ${CMAKE_CURRENT_BINARY_DIR}/build/K3 + ${CMAKE_CURRENT_BINARY_DIR}/build/K3.dir ) message("Parsing project file: ${fileName}") file(STRINGS ${fileName} fileText) @@ -79,8 +75,7 @@ else() unset(fileName CACHE) find_file (fileName K4.gpj - ${CMAKE_CURRENT_BINARY_DIR}/build - ${CMAKE_CURRENT_BINARY_DIR}/build/K4 + ${CMAKE_CURRENT_BINARY_DIR}/build/K4.dir ) message("Parsing project file: ${fileName}") file(STRINGS ${fileName} fileText) diff --git a/Tests/GhsMulti/GhsMultiExclude/CMakeLists.txt b/Tests/GhsMulti/GhsMultiExclude/CMakeLists.txt index 0448cf2..575bf50 100644 --- a/Tests/GhsMulti/GhsMultiExclude/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiExclude/CMakeLists.txt @@ -14,4 +14,6 @@ set_target_properties( lib1 PROPERTIES EXCLUDE_FROM_ALL yes ) add_library(lib2 EXCLUDE_FROM_ALL lib1.c) +add_library(lib3 lib1.c) + add_executable(exe1 exe1.c) diff --git a/Tests/GhsMulti/GhsMultiExclude/verify.cmake b/Tests/GhsMulti/GhsMultiExclude/verify.cmake index 0467b5a..99cef63 100644 --- a/Tests/GhsMulti/GhsMultiExclude/verify.cmake +++ b/Tests/GhsMulti/GhsMultiExclude/verify.cmake @@ -1,54 +1,56 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#test project was generated -unset(fileName CACHE) -find_file (fileName lib1.gpj - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/lib1 - ) - -if (fileName) - message("Found target lib1: ${fileName}") -else() - message(SEND_ERROR "Could not find target lib1: ${fileName}") -endif() - -#test project was built -unset(fileName CACHE) -find_file (fileName lib1.a - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/lib1 - ) - -if (fileName) - message(SEND_ERROR "Found target lib1: ${fileName}") -else() - message("Could not find target lib1: ${fileName}") -endif() - -#test project was generated -unset(fileName CACHE) -find_file (fileName lib2.gpj - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/lib2 - ) - -if (fileName) - message("Found target lib2 ${fileName}") -else() - message(SEND_ERROR "Could not find target lib2: ${fileName}") -endif() - -#test project was built -unset(fileName CACHE) -find_file (fileName lib2.a - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/lib2 - ) - -if (fileName) - message(SEND_ERROR "Found target lib2: ${fileName}") -else() - message("Could not find target lib2: ${fileName}") -endif() +function(verify_skipped_tgt name) + unset(fileName CACHE) + find_file (fileName ${name}.tgt.gpj + ${CMAKE_CURRENT_BINARY_DIR} + ) + + if (fileName) + message("Found target ${name}: ${fileName}") + else() + message(SEND_ERROR "Could not find target ${name}: ${fileName}") + endif() + + #test project was built + unset(fileName CACHE) + find_file (fileName lib${name}.a + ${CMAKE_CURRENT_BINARY_DIR} + ) + + if (fileName) + message(SEND_ERROR "Found target ${name}: ${fileName}") + else() + message("Could not find target ${name}: ${fileName}") + endif() +endfunction() + +function(locate_tgt name) + unset(fileName CACHE) + find_file (fileName ${name}.tgt.gpj + ${CMAKE_CURRENT_BINARY_DIR} + ) + + if (fileName) + message("Found target ${name}: ${fileName}") + else() + message(SEND_ERROR "Could not find target ${name}: ${fileName}") + endif() + + #test project was built + unset(fileName CACHE) + find_file (fileName lib${name}.a + ${CMAKE_CURRENT_BINARY_DIR} + ) + + if (fileName) + message( "Found target ${name}: ${fileName}") + else() + message(SEND_ERROR "Could not find target ${name}: ${fileName}") + endif() +endfunction() + +verify_skipped_tgt(lib1) +verify_skipped_tgt(lib2) +locate_tgt(lib3) diff --git a/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt b/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt index da80b51..2d21bfb 100644 --- a/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt @@ -38,8 +38,7 @@ if (RUN_TEST STREQUAL "NO_FLAGS") else() unset(fileName CACHE) find_file(fileName exe1.gpj - ${CMAKE_CURRENT_BINARY_DIR}/link_build - ${CMAKE_CURRENT_BINARY_DIR}/link_build/exe1 + ${CMAKE_CURRENT_BINARY_DIR}/link_build/exe1.dir ) message("Parsing project file: ${fileName}") file(STRINGS ${fileName} fileText) @@ -54,13 +53,14 @@ else() string(FIND "${fileText}" "${opt}" opt_found) if ( opt_found EQUAL -1 ) message(SEND_ERROR "Could not find: ${opt}") + else() + message("located: ${opt}") endif() endforeach() unset(fileName CACHE) find_file (fileName lib1.gpj - ${CMAKE_CURRENT_BINARY_DIR}/link_build - ${CMAKE_CURRENT_BINARY_DIR}/link_build/lib1 + ${CMAKE_CURRENT_BINARY_DIR}/link_build/lib1.dir ) message("Parsing project file: ${fileName}") file(STRINGS ${fileName} fileText) @@ -71,13 +71,14 @@ else() string(FIND "${fileText}" "${opt}" opt_found) if (opt_found EQUAL -1) message(SEND_ERROR "Could not find: ${opt}") + else() + message("located: ${opt}") endif() endforeach() unset(fileName CACHE) find_file (fileName lib2.gpj - ${CMAKE_CURRENT_BINARY_DIR}/link_build - ${CMAKE_CURRENT_BINARY_DIR}/link_build/lib2 + ${CMAKE_CURRENT_BINARY_DIR}/link_build/lib2.dir ) message("Parsing project file: ${fileName}") file(STRINGS ${fileName} fileText) @@ -87,6 +88,8 @@ else() string(FIND "${fileText}" "${opt}" opt_found) if ( opt_found EQUAL -1 ) message(SEND_ERROR "Could not find: ${opt}") + else() + message("located: ${opt}") endif() endforeach() endif() diff --git a/Tests/GhsMulti/GhsMultiMultipleProjects/verify.cmake b/Tests/GhsMulti/GhsMultiMultipleProjects/verify.cmake index 3855215..b6af935 100644 --- a/Tests/GhsMulti/GhsMultiMultipleProjects/verify.cmake +++ b/Tests/GhsMulti/GhsMultiMultipleProjects/verify.cmake @@ -1,58 +1,38 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#test project was generated -unset(fileName CACHE) -find_file(fileName lib3.gpj - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/lib3 - ${CMAKE_CURRENT_BINARY_DIR}/examples - ) - -if (fileName) - message("Found target lib3: ${fileName}") -else() - message(SEND_ERROR "Could not find target lib3: ${fileName}") -endif() - -#test project was generated -unset(fileName CACHE) -find_file (fileName exe3.gpj - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/exe3 - ${CMAKE_CURRENT_BINARY_DIR}/examples - ) - -if (fileName) - message("Found target exe3: ${fileName}") -else() - message(SEND_ERROR "Could not find target exe3: ${fileName}") -endif() - -#test project was not built -unset(fileName CACHE) -find_file (fileName lib3.a - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/lib3 - ${CMAKE_CURRENT_BINARY_DIR}/examples - ) - -if (fileName) - message(SEND_ERROR "Found target lib3: ${fileName}") -else() - message("Could not find target lib3: ${fileName}") -endif() - -unset(fileName CACHE) -find_file (fileName NAMES exe3.as exe3 - HINTS - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/exe3 - ${CMAKE_CURRENT_BINARY_DIR}/examples - ) - -if (fileName) - message(SEND_ERROR "Found target exe3: ${fileName}") -else() - message("Could not find target exe3: ${fileName}") -endif() +function(verify_project_top name) + unset(fileName CACHE) + find_file (fileName ${name}.top.gpj + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/sub + ${CMAKE_CURRENT_BINARY_DIR}/examples + ) + + if (fileName) + message("Found target ${name}: ${fileName}") + else() + message(SEND_ERROR "Could not find project ${name}: ${fileName}") + endif() +endfunction() + +function(verify_exe_built name) + unset(fileName CACHE) + find_file (fileName ${name} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/sub + ) + + if (fileName) + message("Found target ${name}: ${fileName}") + else() + message(SEND_ERROR "Could not find project ${name}: ${fileName}") + endif() +endfunction() + +#test project top files were generated +verify_project_top(test) +verify_project_top(test2) +verify_project_top(test3) +verify_exe_built(exe1) +verify_exe_built(exe2) diff --git a/Tests/InterfaceLinkLibraries/CMakeLists.txt b/Tests/InterfaceLinkLibraries/CMakeLists.txt index 9e14c44..07a747b 100644 --- a/Tests/InterfaceLinkLibraries/CMakeLists.txt +++ b/Tests/InterfaceLinkLibraries/CMakeLists.txt @@ -59,3 +59,12 @@ set_property(TARGET bar_static_private APPEND PROPERTY INTERFACE_LINK_LIBRARIES add_executable(InterfaceLinkLibraries main_vs6_4.cpp) set_property(TARGET InterfaceLinkLibraries APPEND PROPERTY LINK_LIBRARIES bar_static_private) + +add_library(foo_link_only STATIC foo_link_only.c) +target_compile_definitions(foo_link_only PUBLIC FOO_LINK_ONLY) +add_executable(use_foo_link_only_CMP0131_OLD use_foo_link_only.c) +target_link_libraries(use_foo_link_only_CMP0131_OLD PRIVATE "$<LINK_ONLY:foo_link_only>") +target_compile_definitions(use_foo_link_only_CMP0131_OLD PRIVATE EXPECT_FOO_LINK_ONLY) +cmake_policy(SET CMP0131 NEW) +add_executable(use_foo_link_only_CMP0131_NEW use_foo_link_only.c) +target_link_libraries(use_foo_link_only_CMP0131_NEW PRIVATE "$<LINK_ONLY:foo_link_only>") diff --git a/Tests/InterfaceLinkLibraries/foo_link_only.c b/Tests/InterfaceLinkLibraries/foo_link_only.c new file mode 100644 index 0000000..9ca1c01 --- /dev/null +++ b/Tests/InterfaceLinkLibraries/foo_link_only.c @@ -0,0 +1,8 @@ +#ifndef FOO_LINK_ONLY +# error "FOO_LINK_ONLY incorrectly not defined" +#endif + +int foo_link_only(void) +{ + return 0; +} diff --git a/Tests/InterfaceLinkLibraries/use_foo_link_only.c b/Tests/InterfaceLinkLibraries/use_foo_link_only.c new file mode 100644 index 0000000..e975c1b --- /dev/null +++ b/Tests/InterfaceLinkLibraries/use_foo_link_only.c @@ -0,0 +1,16 @@ +#ifdef EXPECT_FOO_LINK_ONLY +# ifndef FOO_LINK_ONLY +# error "FOO_LINK_ONLY incorrectly not defined" +# endif +#else +# ifdef FOO_LINK_ONLY +# error "FOO_LINK_ONLY incorrectly defined" +# endif +#endif + +extern int foo_link_only(void); + +int main(void) +{ + return foo_link_only(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/CMakeLists.txt b/Tests/InterfaceLinkLibrariesDirect/CMakeLists.txt new file mode 100644 index 0000000..dec131d --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/CMakeLists.txt @@ -0,0 +1,161 @@ +cmake_minimum_required(VERSION 3.21) +project(InterfaceLinkLibrariesDirect C) + +include(testStaticLibPlugin.cmake) +add_executable(InterfaceLinkLibrariesDirect main.c) +target_link_libraries(InterfaceLinkLibrariesDirect PRIVATE testStaticLibWithPlugin) + +include(testSharedLibWithHelper.cmake) +add_executable(UseSharedLibWithHelper UseSharedLibWithHelper.c) +target_link_libraries(UseSharedLibWithHelper PRIVATE testSharedLibWithHelper testSharedLibHelperExclude) + +include(testExeWithPluginHelper.cmake) +add_library(ExePlugin MODULE ExePlugin.c) +target_link_libraries(ExePlugin PRIVATE testExeWithPluginHelper testExePluginHelperExclude) + +#---------------------------------------------------------------------------- + +# Offer usage requirements and symbols to be used through static libs below. +add_library(A STATIC + a_always.c + + # Good symbols that direct_from_A libraries poison if incorrectly used. + a_not_direct_from_A.c + a_not_direct_from_A_for_exe.c + a_not_direct_from_A_optional.c + + # Bad symbols in direct_from_A libraries below to ensure they come first. + a_poison_direct_from_A.c + a_poison_direct_from_A_for_exe.c + a_poison_direct_from_A_optional.c + ) + +# Propagates as usage requirement from A. +add_library(direct_from_A STATIC direct_from_A.c direct_from_A_poison.c) +target_compile_definitions(direct_from_A INTERFACE DEF_DIRECT_FROM_A) +set_property(TARGET A APPEND PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT direct_from_A) + +# Propagates as usage requirement from A, but only for executables. +add_library(direct_from_A_for_exe STATIC direct_from_A_for_exe.c direct_from_A_for_exe_poison.c) +target_compile_definitions(direct_from_A_for_exe INTERFACE DEF_DIRECT_FROM_A_FOR_EXE) +set_property(TARGET A APPEND PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT + "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:direct_from_A_for_exe>") + +# Propagates as usage requirement from A, but only for targets that opt-in. +add_library(direct_from_A_optional STATIC direct_from_A_optional.c direct_from_A_optional_poison.c) +target_compile_definitions(direct_from_A_optional INTERFACE DEF_DIRECT_FROM_A_OPTIONAL) +set_property(TARGET A APPEND PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT + "$<$<BOOL:$<TARGET_PROPERTY:A_LINK_OPTIONAL>>:direct_from_A_optional>") + +# Uses and propagates A's usage requirements. +# Does not use the exe-only or optional usage requirements. +add_library(static_A_public STATIC static_A_public.c) +target_link_libraries(static_A_public PUBLIC A) + +# Uses A's usage requirements, but propagates only the linking requirements. +# Does not use the exe-only usage requirement. Does use the optional one. +add_library(static_A_private STATIC static_A_private.c) +target_link_libraries(static_A_private PRIVATE A) +set_property(TARGET static_A_private PROPERTY A_LINK_OPTIONAL 1) + +# Uses A's usage requirements, including an optional one. +add_executable(exe_use_static_A_public exe_use_static_A_public.c) +target_link_libraries(exe_use_static_A_public PRIVATE static_A_public) +set_property(TARGET exe_use_static_A_public PROPERTY A_LINK_OPTIONAL 1) + +# Does not use A's usage requirements, but does use its non-optional linking requirements. +add_executable(exe_use_static_A_private exe_use_static_A_private.c) +target_link_libraries(exe_use_static_A_private PRIVATE static_A_private) + +# Uses A's usage requirements, including an optional one, but overrides the link ordering. +add_executable(exe_use_static_A_public_explicit exe_use_static_A_public_explicit.c) +target_link_libraries(exe_use_static_A_public_explicit PRIVATE static_A_public A direct_from_A direct_from_A_for_exe direct_from_A_optional) +set_property(TARGET exe_use_static_A_public_explicit PROPERTY A_LINK_OPTIONAL 1) + +#---------------------------------------------------------------------------- + +# Test how original and injected dependencies get ordered. + +# A bunch of static libraries that need to be linked in alphabetic order. +# Each library has an extra source to poison all symbols meant to be +# provided by earlier libraries. This enforces ordering on platforms +# whose linkers re-visit static libraries. +add_library(order_A STATIC order_A.c) +add_library(order_B STATIC order_B.c order_B_poison.c) +add_library(order_C STATIC order_C.c order_C_poison.c) +add_library(order_D STATIC order_D.c order_D_poison.c) +add_library(order_E STATIC order_E.c order_E_poison.c) +add_library(order_F STATIC order_F.c order_F_poison.c) +add_library(order_G STATIC order_G.c order_G_poison.c) +add_library(order_H STATIC order_H.c order_H_poison.c) +add_library(order_I STATIC order_I.c order_I_poison.c) +add_library(order_J STATIC order_J.c order_J_poison.c) + +# An executable to drive linking. +add_executable(order_main order_main.c) + +# In the following diagram, connection by a slash means the top +# target lists the bottom target in a link interface property: +# +# \ => INTERFACE_LINK_LIBRARIES +# / => INTERFACE_LINK_LIBRARIES_DIRECT +# +# The top of each tree represents an entry in the exe's LINK_LIBRARIES. +# CMake should evaluate this graph to generate the proper link order. +# +# D H +# / \ / \ +# B J F I +# / / / / \ +# A C E G J +set_property(TARGET order_main PROPERTY LINK_LIBRARIES order_D order_H) +set_property(TARGET order_D PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT order_B) +set_property(TARGET order_D PROPERTY INTERFACE_LINK_LIBRARIES order_J) +set_property(TARGET order_B PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT order_A) +set_property(TARGET order_J PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT order_C) +set_property(TARGET order_H PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT order_F) +set_property(TARGET order_H PROPERTY INTERFACE_LINK_LIBRARIES order_I) +set_property(TARGET order_F PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT order_E) +set_property(TARGET order_I PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT order_G) +set_property(TARGET order_I PROPERTY INTERFACE_LINK_LIBRARIES order_J) + +#---------------------------------------------------------------------------- + +# Test that the original LINK_LIBRARIES cannot be re-ordered by injection +# from usage requirements. + +# A bunch of static libraries that need to be linked in alphabetic order. +# Each library has an extra source to poison all symbols meant to be +# provided by earlier libraries. This enforces ordering on platforms +# whose linkers re-visit static libraries. +add_library(force_A STATIC order_A.c) +add_library(force_B STATIC order_B.c order_B_poison.c) +add_library(force_C STATIC order_C.c order_C_poison.c) +add_library(force_D STATIC order_D.c order_D_poison.c) +add_library(force_E STATIC order_E.c order_E_poison.c) +add_library(force_F STATIC order_F.c order_F_poison.c) +add_library(force_G STATIC order_G.c order_G_poison.c) +add_library(force_H STATIC order_H.c order_H_poison.c) +add_library(force_I STATIC order_I.c order_I_poison.c) +add_library(force_J STATIC order_J.c order_J_poison.c) + +# An executable to drive linking. +add_executable(force_main order_main.c) + +# The executable explicitly lists all the libraries in the right order. +target_link_libraries(force_main PRIVATE force_A force_B force_C force_D force_E force_F force_G force_H) + +# Add legitimate normal dependencies. +set_property(TARGET force_D PROPERTY INTERFACE_LINK_LIBRARIES force_J) +set_property(TARGET force_H PROPERTY INTERFACE_LINK_LIBRARIES force_I) +set_property(TARGET force_I PROPERTY INTERFACE_LINK_LIBRARIES force_J) + +# Add bogus injected direct dependencies to verify that they do not +# change the original order of LINK_LIBRARIES. +set_property(TARGET force_A PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT force_B) +set_property(TARGET force_B PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT force_C) +set_property(TARGET force_C PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT force_D) +set_property(TARGET force_D PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT force_E) +set_property(TARGET force_E PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT force_F) +set_property(TARGET force_F PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT force_G) +set_property(TARGET force_G PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT force_H) diff --git a/Tests/InterfaceLinkLibrariesDirect/ExePlugin.c b/Tests/InterfaceLinkLibrariesDirect/ExePlugin.c new file mode 100644 index 0000000..40a261c --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/ExePlugin.c @@ -0,0 +1,21 @@ +extern int testExePluginHelperObj(int n); + +#ifdef testExePluginHelperObj_NO_OBJECT +int testExePluginHelperObj(int n) +{ + return n; +} +#endif + +#if defined(_WIN32) +__declspec(dllimport) +#endif + int testExePluginAPI(int n); + +#if defined(_WIN32) +__declspec(dllexport) +#endif + int testExePlugin(int n) +{ + return testExePluginAPI(n) + testExePluginHelperObj(n); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/UseSharedLibWithHelper.c b/Tests/InterfaceLinkLibrariesDirect/UseSharedLibWithHelper.c new file mode 100644 index 0000000..832e31f --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/UseSharedLibWithHelper.c @@ -0,0 +1,18 @@ +extern int testSharedLibHelperObj(int n); + +#ifdef testSharedLibHelperObj_NO_OBJECT +int testSharedLibHelperObj(int n) +{ + return n; +} +#endif + +#if defined(_WIN32) +__declspec(dllimport) +#endif + int testSharedLibWithHelper(int n); + +int main(void) +{ + return testSharedLibWithHelper(0) + testSharedLibHelperObj(0); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/a_always.c b/Tests/InterfaceLinkLibrariesDirect/a_always.c new file mode 100644 index 0000000..007680d --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/a_always.c @@ -0,0 +1,3 @@ +void a_always(void) +{ +} diff --git a/Tests/InterfaceLinkLibrariesDirect/a_not_direct_from_A.c b/Tests/InterfaceLinkLibrariesDirect/a_not_direct_from_A.c new file mode 100644 index 0000000..732d36e --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/a_not_direct_from_A.c @@ -0,0 +1,3 @@ +void not_direct_from_A(void) +{ +} diff --git a/Tests/InterfaceLinkLibrariesDirect/a_not_direct_from_A_for_exe.c b/Tests/InterfaceLinkLibrariesDirect/a_not_direct_from_A_for_exe.c new file mode 100644 index 0000000..9aed296 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/a_not_direct_from_A_for_exe.c @@ -0,0 +1,3 @@ +void not_direct_from_A_for_exe(void) +{ +} diff --git a/Tests/InterfaceLinkLibrariesDirect/a_not_direct_from_A_optional.c b/Tests/InterfaceLinkLibrariesDirect/a_not_direct_from_A_optional.c new file mode 100644 index 0000000..3572e51 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/a_not_direct_from_A_optional.c @@ -0,0 +1,3 @@ +void not_direct_from_A_optional(void) +{ +} diff --git a/Tests/InterfaceLinkLibrariesDirect/a_poison_direct_from_A.c b/Tests/InterfaceLinkLibrariesDirect/a_poison_direct_from_A.c new file mode 100644 index 0000000..6d1963d --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/a_poison_direct_from_A.c @@ -0,0 +1,5 @@ +extern void poison_direct_from_A(void); +void direct_from_A(void) +{ + poison_direct_from_A(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/a_poison_direct_from_A_for_exe.c b/Tests/InterfaceLinkLibrariesDirect/a_poison_direct_from_A_for_exe.c new file mode 100644 index 0000000..623fc07 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/a_poison_direct_from_A_for_exe.c @@ -0,0 +1,5 @@ +extern void poison_direct_from_A_for_exe(void); +void direct_from_A_for_exe(void) +{ + poison_direct_from_A_for_exe(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/a_poison_direct_from_A_optional.c b/Tests/InterfaceLinkLibrariesDirect/a_poison_direct_from_A_optional.c new file mode 100644 index 0000000..0f1328e --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/a_poison_direct_from_A_optional.c @@ -0,0 +1,5 @@ +extern void poison_direct_from_A_optional(void); +void direct_from_A_optional(void) +{ + poison_direct_from_A_optional(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/direct_from_A.c b/Tests/InterfaceLinkLibrariesDirect/direct_from_A.c new file mode 100644 index 0000000..d6d0df3 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/direct_from_A.c @@ -0,0 +1,3 @@ +void direct_from_A(void) +{ +} diff --git a/Tests/InterfaceLinkLibrariesDirect/direct_from_A_for_exe.c b/Tests/InterfaceLinkLibrariesDirect/direct_from_A_for_exe.c new file mode 100644 index 0000000..dfa6db1 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/direct_from_A_for_exe.c @@ -0,0 +1,3 @@ +void direct_from_A_for_exe(void) +{ +} diff --git a/Tests/InterfaceLinkLibrariesDirect/direct_from_A_for_exe_poison.c b/Tests/InterfaceLinkLibrariesDirect/direct_from_A_for_exe_poison.c new file mode 100644 index 0000000..c0ecb0b --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/direct_from_A_for_exe_poison.c @@ -0,0 +1,5 @@ +extern void poison_not_direct_from_A_for_exe(void); +void not_direct_from_A_for_exe(void) +{ + poison_not_direct_from_A_for_exe(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/direct_from_A_optional.c b/Tests/InterfaceLinkLibrariesDirect/direct_from_A_optional.c new file mode 100644 index 0000000..affdaeb --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/direct_from_A_optional.c @@ -0,0 +1,3 @@ +void direct_from_A_optional(void) +{ +} diff --git a/Tests/InterfaceLinkLibrariesDirect/direct_from_A_optional_poison.c b/Tests/InterfaceLinkLibrariesDirect/direct_from_A_optional_poison.c new file mode 100644 index 0000000..c7c3528 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/direct_from_A_optional_poison.c @@ -0,0 +1,5 @@ +extern void poison_not_direct_from_A_optional(void); +void not_direct_from_A_optional(void) +{ + poison_not_direct_from_A_optional(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/direct_from_A_poison.c b/Tests/InterfaceLinkLibrariesDirect/direct_from_A_poison.c new file mode 100644 index 0000000..b03cdf7 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/direct_from_A_poison.c @@ -0,0 +1,5 @@ +extern void poison_not_direct_from_A(void); +void not_direct_from_A(void) +{ + poison_not_direct_from_A(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/exe_use_static_A_private.c b/Tests/InterfaceLinkLibrariesDirect/exe_use_static_A_private.c new file mode 100644 index 0000000..12cf309 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/exe_use_static_A_private.c @@ -0,0 +1,23 @@ +#ifdef DEF_DIRECT_FROM_A +# error "DEF_DIRECT_FROM_A incorrectly defined" +#endif +#ifdef DEF_DIRECT_FROM_A_FOR_EXE +# error "DEF_DIRECT_FROM_A_FOR_EXE incorrectly defined" +#endif +#ifdef DEF_DIRECT_FROM_A_OPTIONAL +# error "DEF_DIRECT_FROM_A_OPTIONAL incorrectly defined" +#endif + +extern void static_A_private(void); +extern void direct_from_A(void); +extern void direct_from_A_for_exe(void); +extern void not_direct_from_A_optional(void); + +int main(void) +{ + static_A_private(); + direct_from_A(); + direct_from_A_for_exe(); + not_direct_from_A_optional(); + return 0; +} diff --git a/Tests/InterfaceLinkLibrariesDirect/exe_use_static_A_public.c b/Tests/InterfaceLinkLibrariesDirect/exe_use_static_A_public.c new file mode 100644 index 0000000..b3b0a56 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/exe_use_static_A_public.c @@ -0,0 +1,23 @@ +#ifndef DEF_DIRECT_FROM_A +# error "DEF_DIRECT_FROM_A incorrectly not defined" +#endif +#ifndef DEF_DIRECT_FROM_A_FOR_EXE +# error "DEF_DIRECT_FROM_A_FOR_EXE incorrectly not defined" +#endif +#ifndef DEF_DIRECT_FROM_A_OPTIONAL +# error "DEF_DIRECT_FROM_A_OPTIONAL incorrectly not defined" +#endif + +extern void static_A_public(void); +extern void direct_from_A(void); +extern void direct_from_A_for_exe(void); +extern void direct_from_A_optional(void); + +int main(void) +{ + static_A_public(); + direct_from_A(); + direct_from_A_for_exe(); + direct_from_A_optional(); + return 0; +} diff --git a/Tests/InterfaceLinkLibrariesDirect/exe_use_static_A_public_explicit.c b/Tests/InterfaceLinkLibrariesDirect/exe_use_static_A_public_explicit.c new file mode 100644 index 0000000..f698a24 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/exe_use_static_A_public_explicit.c @@ -0,0 +1,23 @@ +#ifndef DEF_DIRECT_FROM_A +# error "DEF_DIRECT_FROM_A incorrectly not defined" +#endif +#ifndef DEF_DIRECT_FROM_A_FOR_EXE +# error "DEF_DIRECT_FROM_A_FOR_EXE incorrectly not defined" +#endif +#ifndef DEF_DIRECT_FROM_A_OPTIONAL +# error "DEF_DIRECT_FROM_A_OPTIONAL incorrectly not defined" +#endif + +extern void static_A_public(void); +extern void not_direct_from_A(void); +extern void not_direct_from_A_for_exe(void); +extern void not_direct_from_A_optional(void); + +int main(void) +{ + static_A_public(); + not_direct_from_A(); + not_direct_from_A_for_exe(); + not_direct_from_A_optional(); + return 0; +} diff --git a/Tests/InterfaceLinkLibrariesDirect/main.c b/Tests/InterfaceLinkLibrariesDirect/main.c new file mode 100644 index 0000000..53f0e6d --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/main.c @@ -0,0 +1,5 @@ +extern int testStaticLibPlugin(void); +int main(void) +{ + return testStaticLibPlugin(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/order_A.c b/Tests/InterfaceLinkLibrariesDirect/order_A.c new file mode 100644 index 0000000..2cd4d60 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/order_A.c @@ -0,0 +1,5 @@ +extern void order_B(void); +void order_A(void) +{ + order_B(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/order_B.c b/Tests/InterfaceLinkLibrariesDirect/order_B.c new file mode 100644 index 0000000..1787f1d --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/order_B.c @@ -0,0 +1,5 @@ +extern void order_C(void); +void order_B(void) +{ + order_C(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/order_B_poison.c b/Tests/InterfaceLinkLibrariesDirect/order_B_poison.c new file mode 100644 index 0000000..bcb7b4b --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/order_B_poison.c @@ -0,0 +1,6 @@ +extern void order_B_poison(void); + +void order_A(void) +{ + order_B_poison(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/order_C.c b/Tests/InterfaceLinkLibrariesDirect/order_C.c new file mode 100644 index 0000000..e67e719 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/order_C.c @@ -0,0 +1,5 @@ +extern void order_D(void); +void order_C(void) +{ + order_D(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/order_C_poison.c b/Tests/InterfaceLinkLibrariesDirect/order_C_poison.c new file mode 100644 index 0000000..fc31104 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/order_C_poison.c @@ -0,0 +1,11 @@ +extern void order_C_poison(void); + +void order_A(void) +{ + order_C_poison(); +} + +void order_B(void) +{ + order_C_poison(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/order_D.c b/Tests/InterfaceLinkLibrariesDirect/order_D.c new file mode 100644 index 0000000..f5bb2d6 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/order_D.c @@ -0,0 +1,5 @@ +extern void order_E(void); +void order_D(void) +{ + order_E(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/order_D_poison.c b/Tests/InterfaceLinkLibrariesDirect/order_D_poison.c new file mode 100644 index 0000000..d2d64e6 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/order_D_poison.c @@ -0,0 +1,16 @@ +extern void order_D_poison(void); + +void order_A(void) +{ + order_D_poison(); +} + +void order_B(void) +{ + order_D_poison(); +} + +void order_C(void) +{ + order_D_poison(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/order_E.c b/Tests/InterfaceLinkLibrariesDirect/order_E.c new file mode 100644 index 0000000..2a56443 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/order_E.c @@ -0,0 +1,5 @@ +extern void order_F(void); +void order_E(void) +{ + order_F(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/order_E_poison.c b/Tests/InterfaceLinkLibrariesDirect/order_E_poison.c new file mode 100644 index 0000000..7d8b53e --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/order_E_poison.c @@ -0,0 +1,21 @@ +extern void order_E_poison(void); + +void order_A(void) +{ + order_E_poison(); +} + +void order_B(void) +{ + order_E_poison(); +} + +void order_C(void) +{ + order_E_poison(); +} + +void order_D(void) +{ + order_E_poison(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/order_F.c b/Tests/InterfaceLinkLibrariesDirect/order_F.c new file mode 100644 index 0000000..d242284 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/order_F.c @@ -0,0 +1,5 @@ +extern void order_G(void); +void order_F(void) +{ + order_G(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/order_F_poison.c b/Tests/InterfaceLinkLibrariesDirect/order_F_poison.c new file mode 100644 index 0000000..285f247 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/order_F_poison.c @@ -0,0 +1,26 @@ +extern void order_F_poison(void); + +void order_A(void) +{ + order_F_poison(); +} + +void order_B(void) +{ + order_F_poison(); +} + +void order_C(void) +{ + order_F_poison(); +} + +void order_D(void) +{ + order_F_poison(); +} + +void order_E(void) +{ + order_F_poison(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/order_G.c b/Tests/InterfaceLinkLibrariesDirect/order_G.c new file mode 100644 index 0000000..ff71038 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/order_G.c @@ -0,0 +1,5 @@ +extern void order_H(void); +void order_G(void) +{ + order_H(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/order_G_poison.c b/Tests/InterfaceLinkLibrariesDirect/order_G_poison.c new file mode 100644 index 0000000..3a1fe1d --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/order_G_poison.c @@ -0,0 +1,31 @@ +extern void order_G_poison(void); + +void order_A(void) +{ + order_G_poison(); +} + +void order_B(void) +{ + order_G_poison(); +} + +void order_C(void) +{ + order_G_poison(); +} + +void order_D(void) +{ + order_G_poison(); +} + +void order_E(void) +{ + order_G_poison(); +} + +void order_F(void) +{ + order_G_poison(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/order_H.c b/Tests/InterfaceLinkLibrariesDirect/order_H.c new file mode 100644 index 0000000..9c62bb1 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/order_H.c @@ -0,0 +1,5 @@ +extern void order_I(void); +void order_H(void) +{ + order_I(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/order_H_poison.c b/Tests/InterfaceLinkLibrariesDirect/order_H_poison.c new file mode 100644 index 0000000..0c6b84f --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/order_H_poison.c @@ -0,0 +1,36 @@ +extern void order_H_poison(void); + +void order_A(void) +{ + order_H_poison(); +} + +void order_B(void) +{ + order_H_poison(); +} + +void order_C(void) +{ + order_H_poison(); +} + +void order_D(void) +{ + order_H_poison(); +} + +void order_E(void) +{ + order_H_poison(); +} + +void order_F(void) +{ + order_H_poison(); +} + +void order_G(void) +{ + order_H_poison(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/order_I.c b/Tests/InterfaceLinkLibrariesDirect/order_I.c new file mode 100644 index 0000000..96152de --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/order_I.c @@ -0,0 +1,5 @@ +extern void order_J(void); +void order_I(void) +{ + order_J(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/order_I_poison.c b/Tests/InterfaceLinkLibrariesDirect/order_I_poison.c new file mode 100644 index 0000000..3fabe1f --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/order_I_poison.c @@ -0,0 +1,41 @@ +extern void order_I_poison(void); + +void order_A(void) +{ + order_I_poison(); +} + +void order_B(void) +{ + order_I_poison(); +} + +void order_C(void) +{ + order_I_poison(); +} + +void order_D(void) +{ + order_I_poison(); +} + +void order_E(void) +{ + order_I_poison(); +} + +void order_F(void) +{ + order_I_poison(); +} + +void order_G(void) +{ + order_I_poison(); +} + +void order_H(void) +{ + order_I_poison(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/order_J.c b/Tests/InterfaceLinkLibrariesDirect/order_J.c new file mode 100644 index 0000000..49eec47 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/order_J.c @@ -0,0 +1,3 @@ +void order_J(void) +{ +} diff --git a/Tests/InterfaceLinkLibrariesDirect/order_J_poison.c b/Tests/InterfaceLinkLibrariesDirect/order_J_poison.c new file mode 100644 index 0000000..9724fd5 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/order_J_poison.c @@ -0,0 +1,46 @@ +extern void order_J_poison(void); + +void order_A(void) +{ + order_J_poison(); +} + +void order_B(void) +{ + order_J_poison(); +} + +void order_C(void) +{ + order_J_poison(); +} + +void order_D(void) +{ + order_J_poison(); +} + +void order_E(void) +{ + order_J_poison(); +} + +void order_F(void) +{ + order_J_poison(); +} + +void order_G(void) +{ + order_J_poison(); +} + +void order_H(void) +{ + order_J_poison(); +} + +void order_I(void) +{ + order_J_poison(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/order_main.c b/Tests/InterfaceLinkLibrariesDirect/order_main.c new file mode 100644 index 0000000..eed2453 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/order_main.c @@ -0,0 +1,6 @@ +extern void order_A(void); +int main(void) +{ + order_A(); + return 0; +} diff --git a/Tests/InterfaceLinkLibrariesDirect/static_A_private.c b/Tests/InterfaceLinkLibrariesDirect/static_A_private.c new file mode 100644 index 0000000..d98a22c --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/static_A_private.c @@ -0,0 +1,16 @@ +#ifndef DEF_DIRECT_FROM_A +# error "DEF_DIRECT_FROM_A incorrectly not defined" +#endif +#ifdef DEF_DIRECT_FROM_A_FOR_EXE +# error "DEF_DIRECT_FROM_A_FOR_EXE incorrectly defined" +#endif +#ifndef DEF_DIRECT_FROM_A_OPTIONAL +# error "DEF_DIRECT_FROM_A_OPTIONAL incorrectly not defined" +#endif + +extern void a_always(void); + +void static_A_private(void) +{ + a_always(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/static_A_public.c b/Tests/InterfaceLinkLibrariesDirect/static_A_public.c new file mode 100644 index 0000000..ed88ca6 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/static_A_public.c @@ -0,0 +1,16 @@ +#ifndef DEF_DIRECT_FROM_A +# error "DEF_DIRECT_FROM_A incorrectly not defined" +#endif +#ifdef DEF_DIRECT_FROM_A_FOR_EXE +# error "DEF_DIRECT_FROM_A_FOR_EXE incorrectly defined" +#endif +#ifdef DEF_DIRECT_FROM_A_OPTIONAL +# error "DEF_DIRECT_FROM_A_OPTIONAL incorrectly defined" +#endif + +extern void a_always(void); + +void static_A_public(void) +{ + a_always(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/testExePluginHelperObj.c b/Tests/InterfaceLinkLibrariesDirect/testExePluginHelperObj.c new file mode 100644 index 0000000..49c495f --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/testExePluginHelperObj.c @@ -0,0 +1,4 @@ +int testExePluginHelperObj(int n) +{ + return n; +} diff --git a/Tests/InterfaceLinkLibrariesDirect/testExeWithPluginHelper.c b/Tests/InterfaceLinkLibrariesDirect/testExeWithPluginHelper.c new file mode 100644 index 0000000..f8787db --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/testExeWithPluginHelper.c @@ -0,0 +1,12 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int testExePluginAPI(int n) +{ + return n; +} + +int main(void) +{ + return 0; +} diff --git a/Tests/InterfaceLinkLibrariesDirect/testExeWithPluginHelper.cmake b/Tests/InterfaceLinkLibrariesDirect/testExeWithPluginHelper.cmake new file mode 100644 index 0000000..97c5b65 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/testExeWithPluginHelper.cmake @@ -0,0 +1,7 @@ +# Logic common to InterfaceLinkLibrariesDirect and ExportImport tests. +set(src ${CMAKE_CURRENT_LIST_DIR}) +add_executable(testExeWithPluginHelper ${src}/testExeWithPluginHelper.c) +add_library(testExePluginHelperObj OBJECT ${src}/testExePluginHelperObj.c) +set_property(TARGET testExeWithPluginHelper PROPERTY ENABLE_EXPORTS 1) +set_property(TARGET testExeWithPluginHelper PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT $<TARGET_NAME:testExePluginHelperObj>) +set_property(TARGET testExeWithPluginHelper PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE $<1:testExePluginHelperExclude>) diff --git a/Tests/InterfaceLinkLibrariesDirect/testSharedLibHelperObj.c b/Tests/InterfaceLinkLibrariesDirect/testSharedLibHelperObj.c new file mode 100644 index 0000000..9d55fcb --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/testSharedLibHelperObj.c @@ -0,0 +1,4 @@ +int testSharedLibHelperObj(int n) +{ + return n; +} diff --git a/Tests/InterfaceLinkLibrariesDirect/testSharedLibWithHelper.c b/Tests/InterfaceLinkLibrariesDirect/testSharedLibWithHelper.c new file mode 100644 index 0000000..f942b54 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/testSharedLibWithHelper.c @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int testSharedLibWithHelper(int n) +{ + return n; +} diff --git a/Tests/InterfaceLinkLibrariesDirect/testSharedLibWithHelper.cmake b/Tests/InterfaceLinkLibrariesDirect/testSharedLibWithHelper.cmake new file mode 100644 index 0000000..c51751c --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/testSharedLibWithHelper.cmake @@ -0,0 +1,6 @@ +# Logic common to InterfaceLinkLibrariesDirect and ExportImport tests. +set(src ${CMAKE_CURRENT_LIST_DIR}) +add_library(testSharedLibWithHelper SHARED ${src}/testSharedLibWithHelper.c) +add_library(testSharedLibHelperObj OBJECT ${src}/testSharedLibHelperObj.c) +set_property(TARGET testSharedLibWithHelper PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT $<TARGET_NAME:testSharedLibHelperObj>) +set_property(TARGET testSharedLibWithHelper PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE $<1:testSharedLibHelperExclude>) diff --git a/Tests/InterfaceLinkLibrariesDirect/testStaticLibPlugin.c b/Tests/InterfaceLinkLibrariesDirect/testStaticLibPlugin.c new file mode 100644 index 0000000..17f643f --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/testStaticLibPlugin.c @@ -0,0 +1,6 @@ +extern int testStaticLibWithPlugin1(void); +extern int testStaticLibPluginExtra(void); +int testStaticLibPlugin(void) +{ + return testStaticLibWithPlugin1() + testStaticLibPluginExtra(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/testStaticLibPlugin.cmake b/Tests/InterfaceLinkLibrariesDirect/testStaticLibPlugin.cmake new file mode 100644 index 0000000..907872f --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/testStaticLibPlugin.cmake @@ -0,0 +1,14 @@ +# Logic common to InterfaceLinkLibrariesDirect and ExportImport tests. +set(src ${CMAKE_CURRENT_LIST_DIR}) +add_library(testStaticLibWithPlugin STATIC + ${src}/testStaticLibWithPlugin1.c # used by testStaticLibPlugin + ${src}/testStaticLibWithPlugin2.c # used by testStaticLibPluginExtra + ${src}/testStaticLibWithPluginBad1.c # link error if not after testStaticLibPlugin + ${src}/testStaticLibWithPluginBad2.c # link error if not after testStaticLibPluginExtra + ) +add_library(testStaticLibPluginExtra STATIC ${src}/testStaticLibPluginExtra.c) +add_library(testStaticLibPlugin STATIC ${src}/testStaticLibPlugin.c) +target_link_libraries(testStaticLibPlugin PUBLIC testStaticLibWithPlugin testStaticLibPluginExtra) +target_link_libraries(testStaticLibPluginExtra PUBLIC testStaticLibWithPlugin) +set_property(TARGET testStaticLibWithPlugin PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT testStaticLibPlugin) +set_property(TARGET testStaticLibWithPlugin PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE testStaticLibWithPlugin) diff --git a/Tests/InterfaceLinkLibrariesDirect/testStaticLibPluginExtra.c b/Tests/InterfaceLinkLibrariesDirect/testStaticLibPluginExtra.c new file mode 100644 index 0000000..11fe0f8 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/testStaticLibPluginExtra.c @@ -0,0 +1,5 @@ +extern int testStaticLibWithPlugin2(void); +int testStaticLibPluginExtra(void) +{ + return testStaticLibWithPlugin2(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/testStaticLibWithPlugin1.c b/Tests/InterfaceLinkLibrariesDirect/testStaticLibWithPlugin1.c new file mode 100644 index 0000000..5e75dce --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/testStaticLibWithPlugin1.c @@ -0,0 +1,4 @@ +int testStaticLibWithPlugin1(void) +{ + return 0; +} diff --git a/Tests/InterfaceLinkLibrariesDirect/testStaticLibWithPlugin2.c b/Tests/InterfaceLinkLibrariesDirect/testStaticLibWithPlugin2.c new file mode 100644 index 0000000..74ac1ae --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/testStaticLibWithPlugin2.c @@ -0,0 +1,4 @@ +int testStaticLibWithPlugin2(void) +{ + return 0; +} diff --git a/Tests/InterfaceLinkLibrariesDirect/testStaticLibWithPluginBad1.c b/Tests/InterfaceLinkLibrariesDirect/testStaticLibWithPluginBad1.c new file mode 100644 index 0000000..b41abc9 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/testStaticLibWithPluginBad1.c @@ -0,0 +1,6 @@ +/* Produce an error if if the object compiled from this source is used. */ +extern int testStaticLibWithPlugin_linked_before_testStaticLibPlugin(void); +int testStaticLibPlugin(void) +{ + return testStaticLibWithPlugin_linked_before_testStaticLibPlugin(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/testStaticLibWithPluginBad2.c b/Tests/InterfaceLinkLibrariesDirect/testStaticLibWithPluginBad2.c new file mode 100644 index 0000000..43337a5 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/testStaticLibWithPluginBad2.c @@ -0,0 +1,7 @@ +/* Produce an error if if the object compiled from this source is used. */ +extern int testStaticLibWithPlugin_linked_before_testStaticLibPluginExtra( + void); +int testStaticLibPluginExtra(void) +{ + return testStaticLibWithPlugin_linked_before_testStaticLibPluginExtra(); +} diff --git a/Tests/ObjectLibrary/Transitive/BarMain.c b/Tests/ObjectLibrary/Transitive/BarMain.c new file mode 100644 index 0000000..aec3e48 --- /dev/null +++ b/Tests/ObjectLibrary/Transitive/BarMain.c @@ -0,0 +1,6 @@ +extern int BarObject1(void); + +int main(void) +{ + return BarObject1(); +} diff --git a/Tests/ObjectLibrary/Transitive/BarObject1.c b/Tests/ObjectLibrary/Transitive/BarObject1.c new file mode 100644 index 0000000..2f68386 --- /dev/null +++ b/Tests/ObjectLibrary/Transitive/BarObject1.c @@ -0,0 +1,5 @@ +extern int BarObject2(void); +int BarObject1(void) +{ + return BarObject2(); +} diff --git a/Tests/ObjectLibrary/Transitive/BarObject2.c b/Tests/ObjectLibrary/Transitive/BarObject2.c new file mode 100644 index 0000000..881c64a --- /dev/null +++ b/Tests/ObjectLibrary/Transitive/BarObject2.c @@ -0,0 +1,5 @@ +extern int BarObject3(void); +int BarObject2(void) +{ + return BarObject3(); +} diff --git a/Tests/ObjectLibrary/Transitive/BarObject3.c b/Tests/ObjectLibrary/Transitive/BarObject3.c new file mode 100644 index 0000000..e557dbc --- /dev/null +++ b/Tests/ObjectLibrary/Transitive/BarObject3.c @@ -0,0 +1,4 @@ +int BarObject3(void) +{ + return 0; +} diff --git a/Tests/ObjectLibrary/Transitive/CMakeLists.txt b/Tests/ObjectLibrary/Transitive/CMakeLists.txt index e9f57d4..17247eb 100644 --- a/Tests/ObjectLibrary/Transitive/CMakeLists.txt +++ b/Tests/ObjectLibrary/Transitive/CMakeLists.txt @@ -9,3 +9,17 @@ add_library(FooObject2 OBJECT FooObject.c) target_link_libraries(FooObject2 INTERFACE FooStatic) add_executable(Transitive2 Transitive.c) target_link_libraries(Transitive2 PRIVATE FooObject2) + +add_library(FooObjectDirect OBJECT FooObject.c) +add_library(FooStaticDirect STATIC FooStatic.c) +set_property(TARGET FooStaticDirect PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT FooObjectDirect) +add_executable(TransitiveDirect Transitive.c) +target_link_libraries(TransitiveDirect PRIVATE FooStaticDirect) + +add_library(BarObject1 OBJECT BarObject1.c) +add_library(BarObject2 OBJECT BarObject2.c) +add_library(BarObject3 OBJECT BarObject3.c) +set_property(TARGET BarObject1 PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT BarObject2) +set_property(TARGET BarObject2 PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT BarObject3) +add_executable(BarMain BarMain.c) +target_link_libraries(BarMain PRIVATE BarObject1) diff --git a/Tests/QtAutogen/MocInclude/CMakeLists.txt b/Tests/QtAutogen/MocInclude/CMakeLists.txt index 4224d2f..c62128b 100644 --- a/Tests/QtAutogen/MocInclude/CMakeLists.txt +++ b/Tests/QtAutogen/MocInclude/CMakeLists.txt @@ -1,7 +1,9 @@ cmake_minimum_required(VERSION 3.16) project(MocInclude) -get_filename_component(CS_REAL ${CMAKE_CURRENT_SOURCE_DIR} REALPATH) -include("${CS_REAL}/../AutogenCoreTest.cmake") +if (NOT DEFINED AUTOGEN_CORE_TEST_CMAKE) + get_filename_component(AUTOGEN_CORE_TEST_CMAKE "../AutogenCoreTest.cmake" ABSOLUTE) +endif() +include("${AUTOGEN_CORE_TEST_CMAKE}") # Test moc include patterns diff --git a/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt b/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt index c28616b..cf60555 100644 --- a/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt +++ b/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.16) project(MocIncludeSymlink) -include("../AutogenCoreTest.cmake") +get_filename_component(AUTOGEN_CORE_TEST_CMAKE "../AutogenCoreTest.cmake" ABSOLUTE) +include("${AUTOGEN_CORE_TEST_CMAKE}") # # Tests if MocInclude can be build when @@ -65,6 +66,7 @@ macro(buildMocInclude sourceDir binaryDir) "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" "-DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH}" "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" + "-DAUTOGEN_CORE_TEST_CMAKE:STRING=${AUTOGEN_CORE_TEST_CMAKE}" OUTPUT_VARIABLE output ) if (result) diff --git a/Tests/RunCMake/CMP0132/CMP0132-Common.cmake b/Tests/RunCMake/CMP0132/CMP0132-Common.cmake new file mode 100644 index 0000000..796f61c --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMP0132-Common.cmake @@ -0,0 +1,15 @@ +if(NOT "$ENV{CC}" STREQUAL "") + message(STATUS "Test environment already sets CC, test being SKIPPED") + return() +elseif(CMAKE_GENERATOR MATCHES "Xcode|Visual Studio") + message(STATUS "This generator never sets CC, test being SKIPPED") + return() +endif() + +enable_language(C) + +if("$ENV{CC}" STREQUAL "") + message(STATUS "CC was left unset") +else() + message(STATUS "CC was set to $ENV{CC}") +endif() diff --git a/Tests/RunCMake/CMP0132/CMP0132-NEW-stdout.txt b/Tests/RunCMake/CMP0132/CMP0132-NEW-stdout.txt new file mode 100644 index 0000000..8056c2c --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMP0132-NEW-stdout.txt @@ -0,0 +1 @@ +SKIPPED|CC was left unset diff --git a/Tests/RunCMake/CMP0132/CMP0132-NEW.cmake b/Tests/RunCMake/CMP0132/CMP0132-NEW.cmake new file mode 100644 index 0000000..fabb419 --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMP0132-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0132 NEW) +include(CMP0132-Common.cmake) diff --git a/Tests/RunCMake/CMP0132/CMP0132-OLD-stdout.txt b/Tests/RunCMake/CMP0132/CMP0132-OLD-stdout.txt new file mode 100644 index 0000000..c131428 --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMP0132-OLD-stdout.txt @@ -0,0 +1 @@ +SKIPPED|CC was set diff --git a/Tests/RunCMake/CMP0132/CMP0132-OLD.cmake b/Tests/RunCMake/CMP0132/CMP0132-OLD.cmake new file mode 100644 index 0000000..aae4f2a --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMP0132-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0132 OLD) +include(CMP0132-Common.cmake) diff --git a/Tests/RunCMake/CMP0132/CMP0132-WARN-stdout.txt b/Tests/RunCMake/CMP0132/CMP0132-WARN-stdout.txt new file mode 100644 index 0000000..c131428 --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMP0132-WARN-stdout.txt @@ -0,0 +1 @@ +SKIPPED|CC was set diff --git a/Tests/RunCMake/CMP0132/CMP0132-WARN.cmake b/Tests/RunCMake/CMP0132/CMP0132-WARN.cmake new file mode 100644 index 0000000..c07e5db --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMP0132-WARN.cmake @@ -0,0 +1,2 @@ + +include(CMP0132-Common.cmake) diff --git a/Tests/RunCMake/CMP0132/CMakeLists.txt b/Tests/RunCMake/CMP0132/CMakeLists.txt new file mode 100644 index 0000000..5ff8d3e --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.23) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0132/RunCMakeTest.cmake b/Tests/RunCMake/CMP0132/RunCMakeTest.cmake new file mode 100644 index 0000000..db599ce --- /dev/null +++ b/Tests/RunCMake/CMP0132/RunCMakeTest.cmake @@ -0,0 +1,7 @@ +include(RunCMake) + +if(NOT CMAKE_GENERATOR_NO_COMPILER_ENV) + run_cmake(CMP0132-WARN) + run_cmake(CMP0132-OLD) + run_cmake(CMP0132-NEW) +endif() diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index e97b7dc..dbff293 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -142,6 +142,14 @@ if (CMAKE_SYSTEM_NAME MATCHES "(Linux|Darwin)") endif() add_RunCMake_test(CMP0126) +if("${CMAKE_C_COMPILER_ID}" STREQUAL "LCC" OR + "${CMAKE_CXX_COMPILER_ID}" STREQUAL "LCC" OR + "${CMAKE_Fortran_COMPILER_ID}" STREQUAL "LCC") + add_RunCMake_test("CMP0129") +endif() + +add_RunCMake_test(CMP0132) + # The test for Policy 65 requires the use of the # CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS variable, which both the VS and Xcode # generators ignore. The policy will have no effect on those generators. @@ -278,6 +286,9 @@ endif() add_RunCMake_test(CMakeDependentOption) add_RunCMake_test(CMakeRoleGlobalProperty) add_RunCMake_test(CMakeRelease -DCMake_TEST_JQ=${CMake_TEST_JQ}) +if(CMAKE_GENERATOR MATCHES "Make|Ninja") + add_RunCMake_test(Color) +endif() if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja") add_RunCMake_test(CompilerChange) endif() @@ -313,6 +324,8 @@ add_RunCMake_test(GenEx-LINK_LANGUAGE) add_RunCMake_test(GenEx-LINK_LANG_AND_ID) add_RunCMake_test(GenEx-HOST_LINK) add_RunCMake_test(GenEx-DEVICE_LINK) +add_RunCMake_test(GenEx-LINK_LIBRARY) +add_RunCMake_test(GenEx-LINK_GROUP) add_RunCMake_test(GenEx-TARGET_FILE -DLINKER_SUPPORTS_PDB=${LINKER_SUPPORTS_PDB}) add_RunCMake_test(GenEx-GENEX_EVAL) add_RunCMake_test(GenEx-TARGET_RUNTIME_DLLS) @@ -657,6 +670,30 @@ add_RunCMake_test(target_link_libraries) add_RunCMake_test(target_link_libraries-ALIAS) add_RunCMake_test(target_link_libraries-LINK_LANGUAGE) add_RunCMake_test(target_link_libraries-LINK_LANG_AND_ID) +add_RunCMake_test(target_link_libraries-LINK_LIBRARY -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} + -DMINGW=${MINGW} + -DMSYS=${MSYS} + -DCYGWIN=${CYGWIN} + -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} + -DCMAKE_C_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION} + -DMSVC_VERSION=${MSVC_VERSION} + -DCMAKE_SHARED_LIBRARY_PREFIX=${CMAKE_SHARED_LIBRARY_PREFIX} + -DCMAKE_SHARED_LIBRARY_SUFFIX=${CMAKE_SHARED_LIBRARY_SUFFIX} + -DCMAKE_IMPORT_LIBRARY_PREFIX=${CMAKE_IMPORT_LIBRARY_PREFIX} + -DCMAKE_IMPORT_LIBRARY_SUFFIX=${CMAKE_IMPORT_LIBRARY_SUFFIX} + -DCMAKE_LINK_LIBRARY_FLAG=${CMAKE_LINK_LIBRARY_FLAG}) +add_RunCMake_test(target_link_libraries-LINK_GROUP -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} + -DMINGW=${MINGW} + -DMSYS=${MSYS} + -DCYGWIN=${CYGWIN} + -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} + -DCMAKE_C_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION} + -DMSVC_VERSION=${MSVC_VERSION} + -DCMAKE_SHARED_LIBRARY_PREFIX=${CMAKE_SHARED_LIBRARY_PREFIX} + -DCMAKE_SHARED_LIBRARY_SUFFIX=${CMAKE_SHARED_LIBRARY_SUFFIX} + -DCMAKE_IMPORT_LIBRARY_PREFIX=${CMAKE_IMPORT_LIBRARY_PREFIX} + -DCMAKE_IMPORT_LIBRARY_SUFFIX=${CMAKE_IMPORT_LIBRARY_SUFFIX} + -DCMAKE_LINK_LIBRARY_FLAG=${CMAKE_LINK_LIBRARY_FLAG}) add_RunCMake_test(add_link_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}) add_RunCMake_test(target_link_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} -DCMake_TEST_CUDA=${CMake_TEST_CUDA}) @@ -708,7 +745,8 @@ endif() add_executable(pseudo_llvm-rc pseudo_llvm-rc.c) add_RunCMake_test(CommandLine -DLLVM_RC=$<TARGET_FILE:pseudo_llvm-rc> -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} - -DCYGWIN=${CYGWIN} -DMSYS=${MSYS} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}) + -DCYGWIN=${CYGWIN} -DMSYS=${MSYS} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} + -DEXIT_CODE_EXE=$<TARGET_FILE:exit_code>) add_RunCMake_test(CommandLineTar) if(CMAKE_PLATFORM_NO_VERSIONED_SONAME OR (NOT CMAKE_SHARED_LIBRARY_SONAME_FLAG AND NOT CMAKE_SHARED_LIBRARY_SONAME_C_FLAG)) @@ -738,6 +776,9 @@ add_RunCMake_test(CPackInstallProperties) if(XCODE_VERSION) set(ExternalProject_ARGS -DXCODE_VERSION=${XCODE_VERSION}) endif() +if(CMake_TEST_RunCMake_ExternalProject_DOWNLOAD_SERVER_TIMEOUT) + list(APPEND ExternalProject_ARGS -DDOWNLOAD_SERVER_TIMEOUT=${CMake_TEST_RunCMake_ExternalProject_DOWNLOAD_SERVER_TIMEOUT}) +endif() add_RunCMake_test(ExternalProject) add_RunCMake_test(FetchContent) set(CTestCommandLine_ARGS -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}) @@ -770,6 +811,7 @@ if(CMake_TEST_FindMatlab OR CMake_TEST_FindMatlab_MCR OR (NOT "${CMake_TEST_Find endif() add_RunCMake_test(FindMatlab ${FindMatlab_additional_test_options}) + set_property(TEST RunCMake.FindMatlab APPEND PROPERTY LABELS "Matlab") endif() add_executable(pseudo_emulator pseudo_emulator.c) @@ -936,6 +978,8 @@ add_RunCMake_test(CMakePresetsTest -DCMake_TEST_JSON_SCHEMA=${CMake_TEST_JSON_SCHEMA} ) +add_RunCMake_test(VerifyHeaderSets) + if(${CMAKE_GENERATOR} MATCHES "Make|Ninja") add_RunCMake_test(TransformDepfile) endif() @@ -943,7 +987,3 @@ endif() if(WIN32) add_RunCMake_test(Win32GenEx) endif() - -if("${CMAKE_C_COMPILER_ID}" STREQUAL "LCC" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "LCC" OR "${CMAKE_Fortran_COMPILER_ID}" STREQUAL "LCC") - add_RunCMake_test("CMP0129") -endif() diff --git a/Tests/RunCMake/CMakePresets/IncludeOutsideProjectInclude.json b/Tests/RunCMake/CMakePresets/IncludeOutsideProjectInclude.json index f13e55c..ebf106f 100644 --- a/Tests/RunCMake/CMakePresets/IncludeOutsideProjectInclude.json +++ b/Tests/RunCMake/CMakePresets/IncludeOutsideProjectInclude.json @@ -1,3 +1,3 @@ { - "version": 4 + "version": 5 } diff --git a/Tests/RunCMake/CMakePresetsBuild/Good.json.in b/Tests/RunCMake/CMakePresetsBuild/Good.json.in index 568907c..a953f48 100644 --- a/Tests/RunCMake/CMakePresetsBuild/Good.json.in +++ b/Tests/RunCMake/CMakePresetsBuild/Good.json.in @@ -1,5 +1,5 @@ { - "version": 4, + "version": 5, "configurePresets": [ { "name": "default", diff --git a/Tests/RunCMake/CMakePresetsTest/Good.json.in b/Tests/RunCMake/CMakePresetsTest/Good.json.in index 57be5a5..d484a19 100644 --- a/Tests/RunCMake/CMakePresetsTest/Good.json.in +++ b/Tests/RunCMake/CMakePresetsTest/Good.json.in @@ -1,5 +1,5 @@ { - "version": 2, + "version": 5, "configurePresets": [ { "name": "default", @@ -48,7 +48,8 @@ "quiet": false, "outputLogFile": "", "labelSummary": true, - "subprojectSummary": true + "subprojectSummary": true, + "testOutputTruncation": "tail" }, "filter": { "include": { diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake index 7da95a2..6835834 100644 --- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake @@ -274,6 +274,27 @@ function(run_TestOutputSize) endfunction() run_TestOutputSize() +# Test --test-output-truncation +function(run_TestOutputTruncation mode expected) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TestOutputTruncation_${mode}) + set(RunCMake_TEST_NO_CLEAN 1) + set(TRUNCATED_OUTPUT ${expected}) # used in TestOutputTruncation-check.cmake + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" " + add_test(Truncation_${mode} \"${CMAKE_COMMAND}\" -E echo 123456789) +") + run_cmake_command(TestOutputTruncation + ${CMAKE_CTEST_COMMAND} -M Experimental -T Test + --no-compress-output + --test-output-size-passed 5 + --test-output-truncation ${mode} + ) +endfunction() +run_TestOutputTruncation("head" "\\.\\.\\.6789") +run_TestOutputTruncation("middle" "12\\.\\.\\..*\\.\\.\\.89") +run_TestOutputTruncation("tail" "12345\\.\\.\\.") + # Test --stop-on-failure function(run_stop_on_failure) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/stop-on-failure) diff --git a/Tests/RunCMake/CTestCommandLine/TestOutputTruncation-check.cmake b/Tests/RunCMake/CTestCommandLine/TestOutputTruncation-check.cmake new file mode 100644 index 0000000..5769c9f --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/TestOutputTruncation-check.cmake @@ -0,0 +1,12 @@ +file(GLOB test_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Test.xml") +if(test_xml_file) + file(READ "${test_xml_file}" test_xml LIMIT 4096) + if("${test_xml}" MATCHES [[(<Test Status="passed">.*</Test>)]]) + set(test_result "${CMAKE_MATCH_1}") + endif() + if(NOT "${test_result}" MATCHES "<Value>.*${TRUNCATED_OUTPUT}.*</Value>") + set(RunCMake_TEST_FAILED "Test output truncation failed:\n ${test_result}\nExpected: ${TRUNCATED_OUTPUT}") + endif() +else() + set(RunCMake_TEST_FAILED "Test.xml not found") +endif() diff --git a/Tests/RunCMake/CTestCommandLine/TestOutputTruncation-stderr.txt b/Tests/RunCMake/CTestCommandLine/TestOutputTruncation-stderr.txt new file mode 100644 index 0000000..30b46ce --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/TestOutputTruncation-stderr.txt @@ -0,0 +1 @@ +^Cannot find file: .*/Tests/RunCMake/CTestCommandLine/TestOutputTruncation.*/DartConfiguration.tcl diff --git a/Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake b/Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake index 6fecae7..e37d025 100644 --- a/Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake +++ b/Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake @@ -2,6 +2,7 @@ include(RunCMake) run_cmake(architectures-all) run_cmake(architectures-all-major) +run_cmake(architectures-native) run_cmake(architectures-empty) run_cmake(architectures-invalid) diff --git a/Tests/RunCMake/CUDA_architectures/architectures-all-major-stdout.txt b/Tests/RunCMake/CUDA_architectures/architectures-all-major-stdout.txt index c5cde8f..ee0a5f7 100644 --- a/Tests/RunCMake/CUDA_architectures/architectures-all-major-stdout.txt +++ b/Tests/RunCMake/CUDA_architectures/architectures-all-major-stdout.txt @@ -1,3 +1,4 @@ -- CMAKE_CUDA_ARCHITECTURES='all-major' -- CMAKE_CUDA_ARCHITECTURES_ALL='[0-9;]+' -- CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR='[0-9;]+' +-- CMAKE_CUDA_ARCHITECTURES_NATIVE='[0-9;]+' diff --git a/Tests/RunCMake/CUDA_architectures/architectures-all-major.cmake b/Tests/RunCMake/CUDA_architectures/architectures-all-major.cmake index 5112473..7203c98 100644 --- a/Tests/RunCMake/CUDA_architectures/architectures-all-major.cmake +++ b/Tests/RunCMake/CUDA_architectures/architectures-all-major.cmake @@ -3,3 +3,4 @@ enable_language(CUDA) message(STATUS "CMAKE_CUDA_ARCHITECTURES='${CMAKE_CUDA_ARCHITECTURES}'") message(STATUS "CMAKE_CUDA_ARCHITECTURES_ALL='${CMAKE_CUDA_ARCHITECTURES_ALL}'") message(STATUS "CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR='${CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR}'") +message(STATUS "CMAKE_CUDA_ARCHITECTURES_NATIVE='${CMAKE_CUDA_ARCHITECTURES_NATIVE}'") diff --git a/Tests/RunCMake/CUDA_architectures/architectures-all-stdout.txt b/Tests/RunCMake/CUDA_architectures/architectures-all-stdout.txt index aba26b9..fd738e4 100644 --- a/Tests/RunCMake/CUDA_architectures/architectures-all-stdout.txt +++ b/Tests/RunCMake/CUDA_architectures/architectures-all-stdout.txt @@ -1,3 +1,4 @@ -- CMAKE_CUDA_ARCHITECTURES='all' -- CMAKE_CUDA_ARCHITECTURES_ALL='[0-9;]+' -- CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR='[0-9;]+' +-- CMAKE_CUDA_ARCHITECTURES_NATIVE='[0-9;]+' diff --git a/Tests/RunCMake/CUDA_architectures/architectures-all.cmake b/Tests/RunCMake/CUDA_architectures/architectures-all.cmake index 32175f6..0c3a4e9 100644 --- a/Tests/RunCMake/CUDA_architectures/architectures-all.cmake +++ b/Tests/RunCMake/CUDA_architectures/architectures-all.cmake @@ -3,3 +3,4 @@ enable_language(CUDA) message(STATUS "CMAKE_CUDA_ARCHITECTURES='${CMAKE_CUDA_ARCHITECTURES}'") message(STATUS "CMAKE_CUDA_ARCHITECTURES_ALL='${CMAKE_CUDA_ARCHITECTURES_ALL}'") message(STATUS "CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR='${CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR}'") +message(STATUS "CMAKE_CUDA_ARCHITECTURES_NATIVE='${CMAKE_CUDA_ARCHITECTURES_NATIVE}'") diff --git a/Tests/RunCMake/CUDA_architectures/architectures-native-stdout.txt b/Tests/RunCMake/CUDA_architectures/architectures-native-stdout.txt new file mode 100644 index 0000000..af49e00 --- /dev/null +++ b/Tests/RunCMake/CUDA_architectures/architectures-native-stdout.txt @@ -0,0 +1,4 @@ +-- CMAKE_CUDA_ARCHITECTURES='native' +-- CMAKE_CUDA_ARCHITECTURES_ALL='[0-9;]+' +-- CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR='[0-9;]+' +-- CMAKE_CUDA_ARCHITECTURES_NATIVE='[0-9;]+' diff --git a/Tests/RunCMake/CUDA_architectures/architectures-native.cmake b/Tests/RunCMake/CUDA_architectures/architectures-native.cmake new file mode 100644 index 0000000..64afe13 --- /dev/null +++ b/Tests/RunCMake/CUDA_architectures/architectures-native.cmake @@ -0,0 +1,6 @@ +set(CMAKE_CUDA_ARCHITECTURES "native") +enable_language(CUDA) +message(STATUS "CMAKE_CUDA_ARCHITECTURES='${CMAKE_CUDA_ARCHITECTURES}'") +message(STATUS "CMAKE_CUDA_ARCHITECTURES_ALL='${CMAKE_CUDA_ARCHITECTURES_ALL}'") +message(STATUS "CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR='${CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR}'") +message(STATUS "CMAKE_CUDA_ARCHITECTURES_NATIVE='${CMAKE_CUDA_ARCHITECTURES_NATIVE}'") diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake index 79d67e5..276158c 100644 --- a/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake +++ b/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake @@ -4,6 +4,10 @@ include(CheckCompilerFlag) set(C 1) # test that this is tolerated +# test that the check uses an isolated locale +set(_env_LC_ALL "${LC_ALL}") +set(ENV{LC_ALL} "BAD") + check_compiler_flag(C "-_this_is_not_a_flag_" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "invalid C compile flag didn't fail.") @@ -22,3 +26,8 @@ if(CMAKE_C_COMPILER_ID STREQUAL "GNU") # LCC C compiler silently ignore -frtti i message(SEND_ERROR "${CMAKE_C_COMPILER_ID} compiler flag '-frtti' check passed but should have failed") endif() endif() + +if(NOT "$ENV{LC_ALL}" STREQUAL "BAD") + message(SEND_ERROR "ENV{LC_ALL} was not preserved by check_compiler_flag") +endif() +set(ENV{LC_ALL} ${_env_LC_ALL}) diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckCXXCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCXXCompilerFlag.cmake index 4b20ebd..dec31ec 100644 --- a/Tests/RunCMake/CheckCompilerFlag/CheckCXXCompilerFlag.cmake +++ b/Tests/RunCMake/CheckCompilerFlag/CheckCXXCompilerFlag.cmake @@ -4,6 +4,10 @@ include(CheckCompilerFlag) set(CXX 1) # test that this is tolerated +# test that the check uses an isolated locale +set(_env_LC_ALL "${LC_ALL}") +set(ENV{LC_ALL} "BAD") + check_compiler_flag(CXX "-_this_is_not_a_flag_" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "invalid CXX compile flag didn't fail.") @@ -15,3 +19,8 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|LCC|Clang" AND NOT "x${CMAKE_CXX_SIMULATE_ message(SEND_ERROR "${CMAKE_CXX_COMPILER_ID} compiler flag '-x c++' check failed") endif() endif() + +if(NOT "$ENV{LC_ALL}" STREQUAL "BAD") + message(SEND_ERROR "ENV{LC_ALL} was not preserved by check_compiler_flag") +endif() +set(ENV{LC_ALL} ${_env_LC_ALL}) diff --git a/Tests/RunCMake/CheckCompilerFlag/HeaderpadWorkaround.cmake b/Tests/RunCMake/CheckCompilerFlag/HeaderpadWorkaround.cmake new file mode 100644 index 0000000..128f9db --- /dev/null +++ b/Tests/RunCMake/CheckCompilerFlag/HeaderpadWorkaround.cmake @@ -0,0 +1,18 @@ +enable_language(C) + +include(CheckCompilerFlag) + +# Confirm we can check the conflicting flag directly. This should pass with +# or without the workaround. +check_compiler_flag(C "-fembed-bitcode" result1) +if(NOT result1) + message(FATAL_ERROR "False negative when -fembed-bitcode tested directly") +endif() + +# Check conflicting flag set by user or project won't cause a false negative +# when testing a valid flag. This only passes with the workaround. +set(CMAKE_C_FLAGS -fembed-bitcode) +check_compiler_flag(C "-O" result2) +if(NOT result2) + message(FATAL_ERROR "False negative when -fembed-bitcode set in CMAKE_C_FLAGS") +endif() diff --git a/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake b/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake index 7ef1860..df2b667 100644 --- a/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake +++ b/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake @@ -26,3 +26,7 @@ endif() if(CMake_TEST_HIP) run_cmake(CheckHIPCompilerFlag) endif() + +if(APPLE) + run_cmake_with_options(HeaderpadWorkaround --debug-trycompile) +endif() diff --git a/Tests/RunCMake/Color/CMakeLists.txt b/Tests/RunCMake/Color/CMakeLists.txt new file mode 100644 index 0000000..5ff8d3e --- /dev/null +++ b/Tests/RunCMake/Color/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.23) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/Color/DiagCommon.cmake b/Tests/RunCMake/Color/DiagCommon.cmake new file mode 100644 index 0000000..9a69317 --- /dev/null +++ b/Tests/RunCMake/Color/DiagCommon.cmake @@ -0,0 +1,9 @@ +enable_language(C) + +set(CMAKE_C_COMPILE_OPTIONS_COLOR_DIAGNOSTICS -DCOLOR_ON) +set(CMAKE_C_COMPILE_OPTIONS_COLOR_DIAGNOSTICS_OFF -DCOLOR_OFF) + +add_library(diag STATIC diag.c) +if(DEFINED EXPECT_COLOR) + target_compile_definitions(diag PRIVATE EXPECT_COLOR=${EXPECT_COLOR}) +endif() diff --git a/Tests/RunCMake/Color/DiagDefault.cmake b/Tests/RunCMake/Color/DiagDefault.cmake new file mode 100644 index 0000000..5add9dc --- /dev/null +++ b/Tests/RunCMake/Color/DiagDefault.cmake @@ -0,0 +1,8 @@ +include(DiagCommon.cmake) + +if(DEFINED CMAKE_COLOR_DIAGNOSTICS) + message(FATAL_ERROR "CMAKE_COLOR_DIAGNOSTICS incorrectly defined.") +endif() +if(CMAKE_GENERATOR MATCHES "Make" AND NOT DEFINED CMAKE_COLOR_MAKEFILE) + message(FATAL_ERROR "CMAKE_COLOR_MAKEFILE incorrectly not defined.") +endif() diff --git a/Tests/RunCMake/Color/DiagOff.cmake b/Tests/RunCMake/Color/DiagOff.cmake new file mode 100644 index 0000000..56657b0 --- /dev/null +++ b/Tests/RunCMake/Color/DiagOff.cmake @@ -0,0 +1,6 @@ +set(EXPECT_COLOR 0) +include(DiagCommon.cmake) + +if(DEFINED CMAKE_COLOR_MAKEFILE) + message(FATAL_ERROR "CMAKE_COLOR_MAKEFILE incorrectly defined.") +endif() diff --git a/Tests/RunCMake/Color/DiagOn.cmake b/Tests/RunCMake/Color/DiagOn.cmake new file mode 100644 index 0000000..fbb6c70 --- /dev/null +++ b/Tests/RunCMake/Color/DiagOn.cmake @@ -0,0 +1,6 @@ +set(EXPECT_COLOR 1) +include(DiagCommon.cmake) + +if(DEFINED CMAKE_COLOR_MAKEFILE) + message(FATAL_ERROR "CMAKE_COLOR_MAKEFILE incorrectly defined.") +endif() diff --git a/Tests/RunCMake/Color/RunCMakeTest.cmake b/Tests/RunCMake/Color/RunCMakeTest.cmake new file mode 100644 index 0000000..bb62d4c --- /dev/null +++ b/Tests/RunCMake/Color/RunCMakeTest.cmake @@ -0,0 +1,14 @@ +include(RunCMake) + +unset(ENV{CMAKE_COLOR_DIAGNOSTICS}) + +function(run_Diag case) + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/Diag${case}-build") + run_cmake_with_options(Diag${case} ${ARGN}) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(Diag${case}-build ${CMAKE_COMMAND} --build . --config Debug) +endfunction() + +run_Diag(On -DCMAKE_COLOR_DIAGNOSTICS=ON) +run_Diag(Off -DCMAKE_COLOR_DIAGNOSTICS=OFF) +run_Diag(Default) diff --git a/Tests/RunCMake/Color/diag.c b/Tests/RunCMake/Color/diag.c new file mode 100644 index 0000000..7ff8304 --- /dev/null +++ b/Tests/RunCMake/Color/diag.c @@ -0,0 +1,28 @@ +#ifdef EXPECT_COLOR +# if EXPECT_COLOR +# ifndef COLOR_ON +# error "COLOR_ON incorrectly not defined" +# endif +# ifdef COLOR_OFF +# error "COLOR_OFF incorrectly defined" +# endif +# else +# ifdef COLOR_ON +# error "COLOR_ON incorrectly defined" +# endif +# ifndef COLOR_OFF +# error "COLOR_OFF incorrectly not defined" +# endif +# endif +#else +# ifdef COLOR_ON +# error "COLOR_ON incorrectly defined" +# endif +# ifdef COLOR_OFF +# error "COLOR_OFF incorrectly defined" +# endif +#endif + +void diag(void) +{ +} diff --git a/Tests/RunCMake/CommandLine/E_cat-with-double-dash-stdout.txt b/Tests/RunCMake/CommandLine/E_cat-with-double-dash-stdout.txt new file mode 100644 index 0000000..e5939d0 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_cat-with-double-dash-stdout.txt @@ -0,0 +1 @@ +file starting with dash, not an option diff --git a/Tests/RunCMake/CommandLine/E_cat-without-double-dash-result.txt b/Tests/RunCMake/CommandLine/E_cat-without-double-dash-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_cat-without-double-dash-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_cat-without-double-dash-stderr.txt b/Tests/RunCMake/CommandLine/E_cat-without-double-dash-stderr.txt new file mode 100644 index 0000000..051f678 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_cat-without-double-dash-stderr.txt @@ -0,0 +1 @@ +^CMake Error: -file-starting-with-dash.txt: option not handled$ diff --git a/Tests/RunCMake/CommandLine/E_env-with-double-dash-result.txt b/Tests/RunCMake/CommandLine/E_env-with-double-dash-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_env-with-double-dash-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CommandLine/E_env-without-double-dash-result.txt b/Tests/RunCMake/CommandLine/E_env-without-double-dash-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_env-without-double-dash-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_env-without-double-dash-stderr.txt b/Tests/RunCMake/CommandLine/E_env-without-double-dash-stderr.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_env-without-double-dash-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/CommandLine/EnvColorDefault.cmake b/Tests/RunCMake/CommandLine/EnvColorDefault.cmake new file mode 100644 index 0000000..dc4bc98 --- /dev/null +++ b/Tests/RunCMake/CommandLine/EnvColorDefault.cmake @@ -0,0 +1,6 @@ +if(DEFINED CMAKE_COLOR_DIAGNOSTICS) + message(FATAL_ERROR "CMAKE_COLOR_DIAGNOSTICS incorrectly defined.") +endif() +if(CMAKE_GENERATOR MATCHES "Make" AND NOT DEFINED CMAKE_COLOR_MAKEFILE) + message(FATAL_ERROR "CMAKE_COLOR_MAKEFILE incorrectly not defined.") +endif() diff --git a/Tests/RunCMake/CommandLine/EnvColorOn-stdout.txt b/Tests/RunCMake/CommandLine/EnvColorOn-stdout.txt new file mode 100644 index 0000000..885925e --- /dev/null +++ b/Tests/RunCMake/CommandLine/EnvColorOn-stdout.txt @@ -0,0 +1 @@ +-- CMAKE_COLOR_DIAGNOSTICS='ON' diff --git a/Tests/RunCMake/CommandLine/EnvColorOn.cmake b/Tests/RunCMake/CommandLine/EnvColorOn.cmake new file mode 100644 index 0000000..af1235d --- /dev/null +++ b/Tests/RunCMake/CommandLine/EnvColorOn.cmake @@ -0,0 +1,4 @@ +message(STATUS "CMAKE_COLOR_DIAGNOSTICS='${CMAKE_COLOR_DIAGNOSTICS}'") +if(DEFINED CMAKE_COLOR_MAKEFILE) + message(FATAL_ERROR "CMAKE_COLOR_MAKEFILE incorrectly defined.") +endif() diff --git a/Tests/RunCMake/CommandLine/Fresh-stdout.txt b/Tests/RunCMake/CommandLine/Fresh-stdout.txt new file mode 100644 index 0000000..b5cece9 --- /dev/null +++ b/Tests/RunCMake/CommandLine/Fresh-stdout.txt @@ -0,0 +1,4 @@ +-- CMAKE_SOURCE_DIR='[^']*/Tests/RunCMake/CommandLine' +-- CMAKE_BINARY_DIR='[^']*/Tests/RunCMake/CommandLine/Fresh-build' +-- OLD CACHED_VAR_1='' +-- NEW CACHED_VAR_1='CACHED-VALUE-1' diff --git a/Tests/RunCMake/CommandLine/Fresh.cmake b/Tests/RunCMake/CommandLine/Fresh.cmake new file mode 100644 index 0000000..9b1695c --- /dev/null +++ b/Tests/RunCMake/CommandLine/Fresh.cmake @@ -0,0 +1,18 @@ +message(STATUS "CMAKE_SOURCE_DIR='${CMAKE_SOURCE_DIR}'") +message(STATUS "CMAKE_BINARY_DIR='${CMAKE_BINARY_DIR}'") +message(STATUS "OLD CACHED_VAR_1='${CACHED_VAR_1}'") +set(CACHED_VAR_1 "CACHED-VALUE-1" CACHE STRING "") +message(STATUS "NEW CACHED_VAR_1='${CACHED_VAR_1}'") +set(kept "${CMAKE_BINARY_DIR}/kept") +set(removed "${CMAKE_BINARY_DIR}/CMakeFiles/removed") +if(FIRST) + file(WRITE "${kept}" "") + file(WRITE "${removed}" "") +else() + if(NOT EXISTS "${kept}") + message(FATAL_ERROR "File was not kept:\n ${kept}") + endif() + if(EXISTS "${removed}") + message(FATAL_ERROR "File was not removed:\n ${removed}") + endif() +endif() diff --git a/Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt b/Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt new file mode 100644 index 0000000..c94c19d --- /dev/null +++ b/Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt @@ -0,0 +1,9 @@ +^-- CMAKE_ARGC='8' +-- CMAKE_ARGV1='-P' +-- CMAKE_ARGV2='[^']*/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake' +-- CMAKE_ARGV3='--' +-- CMAKE_ARGV4='-DFOO' +-- CMAKE_ARGV5='-S' +-- CMAKE_ARGV6='-B' +-- CMAKE_ARGV7='--fresh' +-- CMAKE_ARGV8=''$ diff --git a/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake b/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake index 29faae3..8dca990 100644 --- a/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake +++ b/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake @@ -1,3 +1,9 @@ -if(NOT ("${CMAKE_ARGV3}" STREQUAL "--" AND "${CMAKE_ARGV4}" STREQUAL "-DFOO")) - message(FATAL_ERROR "`-DFOO` shouldn't trigger an error after `--`") -endif() +message(STATUS "CMAKE_ARGC='${CMAKE_ARGC}'") +message(STATUS "CMAKE_ARGV1='${CMAKE_ARGV1}'") +message(STATUS "CMAKE_ARGV2='${CMAKE_ARGV2}'") +message(STATUS "CMAKE_ARGV3='${CMAKE_ARGV3}'") +message(STATUS "CMAKE_ARGV4='${CMAKE_ARGV4}'") +message(STATUS "CMAKE_ARGV5='${CMAKE_ARGV5}'") +message(STATUS "CMAKE_ARGV6='${CMAKE_ARGV6}'") +message(STATUS "CMAKE_ARGV7='${CMAKE_ARGV7}'") +message(STATUS "CMAKE_ARGV8='${CMAKE_ARGV8}'") diff --git a/Tests/RunCMake/CommandLine/P_fresh-result.txt b/Tests/RunCMake/CommandLine/P_fresh-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/P_fresh-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/P_fresh-stderr.txt b/Tests/RunCMake/CommandLine/P_fresh-stderr.txt new file mode 100644 index 0000000..0c5b035 --- /dev/null +++ b/Tests/RunCMake/CommandLine/P_fresh-stderr.txt @@ -0,0 +1 @@ +^CMake Error: --fresh allowed only when configuring a project$ diff --git a/Tests/RunCMake/CommandLine/P_fresh.cmake b/Tests/RunCMake/CommandLine/P_fresh.cmake new file mode 100644 index 0000000..dfedce1 --- /dev/null +++ b/Tests/RunCMake/CommandLine/P_fresh.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "This code should not be reached.") diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index f7554ff..c8234ec 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -52,7 +52,8 @@ run_cmake_command(G_no-arg ${CMAKE_COMMAND} -B DummyBuildDir -G) run_cmake_command(G_bad-arg ${CMAKE_COMMAND} -B DummyBuildDir -G NoSuchGenerator) run_cmake_command(P_no-arg ${CMAKE_COMMAND} -P) run_cmake_command(P_no-file ${CMAKE_COMMAND} -P nosuchscriptfile.cmake) -run_cmake_command(P_arbitrary_args ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_arbitrary_args.cmake" -- -DFOO) +run_cmake_command(P_arbitrary_args ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_arbitrary_args.cmake" -- -DFOO -S -B --fresh) +run_cmake_command(P_fresh ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_fresh.cmake" --fresh) run_cmake_command(build-no-dir ${CMAKE_COMMAND} --build) @@ -212,6 +213,22 @@ message(STATUS "CMAKE_BINARY_DIR='${CMAKE_BINARY_DIR}'") endfunction() run_ExplicitDirs() +function(run_Fresh) + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/Fresh-build") + + set(RunCMake_TEST_VARIANT_DESCRIPTION "-empty") + run_cmake_with_options(Fresh --fresh -DFIRST=ON) + set(RunCMake_TEST_NO_CLEAN 1) + + set(RunCMake_TEST_VARIANT_DESCRIPTION "-reconfig") + run_cmake_with_options(Fresh --fresh) + + set(RunCMake_TEST_VARIANT_DESCRIPTION "-src-from-cache") + set(RunCMake_TEST_NO_SOURCE_DIR 1) + run_cmake_with_options(Fresh --fresh "${RunCMake_TEST_BINARY_DIR}") +endfunction() +run_Fresh() + function(run_Toolchain) set(RunCMake_TEST_NO_SOURCE_DIR 1) set(source_dir ${RunCMake_SOURCE_DIR}/Toolchain) @@ -445,6 +462,14 @@ function(run_EnvironmentToolchain) endfunction() run_EnvironmentToolchain() +function(run_EnvironmentColor) + set(ENV{CMAKE_COLOR_DIAGNOSTICS} "ON") + run_cmake(EnvColorOn) + unset(ENV{CMAKE_COLOR_DIAGNOSTICS}) + run_cmake(EnvColorDefault) +endfunction() +run_EnvironmentColor() + 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) @@ -705,17 +730,33 @@ file(WRITE "${out}/empty_file.txt" "") file(WRITE "${out}/unicode_file.txt" "à éùç - í•œêµì–´") # Korean in Korean run_cmake_command(E_cat_good_cat ${CMAKE_COMMAND} -E cat "${out}/first_file.txt" "${out}/second_file.txt" "${out}/empty_file.txt" "${out}/unicode_file.txt") -unset(out) run_cmake_command(E_cat_good_binary_cat ${CMAKE_COMMAND} -E cat "${RunCMake_SOURCE_DIR}/E_cat_binary_files/binary.obj" "${RunCMake_SOURCE_DIR}/E_cat_binary_files/binary.obj") +# To test whether the double dash (--) works, we need to control the working directory +# in order to be able to pass a relative path that starts with a dash. +file(WRITE "${out}/-file-starting-with-dash.txt" "file starting with dash, not an option\n") +set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${out}") +run_cmake_command(E_cat-with-double-dash ${CMAKE_COMMAND} -E cat -- "-file-starting-with-dash.txt") +run_cmake_command(E_cat-without-double-dash ${CMAKE_COMMAND} -E cat "-file-starting-with-dash.txt") +unset(RunCMake_TEST_COMMAND_WORKING_DIRECTORY) +unset(out) + run_cmake_command(E_env-no-command0 ${CMAKE_COMMAND} -E env) run_cmake_command(E_env-no-command1 ${CMAKE_COMMAND} -E env TEST_ENV=1) run_cmake_command(E_env-bad-arg1 ${CMAKE_COMMAND} -E env -bad-arg1) run_cmake_command(E_env-set ${CMAKE_COMMAND} -E env TEST_ENV=1 ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/E_env-set.cmake) run_cmake_command(E_env-unset ${CMAKE_COMMAND} -E env TEST_ENV=1 ${CMAKE_COMMAND} -E env --unset=TEST_ENV ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/E_env-unset.cmake) +# To test whether the double dash (--) works for the env command, we need a command that e.g. contains an equals sign (=) +# and would normally be interpreted as an NAME=VALUE environment variable. +# Ensuring such a command is done by simply copying the trivial exit_code executable with a different name. +cmake_path(GET EXIT_CODE_EXE FILENAME exit_code) +file(COPY_FILE "${EXIT_CODE_EXE}" "${RunCMake_BINARY_DIR}/env=${exit_code}") +run_cmake_command(E_env-with-double-dash ${CMAKE_COMMAND} -E env TEST_ENV=1 -- "${RunCMake_BINARY_DIR}/env=${exit_code}" zero_exit) +run_cmake_command(E_env-without-double-dash ${CMAKE_COMMAND} -E env TEST_ENV=1 "${RunCMake_BINARY_DIR}/env=${exit_code}" zero_exit) + run_cmake_command(E_md5sum-dir ${CMAKE_COMMAND} -E md5sum .) run_cmake_command(E_sha1sum-dir ${CMAKE_COMMAND} -E sha1sum .) run_cmake_command(E_sha224sum-dir ${CMAKE_COMMAND} -E sha224sum .) diff --git a/Tests/RunCMake/CommandLine/trace-json-v1-check.py b/Tests/RunCMake/CommandLine/trace-json-v1-check.py index 1ee005e..c4b95dc 100755 --- a/Tests/RunCMake/CommandLine/trace-json-v1-check.py +++ b/Tests/RunCMake/CommandLine/trace-json-v1-check.py @@ -30,6 +30,8 @@ required_traces = [ { 'args': ['STATUS', 'JSON-V1 str', 'spaces'], 'cmd': 'message', + 'line': 1, + 'line_end': 5 }, { 'args': ['ASDF', 'fff', 'sss', ' SPACES !!! '], @@ -46,31 +48,62 @@ required_traces = [ { 'args': msg_args, 'cmd': 'message', - 'frame': 3 if expand else 2 + 'frame': 3 if expand else 2, + 'global_frame': 3 if expand else 2 }, + { + 'args': ['STATUS', 'nested global_frame'], + 'cmd': 'message', + 'frame': 3, + 'global_frame': 6 if expand else 5 + }, + { + 'cmd': 'else', + 'global_frame': 4 if expand else 3, + 'line': 3 + } ] +def assert_fields_look_good(line): + expected_fields = {'args', 'cmd', 'file', 'frame', 'global_frame','line', 'time'} + if "line_end" in line: + assert isinstance(line['line_end'], int) + assert line['line'] != line['line_end'] + expected_fields.add("line_end") + + assert set(line.keys()) == expected_fields + + assert isinstance(line['args'], list) + assert isinstance(line['cmd'], unicode) + assert isinstance(line['file'], unicode) + assert isinstance(line['frame'], int) + assert isinstance(line['global_frame'], int) + assert isinstance(line['line'], int) + assert isinstance(line['time'], float) + + with open(trace_file, 'r') as fp: # Check for version (must be the first document) vers = json.loads(fp.readline()) assert sorted(vers.keys()) == ['version'] assert sorted(vers['version'].keys()) == ['major', 'minor'] assert vers['version']['major'] == 1 - assert vers['version']['minor'] == 1 + assert vers['version']['minor'] == 2 for i in fp.readlines(): line = json.loads(i) - assert sorted(line.keys()) == ['args', 'cmd', 'file', 'frame', 'line', 'time'] - assert isinstance(line['args'], list) - assert isinstance(line['cmd'], unicode) - assert isinstance(line['file'], unicode) - assert isinstance(line['frame'], int) - assert isinstance(line['line'], int) - assert isinstance(line['time'], float) - + assert_fields_look_good(line) for j in required_traces: # Compare the subset of required keys with line - if {k: line[k] for k in j} == j: + subset = { + k: line[k] + for k in j + if k in line + } + if subset == j: required_traces.remove(j) -assert not required_traces +assert not required_traces, ( + "The following traces were expected to be part of the " + "output but weren't", required_traces +) diff --git a/Tests/RunCMake/CommandLine/trace-json-v1-nested/CMakeLists.txt b/Tests/RunCMake/CommandLine/trace-json-v1-nested/CMakeLists.txt new file mode 100644 index 0000000..743f6de --- /dev/null +++ b/Tests/RunCMake/CommandLine/trace-json-v1-nested/CMakeLists.txt @@ -0,0 +1,14 @@ +function(function_that_uses_else) + if(FALSE) + else() + endif() +endfunction() +function(f) + message(STATUS "nested global_frame") +endfunction() + +function(g) + f() +endfunction() + +g() diff --git a/Tests/RunCMake/CommandLine/trace-json-v1.cmake b/Tests/RunCMake/CommandLine/trace-json-v1.cmake index ed0a0f9..464eb1f 100644 --- a/Tests/RunCMake/CommandLine/trace-json-v1.cmake +++ b/Tests/RunCMake/CommandLine/trace-json-v1.cmake @@ -1,5 +1,11 @@ -message(STATUS "JSON-V1 str" "spaces") +message( + STATUS + "JSON-V1 str" + "spaces" + ) set(ASDF fff sss " SPACES !!! ") set(FOO 42) set(BAR " space in string!") message(STATUS fff ${ASDF} " ${FOO} ${BAR}" " SPACES !!! ") +add_subdirectory(trace-json-v1-nested) +function_that_uses_else() diff --git a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake index a64af95..a487f37 100644 --- a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake @@ -34,3 +34,9 @@ run_cmake(zip) # Extracting only selected files or directories run_cmake(zip-filtered) + +# Use the --mtime option to set the mtime when creating archive +run_cmake(set-mtime) + +# Use the --touch option to avoid extracting the mtime +run_cmake(touch-mtime) diff --git a/Tests/RunCMake/CommandLineTar/mtime-tests.cmake b/Tests/RunCMake/CommandLineTar/mtime-tests.cmake new file mode 100644 index 0000000..8b4f098 --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/mtime-tests.cmake @@ -0,0 +1,9 @@ +set(OUTPUT_NAME "test.tar") + +set(ARCHIVE_MTIME "1970-01-01UTC") +set(ARCHIVE_MTIME_RFC3339 "1970-01-01T00:00:00Z") + +set(COMPRESSION_FLAGS cvf) +set(COMPRESSION_OPTIONS --mtime=${ARCHIVE_MTIME}) + +set(DECOMPRESSION_FLAGS xvf) diff --git a/Tests/RunCMake/CommandLineTar/set-mtime.cmake b/Tests/RunCMake/CommandLineTar/set-mtime.cmake new file mode 100644 index 0000000..333cc88 --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/set-mtime.cmake @@ -0,0 +1,11 @@ +include(${CMAKE_CURRENT_LIST_DIR}/mtime-tests.cmake) + +include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake) + +foreach(file ${CHECK_FILES}) + file(TIMESTAMP ${FULL_DECOMPRESS_DIR}/${COMPRESS_DIR}/${file} MTIME UTC) + if(NOT MTIME STREQUAL ARCHIVE_MTIME_RFC3339) + message(FATAL_ERROR + "Extracted timestamp ${MTIME} does not match expected ${ARCHIVE_MTIME_RFC3339}") + endif() +endforeach() diff --git a/Tests/RunCMake/CommandLineTar/touch-mtime.cmake b/Tests/RunCMake/CommandLineTar/touch-mtime.cmake new file mode 100644 index 0000000..c9e3524 --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/touch-mtime.cmake @@ -0,0 +1,13 @@ +include(${CMAKE_CURRENT_LIST_DIR}/mtime-tests.cmake) + +set(DECOMPRESSION_OPTIONS --touch) + +include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake) + +foreach(file ${CHECK_FILES}) + file(TIMESTAMP ${FULL_DECOMPRESS_DIR}/${COMPRESS_DIR}/${file} MTIME UTC) + if(MTIME STREQUAL ARCHIVE_MTIME_RFC3339) + message(FATAL_ERROR + "File has unexpected timestamp ${MTIME}") + endif() +endforeach() diff --git a/Tests/RunCMake/CompilerArgs/C-stdout.txt b/Tests/RunCMake/CompilerArgs/C-stdout.txt new file mode 100644 index 0000000..e553cbb --- /dev/null +++ b/Tests/RunCMake/CompilerArgs/C-stdout.txt @@ -0,0 +1 @@ +-- CMAKE_C_COMPILER_ARG1=' ?-DFOO1 -DFOO2' diff --git a/Tests/RunCMake/CompilerArgs/C.cmake b/Tests/RunCMake/CompilerArgs/C.cmake index 96b004b..0fbfdd2 100644 --- a/Tests/RunCMake/CompilerArgs/C.cmake +++ b/Tests/RunCMake/CompilerArgs/C.cmake @@ -1,3 +1,4 @@ enable_language(C) set(CMAKE_VERBOSE_MAKEFILE TRUE) +message(STATUS "CMAKE_C_COMPILER_ARG1='${CMAKE_C_COMPILER_ARG1}'") add_executable(main main.c) diff --git a/Tests/RunCMake/CompilerArgs/CXX-stdout.txt b/Tests/RunCMake/CompilerArgs/CXX-stdout.txt new file mode 100644 index 0000000..c543d3b --- /dev/null +++ b/Tests/RunCMake/CompilerArgs/CXX-stdout.txt @@ -0,0 +1 @@ +-- CMAKE_CXX_COMPILER_ARG1=' ?-DFOO1 -DFOO2' diff --git a/Tests/RunCMake/CompilerArgs/CXX.cmake b/Tests/RunCMake/CompilerArgs/CXX.cmake index 3d2ee00..b6cf87e 100644 --- a/Tests/RunCMake/CompilerArgs/CXX.cmake +++ b/Tests/RunCMake/CompilerArgs/CXX.cmake @@ -1,3 +1,4 @@ enable_language(CXX) set(CMAKE_VERBOSE_MAKEFILE TRUE) +message(STATUS "CMAKE_CXX_COMPILER_ARG1='${CMAKE_CXX_COMPILER_ARG1}'") add_executable(main main.cxx) diff --git a/Tests/RunCMake/CompilerArgs/RunCMakeTest.cmake b/Tests/RunCMake/CompilerArgs/RunCMakeTest.cmake index 9e5a18a..62294cd 100644 --- a/Tests/RunCMake/CompilerArgs/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompilerArgs/RunCMakeTest.cmake @@ -19,12 +19,6 @@ function(run_compiler_env lang) # Use the correct compiler include(${RunCMake_BINARY_DIR}/Find${lang}Compiler-build/${lang}_comp.cmake) - # Use a single build tree for tests without cleaning. - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${lang}-env-build) - set(RunCMake_TEST_NO_CLEAN 1) - file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") - file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") - # Set the compiler if(lang STREQUAL "C") set(ENV{CC} "'${temp_CMAKE_${lang}_COMPILER}' -DFOO1 -DFOO2") @@ -32,19 +26,30 @@ function(run_compiler_env lang) set(ENV{${lang}} "'${temp_CMAKE_${lang}_COMPILER}' -DFOO1 -DFOO2") endif() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${lang}-env-build) + set(RunCMake_TEST_VARIANT_DESCRIPTION "-env") + run_cmake(${lang}) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build . ${verbose_args}) + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}/CMakeFiles") + set(RunCMake_TEST_VARIANT_DESCRIPTION "-env-cached") run_cmake(${lang}) run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build . ${verbose_args}) endfunction() function(run_compiler_tc lang) - # Use a single build tree for tests without cleaning. + set(RunCMake_TEST_OPTIONS + -DCMAKE_TOOLCHAIN_FILE=${RunCMake_BINARY_DIR}/Find${lang}Compiler-build/toolchain_${lang}_comp.cmake) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${lang}-tc-build) + set(RunCMake_TEST_VARIANT_DESCRIPTION "-tc") + run_cmake(${lang}) set(RunCMake_TEST_NO_CLEAN 1) - file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") - file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build . ${verbose_args}) - set(RunCMake_TEST_OPTIONS - -DCMAKE_TOOLCHAIN_FILE=${RunCMake_BINARY_DIR}/Find${lang}Compiler-build/toolchain_${lang}_comp.cmake) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}/CMakeFiles") + set(RunCMake_TEST_VARIANT_DESCRIPTION "-tc-cached") run_cmake(${lang}) run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build . ${verbose_args}) endfunction() diff --git a/Tests/RunCMake/ExternalProject/CONFIGURE_HANDLED_BY_BUILD.cmake b/Tests/RunCMake/ExternalProject/CONFIGURE_HANDLED_BY_BUILD.cmake index 6dbf0f4..d531928 100644 --- a/Tests/RunCMake/ExternalProject/CONFIGURE_HANDLED_BY_BUILD.cmake +++ b/Tests/RunCMake/ExternalProject/CONFIGURE_HANDLED_BY_BUILD.cmake @@ -1,5 +1,12 @@ include(ExternalProject) +if(CMAKE_GENERATOR STREQUAL "Borland Makefiles" OR + CMAKE_GENERATOR STREQUAL "Watcom WMake") + set(fs_delay 3) +else() + set(fs_delay 1.125) +endif() + # Given this setup, on the first build, both configure steps and both build # steps will run. On a noop rebuild, only the build steps will run. Without # CONFIGURE_HANDLED_BY_BUILD, the configure step of proj2 would also run on a @@ -11,7 +18,7 @@ ExternalProject_Add(proj1 CONFIGURE_COMMAND ${CMAKE_COMMAND} -E echo "Doing something" # file(TIMESTAMP) gives back the timestamp in seconds so we sleep a second to # make sure we get a different timestamp on the stamp file - BUILD_COMMAND ${CMAKE_COMMAND} -E sleep 1.125 + BUILD_COMMAND ${CMAKE_COMMAND} -E sleep ${fs_delay} INSTALL_COMMAND "" BUILD_ALWAYS ON STAMP_DIR "stamp" @@ -20,7 +27,7 @@ ExternalProject_Add(proj2 DOWNLOAD_COMMAND "" SOURCE_DIR "" CONFIGURE_COMMAND ${CMAKE_COMMAND} -E echo "Doing something" - BUILD_COMMAND ${CMAKE_COMMAND} -E sleep 1.125 + BUILD_COMMAND ${CMAKE_COMMAND} -E sleep ${fs_delay} INSTALL_COMMAND "" CONFIGURE_HANDLED_BY_BUILD ON DEPENDS proj1 diff --git a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake index fde384f..08adee2 100644 --- a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake @@ -105,12 +105,15 @@ function(__ep_test_with_build_with_server testName) if(EXISTS "${URL_FILE}") file(REMOVE "${URL_FILE}") endif() + if(NOT DOWNLOAD_SERVER_TIMEOUT) + set(DOWNLOAD_SERVER_TIMEOUT 30) + endif() execute_process( COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/DownloadServer.py --file "${URL_FILE}" ${ARGN} OUTPUT_FILE ${RunCMake_BINARY_DIR}/${testName}-python.txt ERROR_FILE ${RunCMake_BINARY_DIR}/${testName}-python.txt RESULT_VARIABLE result - TIMEOUT 30 + TIMEOUT "${DOWNLOAD_SERVER_TIMEOUT}" ) if(NOT result EQUAL 0) message(FATAL_ERROR "Failed to start download server:\n ${result}") diff --git a/Tests/RunCMake/Framework/FrameworkConsumption.cmake b/Tests/RunCMake/Framework/FrameworkConsumption.cmake new file mode 100644 index 0000000..4663166 --- /dev/null +++ b/Tests/RunCMake/Framework/FrameworkConsumption.cmake @@ -0,0 +1,15 @@ + +cmake_minimum_required(VERSION 3.22...3.24) +enable_language(C) + +# Create framework and ensure header is placed in Headers +set(input_header "${CMAKE_SOURCE_DIR}/Gui.h") +add_library(Gui SHARED Gui.c "${input_header}") +set_target_properties(Gui PROPERTIES + PUBLIC_HEADER "${input_header}" + FRAMEWORK TRUE +) + +add_executable(app main.c) + +target_link_libraries(app PRIVATE Gui) diff --git a/Tests/RunCMake/Framework/Gui.c b/Tests/RunCMake/Framework/Gui.c new file mode 100644 index 0000000..f669327 --- /dev/null +++ b/Tests/RunCMake/Framework/Gui.c @@ -0,0 +1,5 @@ + +int foo(void) +{ + return 0; +} diff --git a/Tests/RunCMake/Framework/Gui.h b/Tests/RunCMake/Framework/Gui.h new file mode 100644 index 0000000..5beae6d --- /dev/null +++ b/Tests/RunCMake/Framework/Gui.h @@ -0,0 +1,2 @@ + +int foo(void); diff --git a/Tests/RunCMake/Framework/RunCMakeTest.cmake b/Tests/RunCMake/Framework/RunCMakeTest.cmake index 2f8fdc7..a767130 100644 --- a/Tests/RunCMake/Framework/RunCMakeTest.cmake +++ b/Tests/RunCMake/Framework/RunCMakeTest.cmake @@ -105,3 +105,15 @@ function(framework_system_include_test) endfunction() framework_system_include_test() + +function(framework_consumption) + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/FrameworkConsumption-build") + set(RunCMake_TEST_NO_CLEAN 1) + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(FrameworkConsumption) + run_cmake_command(FrameworkConsumption-build ${CMAKE_COMMAND} --build .) +endfunction() + +framework_consumption() diff --git a/Tests/RunCMake/Framework/main.c b/Tests/RunCMake/Framework/main.c new file mode 100644 index 0000000..fc09922 --- /dev/null +++ b/Tests/RunCMake/Framework/main.c @@ -0,0 +1,9 @@ + +#include <Gui/Gui.h> + +int main() +{ + foo(); + + return 0; +} diff --git a/Tests/RunCMake/GNUInstallDirs/Root-Debian-stderr.txt b/Tests/RunCMake/GNUInstallDirs/Root-Debian-stderr.txt index 2019459..25f80d3 100644 --- a/Tests/RunCMake/GNUInstallDirs/Root-Debian-stderr.txt +++ b/Tests/RunCMake/GNUInstallDirs/Root-Debian-stderr.txt @@ -4,7 +4,7 @@ CMAKE_INSTALL_DATAROOTDIR='usr/share' CMAKE_INSTALL_DOCDIR='usr/share/doc/Root' CMAKE_INSTALL_INCLUDEDIR='usr/include' CMAKE_INSTALL_INFODIR='usr/share/info' -CMAKE_INSTALL_LIBDIR='usr/lib/arch' +CMAKE_INSTALL_LIBDIR='usr/lib' CMAKE_INSTALL_LIBEXECDIR='usr/libexec' CMAKE_INSTALL_LOCALEDIR='usr/share/locale' CMAKE_INSTALL_LOCALSTATEDIR='var' @@ -19,7 +19,7 @@ CMAKE_INSTALL_FULL_DATAROOTDIR='/usr/share' CMAKE_INSTALL_FULL_DOCDIR='/usr/share/doc/Root' CMAKE_INSTALL_FULL_INCLUDEDIR='/usr/include' CMAKE_INSTALL_FULL_INFODIR='/usr/share/info' -CMAKE_INSTALL_FULL_LIBDIR='/usr/lib/arch' +CMAKE_INSTALL_FULL_LIBDIR='/usr/lib' CMAKE_INSTALL_FULL_LIBEXECDIR='/usr/libexec' CMAKE_INSTALL_FULL_LOCALEDIR='/usr/share/locale' CMAKE_INSTALL_FULL_LOCALSTATEDIR='/var' diff --git a/Tests/RunCMake/GNUInstallDirs/UsrLocal-Debian-stderr.txt b/Tests/RunCMake/GNUInstallDirs/UsrLocal-Debian-stderr.txt index 0830138..30795c8 100644 --- a/Tests/RunCMake/GNUInstallDirs/UsrLocal-Debian-stderr.txt +++ b/Tests/RunCMake/GNUInstallDirs/UsrLocal-Debian-stderr.txt @@ -4,7 +4,7 @@ CMAKE_INSTALL_DATAROOTDIR='share' CMAKE_INSTALL_DOCDIR='share/doc/UsrLocal' CMAKE_INSTALL_INCLUDEDIR='include' CMAKE_INSTALL_INFODIR='share/info' -CMAKE_INSTALL_LIBDIR='lib/arch' +CMAKE_INSTALL_LIBDIR='lib' CMAKE_INSTALL_LIBEXECDIR='libexec' CMAKE_INSTALL_LOCALEDIR='share/locale' CMAKE_INSTALL_LOCALSTATEDIR='var' @@ -19,7 +19,7 @@ CMAKE_INSTALL_FULL_DATAROOTDIR='/usr/local/share' CMAKE_INSTALL_FULL_DOCDIR='/usr/local/share/doc/UsrLocal' CMAKE_INSTALL_FULL_INCLUDEDIR='/usr/local/include' CMAKE_INSTALL_FULL_INFODIR='/usr/local/share/info' -CMAKE_INSTALL_FULL_LIBDIR='/usr/local/lib/arch' +CMAKE_INSTALL_FULL_LIBDIR='/usr/local/lib' CMAKE_INSTALL_FULL_LIBEXECDIR='/usr/local/libexec' CMAKE_INSTALL_FULL_LOCALEDIR='/usr/local/share/locale' CMAKE_INSTALL_FULL_LOCALSTATEDIR='/usr/local/var' diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/CMakeLists.txt b/Tests/RunCMake/GenEx-LINK_GROUP/CMakeLists.txt new file mode 100644 index 0000000..612169c --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.18...3.22) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/RunCMakeTest.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/RunCMakeTest.cmake new file mode 100644 index 0000000..f20d225 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/RunCMakeTest.cmake @@ -0,0 +1,36 @@ +include(RunCMake) + +run_cmake(add_custom_target) +run_cmake(add_custom_command) +run_cmake(add_link_options) +run_cmake(link_directories) +run_cmake(target_link_options) +run_cmake(target_link_directories) +run_cmake(no-arguments) +run_cmake(empty-arguments) +run_cmake(forbidden-arguments) +run_cmake(nested-incompatible-genex) +run_cmake(invalid-feature) +run_cmake(multiple-definitions) +run_cmake(bad-feature1) +run_cmake(bad-feature2) +run_cmake(bad-feature3) +run_cmake(bad-feature4) +run_cmake(bad-feature5) +run_cmake(feature-not-supported) +run_cmake(library-ignored) +run_cmake(compatible-features1) +run_cmake(compatible-features2) +run_cmake(compatible-features3) +run_cmake(incompatible-features1) +run_cmake(nested-incompatible-features1) +run_cmake(nested-incompatible-features2) +run_cmake(circular-dependencies1) +run_cmake(circular-dependencies2) +run_cmake(only-targets) + +# usage of LINK_LIBRARY with LINK_GROUP +run_cmake(incompatible-library-features1) +run_cmake(incompatible-library-features2) +run_cmake(override-library-features1) +run_cmake(override-library-features2) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command-stderr.txt new file mode 100644 index 0000000..a80a11b --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at add_custom_command.cmake:[0-9]+ \(add_custom_command\): + Error evaluating generator expression: + + \$<LINK_GROUP:feat> + + \$<LINK_GROUP:...> may only be used with binary targets to specify group of + link libraries. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command.cmake new file mode 100644 index 0000000..1efe276 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command.cmake @@ -0,0 +1,4 @@ +add_custom_target(drive) +add_custom_command(TARGET drive PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E echo "$<LINK_GROUP:feat>" +) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target-stderr.txt new file mode 100644 index 0000000..deb246a --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at add_custom_target.cmake:[0-9]+ \(add_custom_target\): + Error evaluating generator expression: + + \$<LINK_GROUP:feat> + + \$<LINK_GROUP:...> may only be used with binary targets to specify group of + link libraries. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target.cmake new file mode 100644 index 0000000..cbb5ff0 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target.cmake @@ -0,0 +1,3 @@ +add_custom_target(drive + COMMAND ${CMAKE_COMMAND} -E echo "$<LINK_GROUP:feat>" +) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options-stderr.txt new file mode 100644 index 0000000..17c348c --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at add_link_options.cmake:[0-9]+ \(add_link_options\): + Error evaluating generator expression: + + \$<LINK_GROUP:feat> + + \$<LINK_GROUP:...> may only be used with binary targets to specify group of + link libraries. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options.cmake new file mode 100644 index 0000000..2e31b34 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options.cmake @@ -0,0 +1,5 @@ +enable_language(C) + +add_link_options("$<LINK_GROUP:feat>") + +add_library(empty SHARED empty.c) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1-stderr.txt new file mode 100644 index 0000000..8c95452 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at bad-feature1.cmake:[0-9]+ \(add_library\): + Feature 'bad_feat', specified through generator-expression '\$<LINK_GROUP>' + to link target 'lib', is not supported for the 'C' link language. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1.cmake new file mode 100644 index 0000000..0161221 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1.cmake @@ -0,0 +1,6 @@ +enable_language(C) + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_GROUP:bad_feat,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2-stderr.txt new file mode 100644 index 0000000..3f057c4 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at bad-feature2.cmake:[0-9]+ \(add_library\): + Feature 'feat', specified through generator-expression '\$<LINK_GROUP>' to + link target 'lib', is not defined for the 'C' link language. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2.cmake new file mode 100644 index 0000000..7e56194 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2.cmake @@ -0,0 +1,8 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE) + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3-stderr.txt new file mode 100644 index 0000000..43e2700 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at bad-feature3.cmake:[0-9]+ \(add_library\): + Feature 'feat', specified by variable 'CMAKE_C_LINK_GROUP_USING_feat', is + malformed \(wrong number of elements\) and cannot be used to link target + 'lib'. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3.cmake new file mode 100644 index 0000000..58b422a --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3.cmake @@ -0,0 +1,9 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat "") + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4-stderr.txt new file mode 100644 index 0000000..0a2ba60 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at bad-feature4.cmake:[0-9]+ \(add_library\): + Feature 'feat', specified by variable 'CMAKE_C_LINK_GROUP_USING_feat', is + malformed \(wrong number of elements\) and cannot be used to link target + 'lib'. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4.cmake new file mode 100644 index 0000000..dcb8236 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4.cmake @@ -0,0 +1,9 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat "-opt") + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5-stderr.txt new file mode 100644 index 0000000..4b1f01d --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at bad-feature5.cmake:[0-9]+ \(add_library\): + Feature 'feat', specified by variable 'CMAKE_C_LINK_GROUP_USING_feat', is + malformed \(wrong number of elements\) and cannot be used to link target + 'lib'. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5.cmake new file mode 100644 index 0000000..cb10996 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5.cmake @@ -0,0 +1,9 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat "-start" "<LIBRARY>" "-stop") + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1-stderr.txt new file mode 100644 index 0000000..94008e1 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at circular-dependencies1.cmake:[0-9]+ \(add_library\): + The inter-target dependency graph, for the target "lib1", contains the + following strongly connected component \(cycle\): + + group "feat:{dep1.1,dep1.2}" + depends on group "feat:{dep2.1,dep2.2}" + group "feat:{dep2.1,dep2.2}" + depends on group "feat:{dep1.1,dep1.2}" + +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1.cmake new file mode 100644 index 0000000..a1d7575 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1.cmake @@ -0,0 +1,17 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--stop") + +add_library(dep1.1 SHARED empty.c) +add_library(dep1.2 SHARED empty.c) + +add_library(dep2.1 SHARED empty.c) +add_library(dep2.2 SHARED empty.c) + +target_link_libraries(dep1.1 PUBLIC dep2.1) +target_link_libraries(dep2.2 PUBLIC dep1.2) + +add_library(lib1 SHARED empty.c) +target_link_libraries(lib1 PRIVATE "$<LINK_GROUP:feat,dep1.1,dep1.2>" + "$<LINK_GROUP:feat,dep2.1,dep2.2>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2-stderr.txt new file mode 100644 index 0000000..365e98f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at circular-dependencies2.cmake:[0-9]+ \(add_library\): + The inter-target dependency graph, for the target "lib2", contains the + following strongly connected component \(cycle\): + + group "feat:{base3,base4}" + depends on group "feat:{base1,base2}" + group "feat:{base1,base2}" + depends on group "feat:{base3,base4}" + +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2.cmake new file mode 100644 index 0000000..99fda4d --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2.cmake @@ -0,0 +1,18 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--stop") + +add_library(base1 SHARED empty.c) +add_library(base2 SHARED empty.c) +add_library(base3 SHARED empty.c) +add_library(base4 SHARED empty.c) + +target_link_libraries(base1 PUBLIC base3) +target_link_libraries(base4 PUBLIC base2) + +add_library(lib1 SHARED empty.c) +target_link_libraries(lib1 PUBLIC "$<LINK_GROUP:feat,base1,base2>") + +add_library(lib2 SHARED empty.c) +target_link_libraries(lib2 PRIVATE "$<LINK_GROUP:feat,base3,base4>" lib1) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features1.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features1.cmake new file mode 100644 index 0000000..9d10f95 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features1.cmake @@ -0,0 +1,18 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat1_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat1 "--start" "--stop") + +set(CMAKE_C_LINK_GROUP_USING_feat2_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat2 "--start" "--stop") + +add_library(dep1 SHARED empty.c) + +add_library(dep2 SHARED empty.c) +target_link_libraries(dep2 PRIVATE "$<LINK_GROUP:feat1,dep1>") + +add_library(dep3 SHARED empty.c) +target_link_libraries(dep3 PUBLIC dep2) + +add_library(lib1 SHARED empty.c) +target_link_libraries(lib1 PRIVATE $<LINK_GROUP:feat2,dep1,dep2>) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features2.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features2.cmake new file mode 100644 index 0000000..1fe2880 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features2.cmake @@ -0,0 +1,13 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--stop") + +add_library(dep1 SHARED empty.c) +add_library(dep2 SHARED empty.c) + +add_library(lib1 SHARED empty.c) +target_link_libraries(lib1 PUBLIC "$<LINK_GROUP:feat,dep1,dep2>") + +add_library(lib2 SHARED empty.c) +target_link_libraries(lib2 PRIVATE "$<LINK_GROUP:feat,dep2,lib1>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features3.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features3.cmake new file mode 100644 index 0000000..ac486ce --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features3.cmake @@ -0,0 +1,13 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--stop") + +add_library(dep1 SHARED empty.c) +add_library(dep2 SHARED empty.c) +target_link_libraries(dep2 PUBLIC dep1) +add_library(dep3 SHARED empty.c) +target_link_libraries(dep3 PUBLIC dep1) + +add_library(lib1 SHARED empty.c) +target_link_libraries(lib1 PUBLIC "$<LINK_GROUP:feat,dep1,dep2>" dep3) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments-stderr.txt new file mode 100644 index 0000000..27101cb --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at empty-arguments.cmake:[0-9]+ \(target_link_libraries\): + Error evaluating generator expression: + + \$<LINK_GROUP:,> + + \$<LINK_GROUP:...> expects a feature name as first argument. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments.cmake new file mode 100644 index 0000000..6093935 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_GROUP:,>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/empty.c b/Tests/RunCMake/GenEx-LINK_GROUP/empty.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/empty.c diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported-stderr.txt new file mode 100644 index 0000000..3507f4d --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at feature-not-supported.cmake:[0-9]+ \(add_library\): + Feature 'feat', specified through generator-expression '\$<LINK_GROUP>' to + link target 'lib', is not supported for the 'C' link language. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported.cmake new file mode 100644 index 0000000..c4739bb --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported.cmake @@ -0,0 +1,9 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED FALSE) +set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--end") + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments-stderr.txt new file mode 100644 index 0000000..bae6505 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments-stderr.txt @@ -0,0 +1,16 @@ +CMake Error at forbidden-arguments.cmake:[0-9]+ \(link_libraries\): + Property LINK_LIBRARIES contains the invalid item "<LINK_GROUP:feat>". The + LINK_LIBRARIES property may contain the generator-expression + "\$<LINK_GROUP:...>" which may be used to specify how the libraries are + linked. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Error at forbidden-arguments.cmake:[0-9]+ \(target_link_libraries\): + Property LINK_LIBRARIES contains the invalid item "<LINK_GROUP:feat>". The + LINK_LIBRARIES property may contain the generator-expression + "\$<LINK_GROUP:...>" which may be used to specify how the libraries are + linked. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments.cmake new file mode 100644 index 0000000..dcbf8dd --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments.cmake @@ -0,0 +1,6 @@ +enable_language(C) + +link_libraries(<LINK_GROUP:feat> foo </LINK_GROUP:feat>) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE <LINK_GROUP:feat> foo </LINK_GROUP:feat>) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1-stderr.txt new file mode 100644 index 0000000..932245d --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at incompatible-features1.cmake:[0-9]+ \(add_library\): + Impossible to link target 'lib1' because the link item 'dep2', specified + with the group feature 'feat1', has already occurred with the feature + 'feat2', which is not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1.cmake new file mode 100644 index 0000000..efac0f8 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1.cmake @@ -0,0 +1,15 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat1_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat1 "--start" "--stop") + +set(CMAKE_C_LINK_GROUP_USING_feat2_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat2 "--start" "--stop") + +add_library(dep1 SHARED empty.c) +add_library(dep2 SHARED empty.c) +add_library(dep3 SHARED empty.c) +target_link_libraries(dep3 PUBLIC "$<LINK_GROUP:feat1,dep1,dep2>") + +add_library(lib1 SHARED empty.c) +target_link_libraries(lib1 PRIVATE "$<LINK_GROUP:feat2,dep2,dep3>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1-stderr.txt new file mode 100644 index 0000000..e3a4250 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at incompatible-library-features1.cmake:[0-9]+ \(add_library\): + Impossible to link target 'lib1' because the link item 'dep1', specified + with the feature 'feat1', has already occurred without any feature or + 'DEFAULT' feature, which is not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1.cmake new file mode 100644 index 0000000..203f071 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1.cmake @@ -0,0 +1,17 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat1_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat1 "--start" "--stop") + +set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat1 "--libflag1<LIBRARY>") + +set(CMAKE_C_LINK_LIBRARY_USING_feat2_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat2 "--libflag2<LIBRARY>") + +add_library(dep1 SHARED empty.c) +add_library(dep2 SHARED empty.c) +target_link_libraries(dep2 PUBLIC "$<LINK_LIBRARY:feat1,dep1>") + +add_library(lib1 SHARED empty.c) +target_link_libraries(lib1 PRIVATE "$<LINK_GROUP:feat1,$<LINK_LIBRARY:feat2,dep2>,dep1>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2-stderr.txt new file mode 100644 index 0000000..889cba0 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at incompatible-library-features2.cmake:[0-9]+ \(add_library\): + Impossible to link target 'lib1' because the link item 'dep1', specified + with the feature 'feat1', has already occurred with the feature 'feat2', + which is not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2.cmake new file mode 100644 index 0000000..6490819 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2.cmake @@ -0,0 +1,17 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat1_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat1 "--start" "--stop") + +set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat1 "--libflag1<LIBRARY>") + +set(CMAKE_C_LINK_LIBRARY_USING_feat2_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat2 "--libflag2<LIBRARY>") + +add_library(dep1 SHARED empty.c) +add_library(dep2 SHARED empty.c) +target_link_libraries(dep2 PUBLIC "$<LINK_LIBRARY:feat1,dep1>") + +add_library(lib1 SHARED empty.c) +target_link_libraries(lib1 PRIVATE "$<LINK_GROUP:feat1,$<LINK_LIBRARY:feat2,dep2,dep1>>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature-stderr.txt new file mode 100644 index 0000000..793b393 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at invalid-feature.cmake:[0-9]+ \(target_link_libraries\): + Error evaluating generator expression: + + \$<LINK_GROUP:feat:invalid,dep> + + The feature name 'feat:invalid' contains invalid characters. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature.cmake new file mode 100644 index 0000000..34a319c --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature.cmake @@ -0,0 +1,6 @@ +enable_language(C) + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat:invalid,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/library-ignored-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/library-ignored-stderr.txt new file mode 100644 index 0000000..b29c4ec --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/library-ignored-stderr.txt @@ -0,0 +1,13 @@ +CMake Warning \(dev\) at library-ignored.cmake:[0-9]+ \(add_library\): + The feature 'feat', specified as part of a generator-expression + '\$<LINK_GROUP:feat>', will not be applied to the INTERFACE library 'front'. +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 library-ignored.cmake:[0-9]+ \(add_library\): + The feature 'feat', specified as part of a generator-expression + '\$<LINK_GROUP:feat>', will not be applied to the OBJECT library 'dep'. +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/GenEx-LINK_GROUP/library-ignored.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/library-ignored.cmake new file mode 100644 index 0000000..b3f19a7 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/library-ignored.cmake @@ -0,0 +1,15 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--end") + +add_library(dep OBJECT empty.c) + +add_library(lib SHARED empty.c) + +add_library(front INTERFACE) +target_link_libraries(front INTERFACE lib) + + +add_library(lib2 SHARED empty.c) +target_link_libraries(lib2 PRIVATE "$<LINK_GROUP:feat,front,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/link_directories-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/link_directories-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/link_directories-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/link_directories-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/link_directories-stderr.txt new file mode 100644 index 0000000..51194a4 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/link_directories-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at link_directories.cmake:[0-9]+ \(link_directories\): + Error evaluating generator expression: + + \$<LINK_GROUP:feat> + + \$<LINK_GROUP:...> may only be used with binary targets to specify group of + link libraries. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/link_directories.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/link_directories.cmake new file mode 100644 index 0000000..e356e91 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/link_directories.cmake @@ -0,0 +1,5 @@ +enable_language(C) + +link_directories("$<LINK_GROUP:feat>") + +add_library(empty SHARED empty.c) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/multiple-definitions-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/multiple-definitions-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/multiple-definitions-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/multiple-definitions-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/multiple-definitions-stderr.txt new file mode 100644 index 0000000..995f363 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/multiple-definitions-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at multiple-definitions.cmake:[0-9]+ \(add_library\): + Feature 'feat', specified through generator-expression '\$<LINK_GROUP>' to + link target 'lib', is not supported for the 'C' link language. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/multiple-definitions.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/multiple-definitions.cmake new file mode 100644 index 0000000..a021d44 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/multiple-definitions.cmake @@ -0,0 +1,12 @@ +enable_language(C) + +# Language specific definition takes precedence over more generic one +set(CMAKE_C_LINK_GROUP_USING_feat "-BEFORE" "-AFTER") +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED FALSE) +set(CMAKE_LINK_GROUP_USING_feat "-BEFORE" "-AFTER") +set(CMAKE_LINK_GROUP_USING_feat_SUPPORTED TRUE) + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1-stderr.txt new file mode 100644 index 0000000..78631ab --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at nested-incompatible-features1.cmake:[0-9]+ \(target_link_libraries\): + Error evaluating generator expression: + + \$<LINK_GROUP:feat,dep1,\$<LINK_GROUP:feat,dep2>> + + \$<LINK_GROUP:...> cannot be nested. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1.cmake new file mode 100644 index 0000000..50e0c64 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1.cmake @@ -0,0 +1,11 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--end") + +add_library(dep1 SHARED empty.c) + +add_library(dep2 SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat,dep1,$<LINK_GROUP:feat,dep2>>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2-stderr.txt new file mode 100644 index 0000000..1a27c37 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at nested-incompatible-features2.cmake:[0-9]+ \(target_link_libraries\): + Error evaluating generator expression: + + \$<LINK_GROUP:feat1,dep1,\$<LINK_GROUP:feat2,dep2>> + + \$<LINK_GROUP:...> cannot be nested. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2.cmake new file mode 100644 index 0000000..c6ea14c --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2.cmake @@ -0,0 +1,14 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat1_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat1 "--start" "--end") + +set(CMAKE_C_LINK_GROUP_USING_feat2_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat2 "--start" "--end") + +add_library(dep1 SHARED empty.c) + +add_library(dep2 SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat1,dep1,$<LINK_GROUP:feat2,dep2>>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex-stderr.txt new file mode 100644 index 0000000..87eeb4d --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex-stderr.txt @@ -0,0 +1,18 @@ +CMake Error at nested-incompatible-genex.cmake:[0-9]+ \(add_library\): + Error evaluating generator expression: + + \$<LINK_LIBRARY:feat,\$<LINK_GROUP:feat,foo>> + + \$<LINK_GROUP:...> cannot be nested inside a \$<LINK_LIBRARY:...> expression. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Error at nested-incompatible-genex.cmake:[0-9]+ \(target_link_libraries\): + Error evaluating generator expression: + + \$<LINK_LIBRARY:feat,\$<LINK_GROUP:feat,foo>> + + \$<LINK_GROUP:...> cannot be nested inside a \$<LINK_LIBRARY:...> expression. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex.cmake new file mode 100644 index 0000000..e3f2ade --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex.cmake @@ -0,0 +1,6 @@ +enable_language(C) + +link_libraries("$<LINK_LIBRARY:feat,$<LINK_GROUP:feat,foo>>") + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,$<LINK_GROUP:feat,foo>>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments-stderr.txt new file mode 100644 index 0000000..63c2648 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at no-arguments.cmake:[0-9]+ \(target_link_libraries\): + Error evaluating generator expression: + + \$<LINK_GROUP> + + \$<LINK_GROUP> expression requires at least one parameter. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments.cmake new file mode 100644 index 0000000..ffc1381 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_GROUP>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/only-targets-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/only-targets-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/only-targets-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/only-targets-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/only-targets-stderr.txt new file mode 100644 index 0000000..6b770f0 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/only-targets-stderr.txt @@ -0,0 +1,13 @@ +CMake Error at only-targets.cmake:[0-9]+ \(target_link_libraries\): + Target "lib2" has LINK_LIBRARIES_ONLY_TARGETS enabled, but it links to: + + external + + which is not a target. Possible reasons include: + + \* There is a typo in the target name. + \* A find_package call is missing for an IMPORTED target. + \* An ALIAS target is missing. + +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/only-targets.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/only-targets.cmake new file mode 100644 index 0000000..8501f1d --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/only-targets.cmake @@ -0,0 +1,16 @@ +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--end") + +set(CMAKE_LINK_LIBRARIES_ONLY_TARGETS 1) + +add_library(dep1 SHARED empty.c) + +add_library(lib1 SHARED empty.c) +# accepted +target_link_libraries(lib1 PRIVATE "$<LINK_GROUP:feat,dep1>") + +add_library(lib2 SHARED empty.c) +# invalid +target_link_libraries(lib2 PRIVATE "$<LINK_GROUP:feat,external>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/override-library-features1.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/override-library-features1.cmake new file mode 100644 index 0000000..127e73f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/override-library-features1.cmake @@ -0,0 +1,4 @@ + +include(incompatible-library-features1.cmake) + +set_property(TARGET lib1 PROPERTY LINK_LIBRARY_OVERRIDE "feat1,dep1") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/override-library-features2.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/override-library-features2.cmake new file mode 100644 index 0000000..9ad0bfe --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/override-library-features2.cmake @@ -0,0 +1,4 @@ + +include(incompatible-library-features2.cmake) + +set_property(TARGET lib1 PROPERTY LINK_LIBRARY_OVERRIDE_dep1 "feat1") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories-stderr.txt new file mode 100644 index 0000000..042dd0b --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at target_link_directories.cmake:[0-9]+ \(target_link_directories\): + Error evaluating generator expression: + + \$<LINK_GROUP:feat> + + \$<LINK_GROUP:...> may only be used with binary targets to specify group of + link libraries. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories.cmake new file mode 100644 index 0000000..47a5f9c --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(empty SHARED empty.c) +target_link_directories(empty PRIVATE "$<LINK_GROUP:feat>") diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options-stderr.txt new file mode 100644 index 0000000..7030b9c --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at target_link_options.cmake:[0-9]+ \(target_link_options\): + Error evaluating generator expression: + + \$<LINK_GROUP:FEAT> + + \$<LINK_GROUP:...> may only be used with binary targets to specify group of + link libraries. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options.cmake new file mode 100644 index 0000000..d7dd876 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(empty SHARED empty.c) +target_link_options(empty PRIVATE $<LINK_GROUP:FEAT>) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/CMakeLists.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/CMakeLists.txt new file mode 100644 index 0000000..612169c --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.18...3.22) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/RunCMakeTest.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/RunCMakeTest.cmake new file mode 100644 index 0000000..3fb68d6 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/RunCMakeTest.cmake @@ -0,0 +1,36 @@ +include(RunCMake) + +run_cmake(add_custom_target) +run_cmake(add_custom_command) +run_cmake(add_link_options) +run_cmake(link_directories) +run_cmake(target_link_options) +run_cmake(target_link_directories) +run_cmake(no-arguments) +run_cmake(empty-arguments) +run_cmake(forbidden-arguments) +run_cmake(invalid-feature) +run_cmake(multiple-definitions) +run_cmake(bad-feature1) +run_cmake(bad-feature2) +run_cmake(bad-feature3) +run_cmake(bad-feature4) +run_cmake(bad-feature5) +run_cmake(bad-feature6) +run_cmake(bad-feature7) +run_cmake(feature-not-supported) +run_cmake(library-ignored) +run_cmake(compatible-features) +run_cmake(incompatible-features1) +run_cmake(incompatible-features2) +run_cmake(incompatible-features3) +run_cmake(nested-compatible-features) +run_cmake(nested-incompatible-features) +run_cmake(only-targets) + +# testing target propertes LINK_LIBRARY_OVERRIDE and LINK_LIBRARY_OVERRIDE_<LIBRARY> +run_cmake(override-features1) +run_cmake(override-features2) +run_cmake(override-features3) +run_cmake(override-features4) +run_cmake(override-features5) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command-stderr.txt new file mode 100644 index 0000000..d8ff0eb --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at add_custom_command.cmake:[0-9]+ \(add_custom_command\): + Error evaluating generator expression: + + \$<LINK_LIBRARY:feat> + + \$<LINK_LIBRARY:...> may only be used with binary targets to specify link + libraries. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command.cmake new file mode 100644 index 0000000..3583a67 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command.cmake @@ -0,0 +1,4 @@ +add_custom_target(drive) +add_custom_command(TARGET drive PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E echo "$<LINK_LIBRARY:feat>" +) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target-stderr.txt new file mode 100644 index 0000000..8ca384d --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at add_custom_target.cmake:[0-9]+ \(add_custom_target\): + Error evaluating generator expression: + + \$<LINK_LIBRARY:feat> + + \$<LINK_LIBRARY:...> may only be used with binary targets to specify link + libraries. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target.cmake new file mode 100644 index 0000000..ef00965 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target.cmake @@ -0,0 +1,3 @@ +add_custom_target(drive + COMMAND ${CMAKE_COMMAND} -E echo "$<LINK_LIBRARY:feat>" +) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options-stderr.txt new file mode 100644 index 0000000..399a413 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at add_link_options.cmake:[0-9]+ \(add_link_options\): + Error evaluating generator expression: + + \$<LINK_LIBRARY:feat> + + \$<LINK_LIBRARY:...> may only be used with binary targets to specify link + libraries. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options.cmake new file mode 100644 index 0000000..fdccf95 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options.cmake @@ -0,0 +1,5 @@ +enable_language(C) + +add_link_options("$<LINK_LIBRARY:feat>") + +add_library(empty SHARED empty.c) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1-stderr.txt new file mode 100644 index 0000000..0ff8aca --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at bad-feature1.cmake:[0-9]+ \(add_library\): + Feature 'bad_feat', specified through generator-expression + '\$<LINK_LIBRARY>' to link target 'lib', is not supported for the 'C' link + language. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1.cmake new file mode 100644 index 0000000..5e540cf --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1.cmake @@ -0,0 +1,6 @@ +enable_language(C) + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:bad_feat,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2-stderr.txt new file mode 100644 index 0000000..9e878cc --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at bad-feature2.cmake:[0-9]+ \(add_library\): + Feature 'feat', specified through generator-expression '\$<LINK_LIBRARY>' to + link target 'lib', is not defined for the 'C' link language. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2.cmake new file mode 100644 index 0000000..2c9efce --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2.cmake @@ -0,0 +1,8 @@ +enable_language(C) + +set(CMAKE_C_LINK_LIBRARY_USING_feat_SUPPORTED TRUE) + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3-stderr.txt new file mode 100644 index 0000000..48cf51e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at bad-feature3.cmake:[0-9]+ \(add_library\): + Feature 'feat', specified by variable 'CMAKE_C_LINK_LIBRARY_USING_feat', is + malformed \("<LIBRARY>", "<LIB_ITEM>", or "<LINK_ITEM>" patterns are + missing\) and cannot be used to link target 'lib'. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3.cmake new file mode 100644 index 0000000..dab6a64 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3.cmake @@ -0,0 +1,9 @@ +enable_language(C) + +set(CMAKE_C_LINK_LIBRARY_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat "") + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4-stderr.txt new file mode 100644 index 0000000..c074dd0 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at bad-feature4.cmake:[0-9]+ \(add_library\): + Feature 'feat', specified by variable 'CMAKE_C_LINK_LIBRARY_USING_feat', is + malformed \("<LIBRARY>", "<LIB_ITEM>", or "<LINK_ITEM>" patterns are + missing\) and cannot be used to link target 'lib'. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4.cmake new file mode 100644 index 0000000..6942f7c --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4.cmake @@ -0,0 +1,9 @@ +enable_language(C) + +set(CMAKE_C_LINK_LIBRARY_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat "-opt") + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5-stderr.txt new file mode 100644 index 0000000..6604307 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at bad-feature5.cmake:[0-9]+ \(add_library\): + Feature 'feat', specified by variable 'CMAKE_C_LINK_LIBRARY_USING_feat', is + malformed \(wrong number of elements\) and cannot be used to link target + 'lib'. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5.cmake new file mode 100644 index 0000000..d0a827a --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5.cmake @@ -0,0 +1,9 @@ +enable_language(C) + +set(CMAKE_C_LINK_LIBRARY_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat "-prefix" "<LIBRARY>") + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6-stderr.txt new file mode 100644 index 0000000..9de4ffa --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at bad-feature6.cmake:[0-9]+ \(add_library\): + Feature 'feat', specified by variable 'CMAKE_C_LINK_LIBRARY_USING_feat', is + malformed \("<LIBRARY>", "<LIB_ITEM>", or "<LINK_ITEM>" patterns are missing + for "PATH{}" alternative\) and cannot be used to link target 'lib'. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6.cmake new file mode 100644 index 0000000..04a50f8 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6.cmake @@ -0,0 +1,9 @@ +enable_language(C) + +set(CMAKE_C_LINK_LIBRARY_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat "PATH{}NAME{<LIBRARY>}") + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7-stderr.txt new file mode 100644 index 0000000..9ea9936 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at bad-feature7.cmake:[0-9]+ \(add_library\): + Feature 'feat', specified by variable 'CMAKE_C_LINK_LIBRARY_USING_feat', is + malformed \("<LIBRARY>", "<LIB_ITEM>", or "<LINK_ITEM>" patterns are missing + for "NAME{}" alternative\) and cannot be used to link target 'lib'. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7.cmake new file mode 100644 index 0000000..9659811 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7.cmake @@ -0,0 +1,9 @@ +enable_language(C) + +set(CMAKE_C_LINK_LIBRARY_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat "NAME{}PATH{<LIBRARY>}") + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/compatible-features.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/compatible-features.cmake new file mode 100644 index 0000000..fb88e36 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/compatible-features.cmake @@ -0,0 +1,21 @@ +enable_language(C) + +set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat1 "<LIBRARY>") + +set(CMAKE_C_LINK_LIBRARY_USING_feat2_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat2 "<LIBRARY>") + +add_library(dep1 SHARED empty.c) + +add_library(dep2 SHARED empty.c) +target_link_libraries(dep2 PRIVATE "$<LINK_LIBRARY:feat1,dep1>") + +add_library(dep3 SHARED empty.c) +target_link_libraries(dep3 PUBLIC dep2) + +add_library(lib1 SHARED empty.c) +target_link_libraries(lib1 PRIVATE "$<LINK_LIBRARY:feat2,dep1,dep2>") + +add_library(lib2 SHARED empty.c) +target_link_libraries(lib2 PRIVATE "$<LINK_LIBRARY:DEFAULT,dep2,dep3>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments-stderr.txt new file mode 100644 index 0000000..1530f61 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at empty-arguments.cmake:[0-9]+ \(target_link_libraries\): + Error evaluating generator expression: + + \$<LINK_LIBRARY:,> + + \$<LINK_LIBRARY:...> expects a feature name as first argument. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments.cmake new file mode 100644 index 0000000..c6e2260 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:,>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/empty.c b/Tests/RunCMake/GenEx-LINK_LIBRARY/empty.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/empty.c diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported-stderr.txt new file mode 100644 index 0000000..6067bce --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at feature-not-supported.cmake:[0-9]+ \(add_library\): + Feature 'feat', specified through generator-expression '\$<LINK_LIBRARY>' to + link target 'lib', is not supported for the 'C' link language. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported.cmake new file mode 100644 index 0000000..0d952c2 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported.cmake @@ -0,0 +1,9 @@ +enable_language(C) + +set(CMAKE_C_LINK_LIBRARY_USING_feat_SUPPORTED FALSE) +set(CMAKE_C_LINK_LIBRARY_USING_feat "<LIBRARY>") + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments-stderr.txt new file mode 100644 index 0000000..5245dd8 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments-stderr.txt @@ -0,0 +1,16 @@ +CMake Error at forbidden-arguments.cmake:[0-9]+ \(link_libraries\): + Property LINK_LIBRARIES contains the invalid item "<LINK_LIBRARY:feat>". + The LINK_LIBRARIES property may contain the generator-expression + "\$<LINK_LIBRARY:...>" which may be used to specify how the libraries are + linked. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Error at forbidden-arguments.cmake:[0-9]+ \(target_link_libraries\): + Property LINK_LIBRARIES contains the invalid item "<LINK_LIBRARY:feat>". + The LINK_LIBRARIES property may contain the generator-expression + "\$<LINK_LIBRARY:...>" which may be used to specify how the libraries are + linked. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments.cmake new file mode 100644 index 0000000..1c51c44 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments.cmake @@ -0,0 +1,6 @@ +enable_language(C) + +link_libraries(<LINK_LIBRARY:feat> foo </LINK_LIBRARY:feat>) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE <LINK_LIBRARY:feat> foo </LINK_LIBRARY:feat>) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features1-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features1-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features1-stderr.txt new file mode 100644 index 0000000..1b31faa --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features1-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at incompatible-features1.cmake:[0-9]+ \(add_library\): + Impossible to link target 'lib' because the link item 'dep1', specified + with the feature 'feat1', has already occurred with the feature 'feat2', + which is not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features1.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features1.cmake new file mode 100644 index 0000000..c230c4f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features1.cmake @@ -0,0 +1,15 @@ +enable_language(C) + +set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat1 "<LIBRARY>") + +set(CMAKE_C_LINK_LIBRARY_USING_feat2_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat2 "<LIBRARY>") + +add_library(dep1 SHARED empty.c) + +add_library(dep2 SHARED empty.c) +target_link_libraries(dep2 PUBLIC "$<LINK_LIBRARY:feat1,dep1>") + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat2,dep1,dep2>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features2-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features2-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features2-stderr.txt new file mode 100644 index 0000000..0855481 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features2-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at incompatible-features2.cmake:[0-9]+ \(add_library\): + Impossible to link target 'lib' because the link item 'dep1', specified + without any feature or 'DEFAULT' feature, has already occurred with the + feature 'feat2', which is not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features2.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features2.cmake new file mode 100644 index 0000000..d204ebd --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features2.cmake @@ -0,0 +1,15 @@ +enable_language(C) + +set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat1 "<LIBRARY>") + +set(CMAKE_C_LINK_LIBRARY_USING_feat2_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat2 "<LIBRARY>") + +add_library(dep1 SHARED empty.c) + +add_library(dep2 SHARED empty.c) +target_link_libraries(dep2 PUBLIC dep1) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat2,dep1,dep2>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features3-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features3-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features3-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features3-stderr.txt new file mode 100644 index 0000000..2f40a1d --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features3-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at incompatible-features3.cmake:[0-9]+ \(add_library\): + Impossible to link target 'lib' because the link item 'dep1', specified + with the feature 'feat1', has already occurred without any feature or + 'DEFAULT' feature, which is not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features3.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features3.cmake new file mode 100644 index 0000000..bf79e11 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features3.cmake @@ -0,0 +1,15 @@ +enable_language(C) + +set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat1 "<LIBRARY>") + +set(CMAKE_C_LINK_LIBRARY_USING_feat2_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat2 "<LIBRARY>") + +add_library(dep1 SHARED empty.c) + +add_library(dep2 SHARED empty.c) +target_link_libraries(dep2 PUBLIC "$<LINK_LIBRARY:feat1,dep1>") + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE dep1 dep2) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature-stderr.txt new file mode 100644 index 0000000..fb5cdab --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at invalid-feature.cmake:[0-9]+ \(target_link_libraries\): + Error evaluating generator expression: + + \$<LINK_LIBRARY:feat:invalid,dep> + + The feature name 'feat:invalid' contains invalid characters. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature.cmake new file mode 100644 index 0000000..c49e4cd --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature.cmake @@ -0,0 +1,6 @@ +enable_language(C) + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat:invalid,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored-stderr.txt new file mode 100644 index 0000000..f9a99af --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored-stderr.txt @@ -0,0 +1,14 @@ +CMake Warning \(dev\) at library-ignored.cmake:[0-9]+ \(add_library\): + The feature 'feat', specified as part of a generator-expression + '\$<LINK_LIBRARY:feat>', will not be applied to the INTERFACE library + 'front'. +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 library-ignored.cmake:[0-9]+ \(add_library\): + The feature 'feat', specified as part of a generator-expression + '\$<LINK_LIBRARY:feat>', will not be applied to the OBJECT library 'dep'. +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/GenEx-LINK_LIBRARY/library-ignored.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored.cmake new file mode 100644 index 0000000..a888bb8 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored.cmake @@ -0,0 +1,15 @@ +enable_language(C) + +set(CMAKE_C_LINK_LIBRARY_USING_feat_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat "<LIBRARY>") + +add_library(dep OBJECT empty.c) + +add_library(lib SHARED empty.c) + +add_library(front INTERFACE) +target_link_libraries(front INTERFACE lib) + + +add_library(lib2 SHARED empty.c) +target_link_libraries(lib2 PRIVATE "$<LINK_LIBRARY:feat,front,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories-stderr.txt new file mode 100644 index 0000000..aeb32f2 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at link_directories.cmake:[0-9]+ \(link_directories\): + Error evaluating generator expression: + + \$<LINK_LIBRARY:feat> + + \$<LINK_LIBRARY:...> may only be used with binary targets to specify link + libraries. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories.cmake new file mode 100644 index 0000000..b6d9a36 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories.cmake @@ -0,0 +1,5 @@ +enable_language(C) + +link_directories("$<LINK_LIBRARY:feat>") + +add_library(empty SHARED empty.c) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-definitions-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-definitions-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-definitions-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-definitions-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-definitions-stderr.txt new file mode 100644 index 0000000..26b0bac --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-definitions-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at multiple-definitions.cmake:[0-9]+ \(add_library\): + Feature 'feat', specified through generator-expression '\$<LINK_LIBRARY>' to + link target 'lib', is not supported for the 'C' link language. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-definitions.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-definitions.cmake new file mode 100644 index 0000000..1bd1888 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-definitions.cmake @@ -0,0 +1,12 @@ +enable_language(C) + +# Language specific definition takes precedence over more generic one +set(CMAKE_C_LINK_LIBRARY_USING_feat "<LIBRARY>") +set(CMAKE_C_LINK_LIBRARY_USING_feat_SUPPORTED FALSE) +set(CMAKE_LINK_LIBRARY_USING_feat "<LIBRARY>") +set(CMAKE_LINK_LIBRARY_USING_feat_SUPPORTED TRUE) + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-compatible-features.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-compatible-features.cmake new file mode 100644 index 0000000..561aa09 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-compatible-features.cmake @@ -0,0 +1,11 @@ +enable_language(C) + +set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat1 "<LIBRARY>") + +add_library(dep1 SHARED empty.c) + +add_library(dep2 SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat1,dep1,$<LINK_LIBRARY:feat1,dep2>>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features-stderr.txt new file mode 100644 index 0000000..3f6c504 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at nested-incompatible-features.cmake:[0-9]+ \(target_link_libraries\): + Error evaluating generator expression: + + \$<LINK_LIBRARY:feat2,dep1,\$<LINK_LIBRARY:feat1,dep2>> + + \$<LINK_LIBRARY:...> with different features cannot be nested. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features.cmake new file mode 100644 index 0000000..746638e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features.cmake @@ -0,0 +1,14 @@ +enable_language(C) + +set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat1 "<LIBRARY>") + +set(CMAKE_C_LINK_LIBRARY_USING_feat2_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat2 "<LIBRARY>") + +add_library(dep1 SHARED empty.c) + +add_library(dep2 SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat2,dep1,$<LINK_LIBRARY:feat1,dep2>>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments-stderr.txt new file mode 100644 index 0000000..af58fa0 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at no-arguments.cmake:[0-9]+ \(target_link_libraries\): + Error evaluating generator expression: + + \$<LINK_LIBRARY> + + \$<LINK_LIBRARY> expression requires at least one parameter. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments.cmake new file mode 100644 index 0000000..0645dc7 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets-stderr.txt new file mode 100644 index 0000000..6b770f0 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets-stderr.txt @@ -0,0 +1,13 @@ +CMake Error at only-targets.cmake:[0-9]+ \(target_link_libraries\): + Target "lib2" has LINK_LIBRARIES_ONLY_TARGETS enabled, but it links to: + + external + + which is not a target. Possible reasons include: + + \* There is a typo in the target name. + \* A find_package call is missing for an IMPORTED target. + \* An ALIAS target is missing. + +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets.cmake new file mode 100644 index 0000000..8cec0c3 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets.cmake @@ -0,0 +1,16 @@ +enable_language(C) + +set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat1 "<LIBRARY>") + +set(CMAKE_LINK_LIBRARIES_ONLY_TARGETS 1) + +add_library(dep1 SHARED empty.c) + +add_library(lib1 SHARED empty.c) +# accepted +target_link_libraries(lib1 PRIVATE "$<LINK_LIBRARY:feat1,dep1>") + +add_library(lib2 SHARED empty.c) +# invalid +target_link_libraries(lib2 PRIVATE "$<LINK_LIBRARY:feat1,external>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features1.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features1.cmake new file mode 100644 index 0000000..6306c5d --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features1.cmake @@ -0,0 +1,4 @@ + +include(incompatible-features1.cmake) + +set_property(TARGET lib PROPERTY LINK_LIBRARY_OVERRIDE "feat1,dep1") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features2.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features2.cmake new file mode 100644 index 0000000..aa6ee76 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features2.cmake @@ -0,0 +1,4 @@ + +include(incompatible-features1.cmake) + +set_property(TARGET lib PROPERTY LINK_LIBRARY_OVERRIDE "feat2,dep1") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features3.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features3.cmake new file mode 100644 index 0000000..a1437e6 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features3.cmake @@ -0,0 +1,7 @@ + +include(incompatible-features1.cmake) + +set(CMAKE_C_LINK_LIBRARY_USING_feat3_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat3 "<LIBRARY>") + +set_property(TARGET lib PROPERTY LINK_LIBRARY_OVERRIDE "feat3,dep1") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features4.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features4.cmake new file mode 100644 index 0000000..f34f745 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features4.cmake @@ -0,0 +1,9 @@ + +include(incompatible-features1.cmake) + + +set(CMAKE_C_LINK_LIBRARY_USING_feat3_SUPPORTED TRUE) +set(CMAKE_C_LINK_LIBRARY_USING_feat3 "<LIBRARY>") + +set_property(TARGET lib PROPERTY LINK_LIBRARY_OVERRIDE "feat3,dep1") +set_property(TARGET lib PROPERTY LINK_LIBRARY_OVERRIDE_dep1 feat1) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features5.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features5.cmake new file mode 100644 index 0000000..1406d2a --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features5.cmake @@ -0,0 +1,7 @@ + +include(incompatible-features1.cmake) + + +set_property(TARGET lib PROPERTY LINK_LIBRARY_OVERRIDE "feat1,dep1") +# next property will be ignored because no feature is specified +set_property(TARGET lib PROPERTY LINK_LIBRARY_OVERRIDE_dep1) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories-stderr.txt new file mode 100644 index 0000000..e0c60c4 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at target_link_directories.cmake:[0-9]+ \(target_link_directories\): + Error evaluating generator expression: + + \$<LINK_LIBRARY:feat> + + \$<LINK_LIBRARY:...> may only be used with binary targets to specify link + libraries. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories.cmake new file mode 100644 index 0000000..e8cc670 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(empty SHARED empty.c) +target_link_directories(empty PRIVATE "$<LINK_LIBRARY:feat>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options-stderr.txt new file mode 100644 index 0000000..6c9aab1 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at target_link_options.cmake:[0-9]+ \(target_link_options\): + Error evaluating generator expression: + + \$<LINK_LIBRARY:FEAT> + + \$<LINK_LIBRARY:...> may only be used with binary targets to specify link + libraries. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options.cmake new file mode 100644 index 0000000..a989a53 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(empty SHARED empty.c) +target_link_options(empty PRIVATE "$<LINK_LIBRARY:FEAT>") diff --git a/Tests/RunCMake/PrecompileHeaders/PchIncludedOneLanguage.cmake b/Tests/RunCMake/PrecompileHeaders/PchIncludedOneLanguage.cmake new file mode 100644 index 0000000..dd582ac --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/PchIncludedOneLanguage.cmake @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.16) +project(PchIncludedAllLanguages C CXX) + +if(CMAKE_CXX_COMPILE_OPTIONS_USE_PCH) + add_definitions(-DHAVE_PCH_SUPPORT) +endif() + +add_executable(main + main.cpp + empty.c + pch-included.cpp +) + +target_precompile_headers(main PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/pch.h>) + +enable_testing() +add_test(NAME main COMMAND main) diff --git a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake index a7b3126..fd41e2f 100644 --- a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake +++ b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake @@ -30,4 +30,5 @@ if(RunCMake_GENERATOR MATCHES "Make|Ninja") endif() run_test(PchReuseFromObjLib) run_test(PchIncludedAllLanguages) +run_test(PchIncludedOneLanguage) run_test(PchLibObjLibExe) diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index 9f692ee..f232b1b 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -153,6 +153,7 @@ function(run_cmake test) "|BullseyeCoverage" "|[a-z]+\\([0-9]+\\) malloc:" "|clang[^:]*: warning: the object size sanitizer has no effect at -O0, but is explicitly enabled:" + "|lld-link: warning: procedure symbol record for .* refers to PDB item index [0-9A-Fa-fx]+ which is not a valid function ID record" "|Error kstat returned" "|Hit xcodebuild bug" "|Recompacting log\\.\\.\\." @@ -164,8 +165,9 @@ function(run_cmake test) "|[^\n]*install_name_tool: warning: changes being made to the file will invalidate the code signature in:" "|[^\n]*xcodebuild[^\n]*DVTPlugInManager" + "|[^\n]*xcodebuild[^\n]*Requested but did not find extension point with identifier" "|[^\n]*xcodebuild[^\n]*warning: file type[^\n]*is based on missing file type" - "|[^\n]*objc[^\n]*: Class AMSupportURL[^\n]* One of the two will be used. Which one is undefined." + "|[^\n]*objc[^\n]*: Class [^\n]* One of the two will be used. Which one is undefined." "|[^\n]*is a member of multiple groups" "|[^\n]*offset in archive not a multiple of 8" "|[^\n]*from Time Machine by path" diff --git a/Tests/RunCMake/SymlinkTrees/CMakeLists.txt b/Tests/RunCMake/SymlinkTrees/CMakeLists.txt index d6fea2c..e16faea 100644 --- a/Tests/RunCMake/SymlinkTrees/CMakeLists.txt +++ b/Tests/RunCMake/SymlinkTrees/CMakeLists.txt @@ -1,3 +1,52 @@ cmake_minimum_required(VERSION 2.8.12) project(${RunCMake_TEST} NONE) -include("${include_dir}/${RunCMake_TEST}.cmake") + +message(STATUS "source: '${CMAKE_SOURCE_DIR}'") +message(STATUS "binary: '${CMAKE_BINARY_DIR}'") +get_filename_component(real_source "${CMAKE_SOURCE_DIR}" REALPATH) +get_filename_component(real_binary "${CMAKE_BINARY_DIR}" REALPATH) +message(STATUS "real source: '${real_source}'") +message(STATUS "real binary: '${real_binary}'") + +if(RunCMake_TEST MATCHES "-exe") + enable_language(C) + file(WRITE "${CMAKE_SOURCE_DIR}/source.c" [[ + #include <stdio.h> + #include "source.h" + #include "binary.h" + extern void print_binary_c(void); + extern void print_binary_c(void); + void print_source_c(void) { + printf("source.c: '%s'\n", __FILE__); + } + int main(void) { + print_source_c(); + print_source_h(); + print_binary_c(); + print_binary_h(); + return 0; + } + ]]) + file(WRITE "${CMAKE_BINARY_DIR}/binary.c" [[ + #include <stdio.h> + void print_binary_c(void) { + printf("binary.c: '%s'\n", __FILE__); + } + ]]) + file(WRITE "${CMAKE_SOURCE_DIR}/include/source.h" [[ + void print_source_h(void) { + printf("source.h: '%s'\n", __FILE__); + } + ]]) + file(WRITE "${CMAKE_BINARY_DIR}/include/binary.h" [[ + void print_binary_h(void) { + printf("binary.h: '%s'\n", __FILE__); + } + ]]) + add_executable(exe source.c ${CMAKE_BINARY_DIR}/binary.c) + target_include_directories(exe PRIVATE + ${CMAKE_SOURCE_DIR}/include + ${CMAKE_BINARY_DIR}/include + ) + add_custom_target(print ALL COMMAND exe) +endif() diff --git a/Tests/RunCMake/SymlinkTrees/PrintTrees.cmake b/Tests/RunCMake/SymlinkTrees/PrintTrees.cmake deleted file mode 100644 index aa99127..0000000 --- a/Tests/RunCMake/SymlinkTrees/PrintTrees.cmake +++ /dev/null @@ -1,6 +0,0 @@ -message(STATUS "source: '${CMAKE_SOURCE_DIR}'") -message(STATUS "binary: '${CMAKE_BINARY_DIR}'") -get_filename_component(real_source "${CMAKE_SOURCE_DIR}" REALPATH) -get_filename_component(real_binary "${CMAKE_BINARY_DIR}" REALPATH) -message(STATUS "real source: '${real_source}'") -message(STATUS "real binary: '${real_binary}'") diff --git a/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake b/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake index e5f1f7f..e5bfac4 100644 --- a/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake +++ b/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake @@ -1,34 +1,234 @@ include(RunCMake) +function(run_symlink_test_case) + file(REMOVE_RECURSE + "${RunCMake_TEST_BINARY_DIR}/CMakeCache.txt" + "${RunCMake_TEST_BINARY_DIR}/CMakeFiles" + ) + run_cmake_with_options(${ARGN}) +endfunction() + # This function assumes that ``${RunCMake_BINARY_DIR}/${name}/source`` and # ``${RunCMake_BINARY_DIR}/${name}/binary`` are set up properly prior to # calling it. -function (run_symlink_test name) +function (run_symlink_test case src bin src_from_bin bin_from_src) + string(REGEX REPLACE "-.*" "" name "${case}") set(RunCMake_TEST_NO_CLEAN TRUE) + set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/${name}/${src}") + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${name}/${bin}") configure_file( "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" - "${RunCMake_BINARY_DIR}/${name}/source/CMakeLists.txt" + "${RunCMake_TEST_SOURCE_DIR}/CMakeLists.txt" COPYONLY) - set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/${name}/source") - set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${name}/binary") + + # We explicitly pass the source directory argument for each case. + set(RunCMake_TEST_NO_SOURCE_DIR 1) + + # Test running in binary directory. + set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") # Emulate a shell using this directory. - set(ENV{PWD} "${RunCMake_TEST_BINARY_DIR}") - set(RunCMake_TEST_OPTIONS - "-Dinclude_dir:PATH=${CMAKE_CURRENT_LIST_DIR}") - run_cmake("${name}_symlinks") + set(ENV{PWD} "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}") + + # Pass absolute path to the source tree, plain. + set(RunCMake_TEST_VARIANT_DESCRIPTION " $abs/${name}/${src}") + run_symlink_test_case("${case}" "${RunCMake_TEST_SOURCE_DIR}") + + # Pass absolute path to the source tree, with -S. + set(RunCMake_TEST_VARIANT_DESCRIPTION " -S $abs/${name}/${src}") + run_symlink_test_case("${case}" -S "${RunCMake_TEST_SOURCE_DIR}") + + # Pass relative path to the source tree, plain. + set(RunCMake_TEST_VARIANT_DESCRIPTION " ${src_from_bin}") + run_symlink_test_case("${case}" "${src_from_bin}") + + # Pass relative path to the source tree, with -S. + set(RunCMake_TEST_VARIANT_DESCRIPTION " -S ${src_from_bin}") + run_symlink_test_case("${case}" -S "${src_from_bin}") + + # Test running in source directory. + set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_TEST_SOURCE_DIR}") + # Emulate a shell using this directory. + set(ENV{PWD} "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}") + + # Pass absolute path to the binary tree with -B. + set(RunCMake_TEST_VARIANT_DESCRIPTION " -B $abs/${name}/${bin}") + run_symlink_test_case("${case}" -B "${RunCMake_TEST_BINARY_DIR}") + + # Pass relative path to the binary tree with -B. + set(RunCMake_TEST_VARIANT_DESCRIPTION " -B ${bin_from_src}") + run_symlink_test_case("${case}" -B "${bin_from_src}") + + # Test running in another directory. + set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_BINARY_DIR}/${name}") + # Emulate a shell using this directory. + set(ENV{PWD} "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}") + + # Pass absolute paths to the source and binary trees. + set(RunCMake_TEST_VARIANT_DESCRIPTION " -S $abs/${name}/${src} -B $abs/${name}/${bin}") + run_symlink_test_case("${case}" -S "${RunCMake_TEST_SOURCE_DIR}" -B "${RunCMake_TEST_BINARY_DIR}") + + # Pass relative paths to the source and binary trees. + set(RunCMake_TEST_VARIANT_DESCRIPTION " -S ${src} -B ${bin}") + run_symlink_test_case("${case}" -S "${src}" -B "${bin}") + + # Pass relative paths to the source and binary trees. + set(RunCMake_TEST_VARIANT_DESCRIPTION " -S ../${name}/${src} -B ../${name}/${bin}") + run_symlink_test_case("${case}" -S "../${name}/${src}" -B "../${name}/${bin}") + + # Verify paths passed to compiler. + unset(RunCMake_TEST_VARIANT_DESCRIPTION) + run_symlink_test_case("${case}-exe" -S "${src}" -B "${bin}") + if (RunCMake_GENERATOR MATCHES "Xcode") + # The native build system may pass the real paths. + set(RunCMake-stdout-file "generic-exe-build-stdout.txt") + endif() + set(RunCMake_TEST_OUTPUT_MERGE 1) + run_cmake_command("${case}-exe-build" ${CMAKE_COMMAND} --build "${bin}") endfunction () # Create the following structure: # +# .../none/source +# .../none/binary +file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/none") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/none/source") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/none/binary") +run_symlink_test(none-separate "source" "binary" "../source" "../binary") + +# Create the following structure: +# +# .../none/source +# .../none/source/binary +file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/none") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/none/source") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/none/source/binary") +run_symlink_test(none-bin_in_src "source" "source/binary" ".." "binary") + +# Create the following structure: +# +# .../none/binary +# .../none/binary/source +file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/none") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/none/binary") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/none/binary/source") +run_symlink_test(none-src_in_bin "binary/source" "binary" "source" "..") + +# Create the following structure: +# # .../common_real/source # .../common_real/binary # .../common -> common_real +file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/common_real") +file(REMOVE "${RunCMake_BINARY_DIR}/common") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/common_real/source") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/common_real/binary") +file(CREATE_LINK "common_real" "${RunCMake_BINARY_DIR}/common" SYMBOLIC) +run_symlink_test(common-separate "source" "binary" "../source" "../binary") + +# Create the following structure: # -# In this case, CMake should act as if .../common *is* .../common_real for all -# computations except ``REALPATH``. This supports the case where a system has -# a stable *symlink*, but not a stable target for that symlink. +# .../common_real/source +# .../common_real/source/binary +# .../common -> common_real file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/common_real") file(REMOVE "${RunCMake_BINARY_DIR}/common") file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/common_real/source") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/common_real/source/binary") file(CREATE_LINK "common_real" "${RunCMake_BINARY_DIR}/common" SYMBOLIC) -run_symlink_test(common) +run_symlink_test(common-bin_in_src "source" "source/binary" ".." "binary") + +# Create the following structure: +# +# .../common_real/binary +# .../common_real/binary/source +# .../common -> common_real +file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/common_real") +file(REMOVE "${RunCMake_BINARY_DIR}/common") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/common_real/binary") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/common_real/binary/source") +file(CREATE_LINK "common_real" "${RunCMake_BINARY_DIR}/common" SYMBOLIC) +run_symlink_test(common-src_in_bin "binary/source" "binary" "source" "..") + +# Create the following structure: +# +# .../different_src/source_real +# .../different_bin/binary_real +# .../different/source -> ../different_src/source_real +# .../different/binary -> ../different_bin/binary_real +file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/different") +file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/different_src") +file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/different_bin") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/different") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/different_src/source_real") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/different_bin/binary_real") +file(CREATE_LINK "../different_src/source_real" "${RunCMake_BINARY_DIR}/different/source" SYMBOLIC) +file(CREATE_LINK "../different_bin/binary_real" "${RunCMake_BINARY_DIR}/different/binary" SYMBOLIC) +run_symlink_test(different-separate "source" "binary" "../../different/source" "../../different/binary") + +# Create the following structure: +# +# .../different_src/source_real +# .../different_bin/binary_real +# .../different/source -> ../different_src/source_real +# .../different_src/source_real/binary -> ../../different_bin/binary_real +file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/different") +file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/different_src") +file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/different_bin") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/different") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/different_src/source_real") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/different_bin/binary_real") +file(CREATE_LINK "../different_src/source_real" "${RunCMake_BINARY_DIR}/different/source" SYMBOLIC) +file(CREATE_LINK "../../different_bin/binary_real" "${RunCMake_BINARY_DIR}/different_src/source_real/binary" SYMBOLIC) +run_symlink_test(different-bin_in_src "source" "source/binary" "../../different/source" "binary") + +# Create the following structure: +# +# .../different_src/source_real +# .../different_bin/binary_real +# .../different/binary -> ../different_bin/binary_real +# .../different_bin/binary_real/source -> ../../different_src/source_real +file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/different") +file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/different_src") +file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/different_bin") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/different") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/different_src/source_real") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/different_bin/binary_real") +file(CREATE_LINK "../different_bin/binary_real" "${RunCMake_BINARY_DIR}/different/binary" SYMBOLIC) +file(CREATE_LINK "../../different_src/source_real" "${RunCMake_BINARY_DIR}/different_bin/binary_real/source" SYMBOLIC) +run_symlink_test(different-src_in_bin "binary/source" "binary" "source" "../../different/binary") + +# Create the following structure: +# +# .../asymmetric_real/path/binary +# .../asymmetric/source +# .../asymmetric/binary -> ../asymmetric_real/path/binary +file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/asymmetric") +file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/asymmetric_real") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/asymmetric/source") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/asymmetric_real/path/binary") +file(CREATE_LINK "../asymmetric_real/path/binary" "${RunCMake_BINARY_DIR}/asymmetric/binary" SYMBOLIC) +run_symlink_test(asymmetric-separate "source" "binary" "../../../asymmetric/source" "../binary") + +# Create the following structure: +# +# .../asymmetric_real/path/binary +# .../asymmetric/source +# .../asymmetric/source/binary -> ../../asymmetric_real/path/binary +file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/asymmetric") +file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/asymmetric_real") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/asymmetric/source") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/asymmetric_real/path/binary") +file(CREATE_LINK "../../asymmetric_real/path/binary" "${RunCMake_BINARY_DIR}/asymmetric/source/binary" SYMBOLIC) +run_symlink_test(asymmetric-bin_in_src "source" "source/binary" "../../../asymmetric/source" "binary") + +# Create the following structure: +# +# .../asymmetric_real/path/source +# .../asymmetric/binary +# .../asymmetric/binary/source -> ../../asymmetric_real/path/source +file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/asymmetric") +file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/asymmetric_real") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/asymmetric/binary") +file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/asymmetric_real/path/source") +file(CREATE_LINK "../../asymmetric_real/path/source" "${RunCMake_BINARY_DIR}/asymmetric/binary/source" SYMBOLIC) +run_symlink_test(asymmetric-src_in_bin "binary/source" "binary" "source" "../../../asymmetric/binary") diff --git a/Tests/RunCMake/SymlinkTrees/asymmetric-bin_in_src-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/asymmetric-bin_in_src-exe-build-stdout.txt new file mode 100644 index 0000000..450d9f1 --- /dev/null +++ b/Tests/RunCMake/SymlinkTrees/asymmetric-bin_in_src-exe-build-stdout.txt @@ -0,0 +1,4 @@ +source.c: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/source/source.c' +source.h: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/source/include/source.h' +binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/source/binary/binary.c' +binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/source/binary/include/binary.h' diff --git a/Tests/RunCMake/SymlinkTrees/asymmetric-bin_in_src-stdout.txt b/Tests/RunCMake/SymlinkTrees/asymmetric-bin_in_src-stdout.txt new file mode 100644 index 0000000..bc19ac9 --- /dev/null +++ b/Tests/RunCMake/SymlinkTrees/asymmetric-bin_in_src-stdout.txt @@ -0,0 +1,4 @@ +-- source: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/source' +-- binary: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/source/binary' +-- real source: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/source' +-- real binary: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric_real/path/binary' diff --git a/Tests/RunCMake/SymlinkTrees/asymmetric-separate-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/asymmetric-separate-exe-build-stdout.txt new file mode 100644 index 0000000..c1ad9d7 --- /dev/null +++ b/Tests/RunCMake/SymlinkTrees/asymmetric-separate-exe-build-stdout.txt @@ -0,0 +1,4 @@ +source.c: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/source/source.c' +source.h: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/source/include/source.h' +binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/binary/binary.c' +binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/binary/include/binary.h' diff --git a/Tests/RunCMake/SymlinkTrees/asymmetric-separate-stdout.txt b/Tests/RunCMake/SymlinkTrees/asymmetric-separate-stdout.txt new file mode 100644 index 0000000..f103630 --- /dev/null +++ b/Tests/RunCMake/SymlinkTrees/asymmetric-separate-stdout.txt @@ -0,0 +1,4 @@ +-- source: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/source' +-- binary: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/binary' +-- real source: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/source' +-- real binary: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric_real/path/binary' diff --git a/Tests/RunCMake/SymlinkTrees/asymmetric-src_in_bin-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/asymmetric-src_in_bin-exe-build-stdout.txt new file mode 100644 index 0000000..4a33651 --- /dev/null +++ b/Tests/RunCMake/SymlinkTrees/asymmetric-src_in_bin-exe-build-stdout.txt @@ -0,0 +1,4 @@ +source.c: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/binary/source/source.c' +source.h: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/binary/source/include/source.h' +binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/binary/binary.c' +binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/binary/include/binary.h' diff --git a/Tests/RunCMake/SymlinkTrees/asymmetric-src_in_bin-stdout.txt b/Tests/RunCMake/SymlinkTrees/asymmetric-src_in_bin-stdout.txt new file mode 100644 index 0000000..6b6bf11 --- /dev/null +++ b/Tests/RunCMake/SymlinkTrees/asymmetric-src_in_bin-stdout.txt @@ -0,0 +1,4 @@ +-- source: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/binary/source' +-- binary: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/binary' +-- real source: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric_real/path/source' +-- real binary: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/binary' diff --git a/Tests/RunCMake/SymlinkTrees/common-bin_in_src-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/common-bin_in_src-exe-build-stdout.txt new file mode 100644 index 0000000..d72e250 --- /dev/null +++ b/Tests/RunCMake/SymlinkTrees/common-bin_in_src-exe-build-stdout.txt @@ -0,0 +1,4 @@ +source.c: '[^']*/Tests/RunCMake/SymlinkTrees/common/source/source.c' +source.h: '[^']*/Tests/RunCMake/SymlinkTrees/common/source/include/source.h' +binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/common/source/binary/binary.c' +binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/common/source/binary/include/binary.h' diff --git a/Tests/RunCMake/SymlinkTrees/common-bin_in_src-stdout.txt b/Tests/RunCMake/SymlinkTrees/common-bin_in_src-stdout.txt new file mode 100644 index 0000000..90dcf02 --- /dev/null +++ b/Tests/RunCMake/SymlinkTrees/common-bin_in_src-stdout.txt @@ -0,0 +1,4 @@ +-- source: '[^']*/Tests/RunCMake/SymlinkTrees/common/source' +-- binary: '[^']*/Tests/RunCMake/SymlinkTrees/common/source/binary' +-- real source: '[^']*/Tests/RunCMake/SymlinkTrees/common_real/source' +-- real binary: '[^']*/Tests/RunCMake/SymlinkTrees/common_real/source/binary' diff --git a/Tests/RunCMake/SymlinkTrees/common-separate-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/common-separate-exe-build-stdout.txt new file mode 100644 index 0000000..7f73af2 --- /dev/null +++ b/Tests/RunCMake/SymlinkTrees/common-separate-exe-build-stdout.txt @@ -0,0 +1,4 @@ +source.c: '[^']*/Tests/RunCMake/SymlinkTrees/common/source/source.c' +source.h: '[^']*/Tests/RunCMake/SymlinkTrees/common/source/include/source.h' +binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/common/binary/binary.c' +binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/common/binary/include/binary.h' diff --git a/Tests/RunCMake/SymlinkTrees/common_symlinks-stdout.txt b/Tests/RunCMake/SymlinkTrees/common-separate-stdout.txt index bb04450..bb04450 100644 --- a/Tests/RunCMake/SymlinkTrees/common_symlinks-stdout.txt +++ b/Tests/RunCMake/SymlinkTrees/common-separate-stdout.txt diff --git a/Tests/RunCMake/SymlinkTrees/common-src_in_bin-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/common-src_in_bin-exe-build-stdout.txt new file mode 100644 index 0000000..aa0d60a --- /dev/null +++ b/Tests/RunCMake/SymlinkTrees/common-src_in_bin-exe-build-stdout.txt @@ -0,0 +1,4 @@ +source.c: '[^']*/Tests/RunCMake/SymlinkTrees/common/binary/source/source.c' +source.h: '[^']*/Tests/RunCMake/SymlinkTrees/common/binary/source/include/source.h' +binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/common/binary/binary.c' +binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/common/binary/include/binary.h' diff --git a/Tests/RunCMake/SymlinkTrees/common-src_in_bin-stdout.txt b/Tests/RunCMake/SymlinkTrees/common-src_in_bin-stdout.txt new file mode 100644 index 0000000..fc9db21 --- /dev/null +++ b/Tests/RunCMake/SymlinkTrees/common-src_in_bin-stdout.txt @@ -0,0 +1,4 @@ +-- source: '[^']*/Tests/RunCMake/SymlinkTrees/common/binary/source' +-- binary: '[^']*/Tests/RunCMake/SymlinkTrees/common/binary' +-- real source: '[^']*/Tests/RunCMake/SymlinkTrees/common_real/binary/source' +-- real binary: '[^']*/Tests/RunCMake/SymlinkTrees/common_real/binary' diff --git a/Tests/RunCMake/SymlinkTrees/common_symlinks.cmake b/Tests/RunCMake/SymlinkTrees/common_symlinks.cmake deleted file mode 100644 index 5eafe26..0000000 --- a/Tests/RunCMake/SymlinkTrees/common_symlinks.cmake +++ /dev/null @@ -1 +0,0 @@ -include("${CMAKE_CURRENT_LIST_DIR}/PrintTrees.cmake") diff --git a/Tests/RunCMake/SymlinkTrees/different-bin_in_src-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/different-bin_in_src-exe-build-stdout.txt new file mode 100644 index 0000000..1bd1559 --- /dev/null +++ b/Tests/RunCMake/SymlinkTrees/different-bin_in_src-exe-build-stdout.txt @@ -0,0 +1,4 @@ +source.c: '[^']*/Tests/RunCMake/SymlinkTrees/different/source/source.c' +source.h: '[^']*/Tests/RunCMake/SymlinkTrees/different/source/include/source.h' +binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/different/source/binary/binary.c' +binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/different/source/binary/include/binary.h' diff --git a/Tests/RunCMake/SymlinkTrees/different-bin_in_src-stdout.txt b/Tests/RunCMake/SymlinkTrees/different-bin_in_src-stdout.txt new file mode 100644 index 0000000..0533872 --- /dev/null +++ b/Tests/RunCMake/SymlinkTrees/different-bin_in_src-stdout.txt @@ -0,0 +1,4 @@ +-- source: '[^']*/Tests/RunCMake/SymlinkTrees/different/source' +-- binary: '[^']*/Tests/RunCMake/SymlinkTrees/different/source/binary' +-- real source: '[^']*/Tests/RunCMake/SymlinkTrees/different_src/source_real' +-- real binary: '[^']*/Tests/RunCMake/SymlinkTrees/different_bin/binary_real' diff --git a/Tests/RunCMake/SymlinkTrees/different-separate-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/different-separate-exe-build-stdout.txt new file mode 100644 index 0000000..e598725 --- /dev/null +++ b/Tests/RunCMake/SymlinkTrees/different-separate-exe-build-stdout.txt @@ -0,0 +1,4 @@ +source.c: '[^']*/Tests/RunCMake/SymlinkTrees/different/source/source.c' +source.h: '[^']*/Tests/RunCMake/SymlinkTrees/different/source/include/source.h' +binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/different/binary/binary.c' +binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/different/binary/include/binary.h' diff --git a/Tests/RunCMake/SymlinkTrees/different-separate-stdout.txt b/Tests/RunCMake/SymlinkTrees/different-separate-stdout.txt new file mode 100644 index 0000000..fe9c472 --- /dev/null +++ b/Tests/RunCMake/SymlinkTrees/different-separate-stdout.txt @@ -0,0 +1,4 @@ +-- source: '[^']*/Tests/RunCMake/SymlinkTrees/different/source' +-- binary: '[^']*/Tests/RunCMake/SymlinkTrees/different/binary' +-- real source: '[^']*/Tests/RunCMake/SymlinkTrees/different_src/source_real' +-- real binary: '[^']*/Tests/RunCMake/SymlinkTrees/different_bin/binary_real' diff --git a/Tests/RunCMake/SymlinkTrees/different-src_in_bin-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/different-src_in_bin-exe-build-stdout.txt new file mode 100644 index 0000000..a5a2111 --- /dev/null +++ b/Tests/RunCMake/SymlinkTrees/different-src_in_bin-exe-build-stdout.txt @@ -0,0 +1,4 @@ +source.c: '[^']*/Tests/RunCMake/SymlinkTrees/different/binary/source/source.c' +source.h: '[^']*/Tests/RunCMake/SymlinkTrees/different/binary/source/include/source.h' +binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/different/binary/binary.c' +binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/different/binary/include/binary.h' diff --git a/Tests/RunCMake/SymlinkTrees/different-src_in_bin-stdout.txt b/Tests/RunCMake/SymlinkTrees/different-src_in_bin-stdout.txt new file mode 100644 index 0000000..248e820 --- /dev/null +++ b/Tests/RunCMake/SymlinkTrees/different-src_in_bin-stdout.txt @@ -0,0 +1,4 @@ +-- source: '[^']*/Tests/RunCMake/SymlinkTrees/different/binary/source' +-- binary: '[^']*/Tests/RunCMake/SymlinkTrees/different/binary' +-- real source: '[^']*/Tests/RunCMake/SymlinkTrees/different_src/source_real' +-- real binary: '[^']*/Tests/RunCMake/SymlinkTrees/different_bin/binary_real' diff --git a/Tests/RunCMake/SymlinkTrees/generic-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/generic-exe-build-stdout.txt new file mode 100644 index 0000000..db2173c --- /dev/null +++ b/Tests/RunCMake/SymlinkTrees/generic-exe-build-stdout.txt @@ -0,0 +1,4 @@ +source.c: '[^']*/Tests/RunCMake/SymlinkTrees/[^']*/source.c' +source.h: '[^']*/Tests/RunCMake/SymlinkTrees/[^']*/include/source.h' +binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/[^']*/binary.c' +binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/[^']*/include/binary.h' diff --git a/Tests/RunCMake/SymlinkTrees/none-bin_in_src-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/none-bin_in_src-exe-build-stdout.txt new file mode 100644 index 0000000..520d8a8 --- /dev/null +++ b/Tests/RunCMake/SymlinkTrees/none-bin_in_src-exe-build-stdout.txt @@ -0,0 +1,4 @@ +source.c: '[^']*/Tests/RunCMake/SymlinkTrees/none/source/source.c' +source.h: '[^']*/Tests/RunCMake/SymlinkTrees/none/source/include/source.h' +binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/none/source/binary/binary.c' +binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/none/source/binary/include/binary.h' diff --git a/Tests/RunCMake/SymlinkTrees/none-bin_in_src-stdout.txt b/Tests/RunCMake/SymlinkTrees/none-bin_in_src-stdout.txt new file mode 100644 index 0000000..6d6af52 --- /dev/null +++ b/Tests/RunCMake/SymlinkTrees/none-bin_in_src-stdout.txt @@ -0,0 +1,4 @@ +-- source: '[^']*/Tests/RunCMake/SymlinkTrees/none/source' +-- binary: '[^']*/Tests/RunCMake/SymlinkTrees/none/source/binary' +-- real source: '[^']*/Tests/RunCMake/SymlinkTrees/none/source' +-- real binary: '[^']*/Tests/RunCMake/SymlinkTrees/none/source/binary' diff --git a/Tests/RunCMake/SymlinkTrees/none-separate-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/none-separate-exe-build-stdout.txt new file mode 100644 index 0000000..90791d4 --- /dev/null +++ b/Tests/RunCMake/SymlinkTrees/none-separate-exe-build-stdout.txt @@ -0,0 +1,4 @@ +source.c: '[^']*/Tests/RunCMake/SymlinkTrees/none/source/source.c' +source.h: '[^']*/Tests/RunCMake/SymlinkTrees/none/source/include/source.h' +binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/none/binary/binary.c' +binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/none/binary/include/binary.h' diff --git a/Tests/RunCMake/SymlinkTrees/none-separate-stdout.txt b/Tests/RunCMake/SymlinkTrees/none-separate-stdout.txt new file mode 100644 index 0000000..2251ac5 --- /dev/null +++ b/Tests/RunCMake/SymlinkTrees/none-separate-stdout.txt @@ -0,0 +1,4 @@ +-- source: '[^']*/Tests/RunCMake/SymlinkTrees/none/source' +-- binary: '[^']*/Tests/RunCMake/SymlinkTrees/none/binary' +-- real source: '[^']*/Tests/RunCMake/SymlinkTrees/none/source' +-- real binary: '[^']*/Tests/RunCMake/SymlinkTrees/none/binary' diff --git a/Tests/RunCMake/SymlinkTrees/none-src_in_bin-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/none-src_in_bin-exe-build-stdout.txt new file mode 100644 index 0000000..07aed79 --- /dev/null +++ b/Tests/RunCMake/SymlinkTrees/none-src_in_bin-exe-build-stdout.txt @@ -0,0 +1,4 @@ +source.c: '[^']*/Tests/RunCMake/SymlinkTrees/none/binary/source/source.c' +source.h: '[^']*/Tests/RunCMake/SymlinkTrees/none/binary/source/include/source.h' +binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/none/binary/binary.c' +binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/none/binary/include/binary.h' diff --git a/Tests/RunCMake/SymlinkTrees/none-src_in_bin-stdout.txt b/Tests/RunCMake/SymlinkTrees/none-src_in_bin-stdout.txt new file mode 100644 index 0000000..731d62a --- /dev/null +++ b/Tests/RunCMake/SymlinkTrees/none-src_in_bin-stdout.txt @@ -0,0 +1,4 @@ +-- source: '[^']*/Tests/RunCMake/SymlinkTrees/none/binary/source' +-- binary: '[^']*/Tests/RunCMake/SymlinkTrees/none/binary' +-- real source: '[^']*/Tests/RunCMake/SymlinkTrees/none/binary/source' +-- real binary: '[^']*/Tests/RunCMake/SymlinkTrees/none/binary' diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt index 3846d7c..97c3394 100644 --- a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt +++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt @@ -35,6 +35,7 @@ \* CMP0112 \* CMP0113 \* CMP0119 + \* CMP0131 Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index 139dcc7..273b9d5 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -35,6 +35,7 @@ run_cmake(VsProjectImport) run_cmake(VsPackageReferences) run_cmake(VsDpiAware) run_cmake(VsDpiAwareBadParam) +run_cmake(VsForceInclude) run_cmake(VsPrecompileHeaders) run_cmake(VsPrecompileHeadersReuseFromCompilePDBName) run_cmake(VsDeployEnabled) @@ -84,3 +85,4 @@ endif() run_cmake(VsDotnetTargetFramework) run_cmake(VsDotnetTargetFrameworkVersion) +run_cmake(VsNoCompileBatching) diff --git a/Tests/RunCMake/VS10Project/VsForceInclude-check.cmake b/Tests/RunCMake/VS10Project/VsForceInclude-check.cmake new file mode 100644 index 0000000..8906e92 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsForceInclude-check.cmake @@ -0,0 +1,18 @@ +set(tgt_project "${RunCMake_TEST_BINARY_DIR}/tgt.vcxproj") +if (NOT EXISTS "${tgt_project}") + set(RunCMake_TEST_FAILED "Generated project file does not exist:\n ${tgt_project}\n") + return() +endif() + +file(STRINGS ${tgt_project} tgt_projects_strings REGEX ForcedIncludeFiles) + +foreach(line IN LISTS tgt_projects_strings) + if (line MATCHES "<ForcedIncludeFiles>force_include_1.h;force_include_2.h</ForcedIncludeFiles>") + set(have_FI ON) + endif() +endforeach() + +if (NOT have_FI) + set(RunCMake_TEST_FAILED "Generated project does not have expected ForcedIncludeFiles.") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsForceInclude.cmake b/Tests/RunCMake/VS10Project/VsForceInclude.cmake new file mode 100644 index 0000000..fa1f544 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsForceInclude.cmake @@ -0,0 +1,5 @@ +enable_language(CXX) + +add_library(tgt STATIC empty.cxx) +target_compile_options(tgt PRIVATE "SHELL:/FI force_include_1.h") +target_compile_options(tgt PRIVATE "/FIforce_include_2.h") diff --git a/Tests/RunCMake/VS10Project/VsNoCompileBatching-check.cmake b/Tests/RunCMake/VS10Project/VsNoCompileBatching-check.cmake new file mode 100644 index 0000000..4002c3f --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsNoCompileBatching-check.cmake @@ -0,0 +1,31 @@ +macro(VsNoCompileBatching_check tgt ofn_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_OFN 0) + + file(STRINGS "${vcProjectFile}" lines) + foreach(line IN LISTS lines) + if(line MATCHES "^ *<ObjectFileName>([^<>]+)</ObjectFileName>") + set(ofn_actual "${CMAKE_MATCH_1}") + if(NOT "${ofn_actual}" STREQUAL "${ofn_expect}") + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj has <ObjectFileName> '${ofn_actual}', not '${ofn_expect}'.") + return() + endif() + set(HAVE_OFN 1) + break() + endif() + endforeach() + + if(NOT HAVE_OFN) + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not have a <ObjectFileName> property.") + return() + endif() +endmacro() + +VsNoCompileBatching_check(foo "$(IntDir)") +VsNoCompileBatching_check(foo_NB "$(IntDir)%(filename).obj") +VsNoCompileBatching_check(foo_NB_OFF "$(IntDir)") diff --git a/Tests/RunCMake/VS10Project/VsNoCompileBatching.cmake b/Tests/RunCMake/VS10Project/VsNoCompileBatching.cmake new file mode 100644 index 0000000..c96edce --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsNoCompileBatching.cmake @@ -0,0 +1,9 @@ +enable_language(CXX) + +add_library(foo foo.cpp) + +add_library(foo_NB foo.cpp) +set_property(TARGET foo_NB PROPERTY VS_NO_COMPILE_BATCHING ON) + +add_library(foo_NB_OFF foo.cpp) +set_property(TARGET foo_NB_OFF PROPERTY VS_NO_COMPILE_BATCHING OFF) diff --git a/Tests/RunCMake/VerifyHeaderSets/CMakeLists.txt b/Tests/RunCMake/VerifyHeaderSets/CMakeLists.txt new file mode 100644 index 0000000..5ff8d3e --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.23) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/VerifyHeaderSets/RunCMakeTest.cmake b/Tests/RunCMake/VerifyHeaderSets/RunCMakeTest.cmake new file mode 100644 index 0000000..06d48bf --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/RunCMakeTest.cmake @@ -0,0 +1,42 @@ +include(RunCMake) + +function(run_cmake_build name target) + if(NOT BUILD_CONFIG) + set(BUILD_CONFIG Debug) + endif() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${name}-build) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(${name}-${target}-${BUILD_CONFIG}-build ${CMAKE_COMMAND} --build . --config ${BUILD_CONFIG} --target ${target}) +endfunction() + +set(RunCMake_TEST_OPTIONS -DCMAKE_VERIFY_HEADER_SETS=ON) +if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) +endif() +run_cmake(VerifyHeaderSets) +unset(RunCMake_TEST_OPTIONS) + +run_cmake_build(VerifyHeaderSets static_verify_header_sets) +run_cmake_build(VerifyHeaderSets shared_verify_header_sets) +run_cmake_build(VerifyHeaderSets object_verify_header_sets) +run_cmake_build(VerifyHeaderSets interface_verify_header_sets) +run_cmake_build(VerifyHeaderSets exe_verify_header_sets) +run_cmake_build(VerifyHeaderSets export_exe_verify_header_sets) +run_cmake_build(VerifyHeaderSets none_verify_header_sets) +run_cmake_build(VerifyHeaderSets property_off_verify_header_sets) +run_cmake_build(VerifyHeaderSets private_verify_header_sets) +run_cmake_build(VerifyHeaderSets a_h_verify_header_sets) +run_cmake_build(VerifyHeaderSets dir_c_h_verify_header_sets) +run_cmake_build(VerifyHeaderSets dir_cxx_h_verify_header_sets) + +if(NOT RunCMake_GENERATOR STREQUAL "Xcode") + run_cmake_build(VerifyHeaderSets config_verify_header_sets) + if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(BUILD_CONFIG Release) + run_cmake_build(VerifyHeaderSets config_verify_header_sets) + unset(BUILD_CONFIG) + endif() +endif() + +run_cmake_build(VerifyHeaderSets lang_test_c_verify_header_sets) +run_cmake_build(VerifyHeaderSets lang_test_cxx_verify_header_sets) diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-a_h_verify_header_sets-Debug-build-result.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-a_h_verify_header_sets-Debug-build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-a_h_verify_header_sets-Debug-build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-a_h_verify_header_sets-Debug-build-stderr.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-a_h_verify_header_sets-Debug-build-stderr.txt new file mode 100644 index 0000000..b78bc52 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-a_h_verify_header_sets-Debug-build-stderr.txt @@ -0,0 +1 @@ +(TEST_A_H defined)? diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-a_h_verify_header_sets-Debug-build-stdout.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-a_h_verify_header_sets-Debug-build-stdout.txt new file mode 100644 index 0000000..b78bc52 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-a_h_verify_header_sets-Debug-build-stdout.txt @@ -0,0 +1 @@ +(TEST_A_H defined)? diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-check.cmake b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-check.cmake new file mode 100644 index 0000000..44e028f --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-check.cmake @@ -0,0 +1,33 @@ +function(check_file target filename) + set(full_filename "${RunCMake_TEST_BINARY_DIR}/${target}_verify_header_sets/${filename}") + if(NOT EXISTS "${full_filename}") + string(APPEND RunCMake_TEST_FAILED "File ${full_filename} should exist but does not\n") + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) + return() + endif() + + if(filename MATCHES "^(.*)(\\.[a-z]+)$") + set(header_filename "${CMAKE_MATCH_1}") + endif() + set(expected_contents "#include <${header_filename}>\n") + file(READ "${full_filename}" actual_contents) + + if(NOT actual_contents STREQUAL expected_contents) + string(REPLACE "\n" "\n " expected_contents_formatted "${expected_contents}") + string(REPLACE "\n" "\n " actual_contents_formatted "${actual_contents}") + string(APPEND RunCMake_TEST_FAILED "Expected contents of ${full_filename}:\n ${expected_contents_formatted}\nActual contents:\n ${actual_contents_formatted}\n") + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) + return() + endif() +endfunction() + +check_file(static a.h.c) +check_file(static dir/c.h.c) +check_file(static dir/cxx.h.cxx) + +if(NOT RunCMake_GENERATOR STREQUAL "Xcode") + check_file(config debug.h.c) + if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + check_file(config release.h.c) + endif() +endif() diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Debug-build-result.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Debug-build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Debug-build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Debug-build-stderr.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Debug-build-stderr.txt new file mode 100644 index 0000000..eaa9a03 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Debug-build-stderr.txt @@ -0,0 +1 @@ +(Compiled in debug mode)? diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Debug-build-stdout.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Debug-build-stdout.txt new file mode 100644 index 0000000..eaa9a03 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Debug-build-stdout.txt @@ -0,0 +1 @@ +(Compiled in debug mode)? diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Release-build-result.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Release-build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Release-build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Release-build-stderr.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Release-build-stderr.txt new file mode 100644 index 0000000..25699f9 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Release-build-stderr.txt @@ -0,0 +1 @@ +(Compiled in release mode)? diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Release-build-stdout.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Release-build-stdout.txt new file mode 100644 index 0000000..25699f9 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-config_verify_header_sets-Release-build-stdout.txt @@ -0,0 +1 @@ +(Compiled in release mode)? diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_c_h_verify_header_sets-Debug-build-result.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_c_h_verify_header_sets-Debug-build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_c_h_verify_header_sets-Debug-build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_c_h_verify_header_sets-Debug-build-stderr.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_c_h_verify_header_sets-Debug-build-stderr.txt new file mode 100644 index 0000000..27ef042 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_c_h_verify_header_sets-Debug-build-stderr.txt @@ -0,0 +1 @@ +(TEST_DIR_C_H defined)? diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_c_h_verify_header_sets-Debug-build-stdout.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_c_h_verify_header_sets-Debug-build-stdout.txt new file mode 100644 index 0000000..27ef042 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_c_h_verify_header_sets-Debug-build-stdout.txt @@ -0,0 +1 @@ +(TEST_DIR_C_H defined)? diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_cxx_h_verify_header_sets-Debug-build-result.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_cxx_h_verify_header_sets-Debug-build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_cxx_h_verify_header_sets-Debug-build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_cxx_h_verify_header_sets-Debug-build-stderr.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_cxx_h_verify_header_sets-Debug-build-stderr.txt new file mode 100644 index 0000000..cd17d11 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_cxx_h_verify_header_sets-Debug-build-stderr.txt @@ -0,0 +1 @@ +(TEST_DIR_CXX_H defined)? diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_cxx_h_verify_header_sets-Debug-build-stdout.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_cxx_h_verify_header_sets-Debug-build-stdout.txt new file mode 100644 index 0000000..cd17d11 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-dir_cxx_h_verify_header_sets-Debug-build-stdout.txt @@ -0,0 +1 @@ +(TEST_DIR_CXX_H defined)? diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-exe_verify_header_sets-Debug-build-result.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-exe_verify_header_sets-Debug-build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-exe_verify_header_sets-Debug-build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-exe_verify_header_sets-Debug-build-stderr.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-exe_verify_header_sets-Debug-build-stderr.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-exe_verify_header_sets-Debug-build-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-none_verify_header_sets-Debug-build-result.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-none_verify_header_sets-Debug-build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-none_verify_header_sets-Debug-build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-none_verify_header_sets-Debug-build-stderr.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-none_verify_header_sets-Debug-build-stderr.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-none_verify_header_sets-Debug-build-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-private_verify_header_sets-Debug-build-result.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-private_verify_header_sets-Debug-build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-private_verify_header_sets-Debug-build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-private_verify_header_sets-Debug-build-stderr.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-private_verify_header_sets-Debug-build-stderr.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-private_verify_header_sets-Debug-build-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-property_off_verify_header_sets-Debug-build-result.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-property_off_verify_header_sets-Debug-build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-property_off_verify_header_sets-Debug-build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-property_off_verify_header_sets-Debug-build-stderr.txt b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-property_off_verify_header_sets-Debug-build-stderr.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets-property_off_verify_header_sets-Debug-build-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets.cmake b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets.cmake new file mode 100644 index 0000000..f515031 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/VerifyHeaderSets.cmake @@ -0,0 +1,60 @@ +enable_language(C CXX) + +set_property(SOURCE a.h PROPERTY LANGUAGE C) +set_property(SOURCE dir/c.h PROPERTY LANGUAGE C) +set_property(SOURCE dir/cxx.h PROPERTY LANGUAGE CXX) + +add_library(static STATIC lib.c) +target_sources(static INTERFACE FILE_SET HEADERS FILES a.h dir/c.h dir/cxx.h) + +add_library(shared SHARED lib.c) +target_sources(shared INTERFACE FILE_SET HEADERS FILES a.h dir/c.h dir/cxx.h) + +add_library(object OBJECT lib.c) +target_sources(object INTERFACE FILE_SET HEADERS FILES a.h dir/c.h dir/cxx.h) + +add_library(interface INTERFACE) +target_sources(interface INTERFACE FILE_SET HEADERS FILES a.h dir/c.h dir/cxx.h) + +add_executable(exe main.c) +target_sources(exe INTERFACE FILE_SET HEADERS FILES a.h dir/c.h dir/cxx.h) + +add_executable(export_exe main.c) +set_property(TARGET export_exe PROPERTY ENABLE_EXPORTS TRUE) +target_sources(export_exe INTERFACE FILE_SET HEADERS FILES a.h dir/c.h dir/cxx.h) + +add_library(none STATIC lib.c) + +add_library(property_off STATIC lib.c) +target_sources(property_off INTERFACE FILE_SET HEADERS FILES a.h dir/c.h dir/cxx.h) +set_property(TARGET property_off PROPERTY VERIFY_HEADER_SETS OFF) + +add_library(private STATIC lib.c) +target_sources(private PRIVATE FILE_SET HEADERS FILES a.h dir/c.h dir/cxx.h) + +add_library(a_h STATIC lib.c) +target_compile_definitions(a_h INTERFACE TEST_A_H) +target_sources(a_h INTERFACE FILE_SET HEADERS FILES a.h dir/c.h dir/cxx.h) + +add_library(dir_c_h STATIC lib.c) +target_compile_definitions(dir_c_h INTERFACE TEST_DIR_C_H) +target_sources(dir_c_h INTERFACE FILE_SET HEADERS FILES a.h dir/c.h dir/cxx.h) + +add_library(dir_cxx_h STATIC lib.c) +target_compile_definitions(dir_cxx_h INTERFACE TEST_DIR_CXX_H) +target_sources(dir_cxx_h INTERFACE FILE_SET HEADERS FILES a.h dir/c.h dir/cxx.h) + +set_property(SOURCE debug.h PROPERTY LANGUAGE C) +set_property(SOURCE release.h PROPERTY LANGUAGE C) + +if(NOT CMAKE_GENERATOR STREQUAL "Xcode") + add_library(config STATIC lib.c) + target_sources(config INTERFACE FILE_SET HEADERS FILES $<IF:$<CONFIG:Debug>,debug.h,release.h>) +endif() + +add_library(lang_test_c STATIC lib.c) +target_sources(lang_test_c INTERFACE FILE_SET HEADERS FILES lang_test.h) + +add_library(lang_test_cxx STATIC lib.c lib.cxx) +target_compile_definitions(lang_test_cxx INTERFACE EXPECT_CXX) +target_sources(lang_test_cxx INTERFACE FILE_SET HEADERS FILES lang_test.h) diff --git a/Tests/RunCMake/VerifyHeaderSets/a.h b/Tests/RunCMake/VerifyHeaderSets/a.h new file mode 100644 index 0000000..8b17182 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/a.h @@ -0,0 +1,5 @@ +#ifdef TEST_A_H +# error "TEST_A_H defined" +#endif + +extern void a_h(void); diff --git a/Tests/RunCMake/VerifyHeaderSets/debug.h b/Tests/RunCMake/VerifyHeaderSets/debug.h new file mode 100644 index 0000000..4d4baa1 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/debug.h @@ -0,0 +1,3 @@ +#error "Compiled in debug mode" + +extern void debug_h(void); diff --git a/Tests/RunCMake/VerifyHeaderSets/dir/c.h b/Tests/RunCMake/VerifyHeaderSets/dir/c.h new file mode 100644 index 0000000..151cd81 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/dir/c.h @@ -0,0 +1,8 @@ +#ifdef TEST_DIR_C_H +# error "TEST_DIR_C_H defined" +#endif +#ifdef __cplusplus +# error "__cplusplus defined" +#endif + +extern void dir_c_h(void); diff --git a/Tests/RunCMake/VerifyHeaderSets/dir/cxx.h b/Tests/RunCMake/VerifyHeaderSets/dir/cxx.h new file mode 100644 index 0000000..255f61b --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/dir/cxx.h @@ -0,0 +1,8 @@ +#ifdef TEST_DIR_CXX_H +# error "TEST_DIR_CXX_H defined" +#endif +#ifndef __cplusplus +# error "__cplusplus not defined" +#endif + +extern void dir_cxx_h(void); diff --git a/Tests/RunCMake/VerifyHeaderSets/lang_test.h b/Tests/RunCMake/VerifyHeaderSets/lang_test.h new file mode 100644 index 0000000..633a2a4 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/lang_test.h @@ -0,0 +1,8 @@ +#if defined(__cplusplus) && !defined(EXPECT_CXX) +# error "__cplusplus defined but EXPECT_CXX not defined" +#endif +#if !defined(__cplusplus) && defined(EXPECT_CXX) +# error "__cplusplus not defined but EXPECT_CXX defined" +#endif + +extern void lang_test_h(void); diff --git a/Tests/RunCMake/VerifyHeaderSets/lib.c b/Tests/RunCMake/VerifyHeaderSets/lib.c new file mode 100644 index 0000000..6401eca --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/lib.c @@ -0,0 +1,6 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + void lib_c(void) +{ +} diff --git a/Tests/RunCMake/VerifyHeaderSets/lib.cxx b/Tests/RunCMake/VerifyHeaderSets/lib.cxx new file mode 100644 index 0000000..a0b3096 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/lib.cxx @@ -0,0 +1,6 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + void lib_cxx(void) +{ +} diff --git a/Tests/RunCMake/VerifyHeaderSets/main.c b/Tests/RunCMake/VerifyHeaderSets/main.c new file mode 100644 index 0000000..8a83e8c --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/main.c @@ -0,0 +1,11 @@ +int main(void) +{ + return 0; +} + +#ifdef _WIN32 +__declspec(dllexport) +#endif + void main_c(void) +{ +} diff --git a/Tests/RunCMake/VerifyHeaderSets/release.h b/Tests/RunCMake/VerifyHeaderSets/release.h new file mode 100644 index 0000000..7641988 --- /dev/null +++ b/Tests/RunCMake/VerifyHeaderSets/release.h @@ -0,0 +1,3 @@ +#error "Compiled in release mode" + +extern void release_h(void); diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index fa26c3d..80c6b73 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -141,6 +141,16 @@ endfunction() XcodeRemoveExcessiveISystem() +function(XcodeXCConfig) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeXCConfig-build) + run_cmake(XcodeXCConfig) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(XcodeXCConfig-build ${CMAKE_COMMAND} --build . --config Debug) + run_cmake_command(XcodeXCConfig-build ${CMAKE_COMMAND} --build . --config Release) +endfunction() + +XcodeXCConfig() + # Isolate device tests from host architecture selection. unset(ENV{CMAKE_OSX_ARCHITECTURES}) diff --git a/Tests/RunCMake/XcodeProject/XcodeXCConfig.c b/Tests/RunCMake/XcodeProject/XcodeXCConfig.c new file mode 100644 index 0000000..ac59a6b --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeXCConfig.c @@ -0,0 +1,20 @@ +#ifndef BUILD_DEBUG +# error BUILD_DEBUG is undefined +#endif +#ifndef GLOBAL_DEBUG +# error GLOBAL_DEBUG is undefined +#endif +#ifndef TARGET_DEBUG +# error TARGET_DEBUG is undefined +#endif + +#if GLOBAL_DEBUG != BUILD_DEBUG +# error GLOBAL_DEBUG does not match BUILD_DEBUG +#endif +#if TARGET_DEBUG != BUILD_DEBUG +# error TARGET_DEBUG does not match BUILD_DEBUG +#endif + +void some_symbol() +{ +} diff --git a/Tests/RunCMake/XcodeProject/XcodeXCConfig.cmake b/Tests/RunCMake/XcodeProject/XcodeXCConfig.cmake new file mode 100644 index 0000000..58d2616 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeXCConfig.cmake @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.23) + +project(XcodeXCConfig C) + +set(CMAKE_XCODE_XCCONFIG "$<IF:$<CONFIG:Debug>,XcodeXCConfig.global.debug.xcconfig,XcodeXCConfig.global.release.xcconfig>") + +add_library(somelib XcodeXCConfig.c) +target_compile_definitions(somelib PUBLIC "BUILD_DEBUG=$<IF:$<CONFIG:Debug>,1,0>") +set_target_properties(somelib PROPERTIES + XCODE_XCCONFIG "$<IF:$<CONFIG:Debug>,XcodeXCConfig.target.debug.xcconfig,XcodeXCConfig.target.release.xcconfig>" +) diff --git a/Tests/RunCMake/XcodeProject/XcodeXCConfig.global.debug.xcconfig b/Tests/RunCMake/XcodeProject/XcodeXCConfig.global.debug.xcconfig new file mode 100644 index 0000000..6749095 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeXCConfig.global.debug.xcconfig @@ -0,0 +1 @@ +OTHER_CFLAGS = $(inherited) -DGLOBAL_DEBUG=1 diff --git a/Tests/RunCMake/XcodeProject/XcodeXCConfig.global.release.xcconfig b/Tests/RunCMake/XcodeProject/XcodeXCConfig.global.release.xcconfig new file mode 100644 index 0000000..6af304d --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeXCConfig.global.release.xcconfig @@ -0,0 +1 @@ +OTHER_CFLAGS = $(inherited) -DGLOBAL_DEBUG=0 diff --git a/Tests/RunCMake/XcodeProject/XcodeXCConfig.target.debug.xcconfig b/Tests/RunCMake/XcodeProject/XcodeXCConfig.target.debug.xcconfig new file mode 100644 index 0000000..731eba2 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeXCConfig.target.debug.xcconfig @@ -0,0 +1 @@ +OTHER_CFLAGS = $(inherited) -DTARGET_DEBUG=1 diff --git a/Tests/RunCMake/XcodeProject/XcodeXCConfig.target.release.xcconfig b/Tests/RunCMake/XcodeProject/XcodeXCConfig.target.release.xcconfig new file mode 100644 index 0000000..b98acb5 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeXCConfig.target.release.xcconfig @@ -0,0 +1 @@ +OTHER_CFLAGS = $(inherited) -DTARGET_DEBUG=0 diff --git a/Tests/RunCMake/cmake_language/defer_call_trace_json-stderr.txt b/Tests/RunCMake/cmake_language/defer_call_trace_json-stderr.txt index 647beb0..3bde16d 100644 --- a/Tests/RunCMake/cmake_language/defer_call_trace_json-stderr.txt +++ b/Tests/RunCMake/cmake_language/defer_call_trace_json-stderr.txt @@ -1,5 +1,5 @@ -{"args":\["DEFER","CALL","message","Deferred Message"\],"cmd":"cmake_language","file":"[^"]*/Tests/RunCMake/cmake_language/defer_call_trace_json.cmake","frame":2,"line":2,"time":[0-9.]+} -{"args":\["Immediate Message"\],"cmd":"message","file":"[^"]*/Tests/RunCMake/cmake_language/defer_call_trace_json.cmake","frame":2,"line":3,"time":[0-9.]+} +{"args":\["DEFER","CALL","message","Deferred Message"\],"cmd":"cmake_language","file":"[^"]*/Tests/RunCMake/cmake_language/defer_call_trace_json.cmake","frame":2,"global_frame":2,"line":2,"time":[0-9.]+} +{"args":\["Immediate Message"\],"cmd":"message","file":"[^"]*/Tests/RunCMake/cmake_language/defer_call_trace_json.cmake","frame":2,"global_frame":2,"line":3,"time":[0-9.]+} Immediate Message -{"args":\["Deferred Message"],"cmd":"message","defer":"__0","file":"[^"]*/Tests/RunCMake/cmake_language/defer_call_trace_json.cmake","frame":1,"line":2,"time":[0-9.]+} +{"args":\["Deferred Message"],"cmd":"message","defer":"__0","file":"[^"]*/Tests/RunCMake/cmake_language/defer_call_trace_json.cmake","frame":1,"global_frame":1,"line":2,"time":[0-9.]+} Deferred Message$ diff --git a/Tests/RunCMake/ctest_build/RunCMakeTest.cmake b/Tests/RunCMake/ctest_build/RunCMakeTest.cmake index 511cd71..e94a55d 100644 --- a/Tests/RunCMake/ctest_build/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_build/RunCMakeTest.cmake @@ -49,6 +49,18 @@ function(run_BuildChangeId) endfunction() run_BuildChangeId() +function(run_SubdirTarget) + set(CASE_CMAKELISTS_SUFFIX_CODE [=[ +file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/subdir/CMakeLists.txt [[ +add_custom_target(target_in_subdir COMMAND ${CMAKE_COMMAND} -E touch target_in_subdir.out VERBATIM) +]]) +add_subdirectory(subdir) +]=]) + set(CASE_CTEST_BUILD_ARGS TARGET target_in_subdir) + run_ctest(SubdirTarget) +endfunction() +run_SubdirTarget() + set(RunCMake_USE_CUSTOM_BUILD_COMMAND TRUE) set(RunCMake_BUILD_COMMAND "${FAKE_BUILD_COMMAND_EXE}") run_ctest(BuildCommandFailure) diff --git a/Tests/RunCMake/ctest_build/SubdirTarget-check.cmake b/Tests/RunCMake/ctest_build/SubdirTarget-check.cmake new file mode 100644 index 0000000..81d21ec --- /dev/null +++ b/Tests/RunCMake/ctest_build/SubdirTarget-check.cmake @@ -0,0 +1,4 @@ +set(expected_file "${RunCMake_TEST_BINARY_DIR}/subdir/target_in_subdir.out") +if(NOT EXISTS "${expected_file}") + set(RunCMake_TEST_FAILED "Expected build output file not found:\n ${expected_file}") +endif() diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake index de81049..b41c271 100644 --- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake @@ -80,6 +80,23 @@ add_test(NAME FailingTest COMMAND ${CMAKE_COMMAND} -E no_such_command) endfunction() run_TestOutputSize() +# Test --test-output-truncation +function(run_TestOutputTruncation mode expected) + set(CASE_CTEST_TEST_ARGS EXCLUDE RunCMakeVersion) + set(TRUNCATED_OUTPUT ${expected}) # used in TestOutputTruncation-check.cmake + set(CASE_TEST_PREFIX_CODE [[ +set( CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION${mode}) + ]]) + set(CASE_CMAKELISTS_SUFFIX_CODE [[ +add_test(NAME Truncation_${mode} COMMAND ${CMAKE_COMMAND} -E echo 123456789) + ]]) + + run_ctest(TestOutputTruncation) +endfunction() +run_TestOutputTruncation("head" "...6789") +run_TestOutputTruncation("middle" "12....*...89") +run_TestOutputTruncation("tail" "12345...") + run_ctest_test(TestRepeatBad1 REPEAT UNKNOWN:3) run_ctest_test(TestRepeatBad2 REPEAT UNTIL_FAIL:-1) diff --git a/Tests/RunCMake/ctest_test/TestOutputTruncation-check.cmake b/Tests/RunCMake/ctest_test/TestOutputTruncation-check.cmake new file mode 100644 index 0000000..5769c9f --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestOutputTruncation-check.cmake @@ -0,0 +1,12 @@ +file(GLOB test_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Test.xml") +if(test_xml_file) + file(READ "${test_xml_file}" test_xml LIMIT 4096) + if("${test_xml}" MATCHES [[(<Test Status="passed">.*</Test>)]]) + set(test_result "${CMAKE_MATCH_1}") + endif() + if(NOT "${test_result}" MATCHES "<Value>.*${TRUNCATED_OUTPUT}.*</Value>") + set(RunCMake_TEST_FAILED "Test output truncation failed:\n ${test_result}\nExpected: ${TRUNCATED_OUTPUT}") + endif() +else() + set(RunCMake_TEST_FAILED "Test.xml not found") +endif() diff --git a/Tests/RunCMake/find_package/GlobalImportTarget-stdout.txt b/Tests/RunCMake/find_package/GlobalImportTarget-stdout.txt new file mode 100644 index 0000000..bd06873 --- /dev/null +++ b/Tests/RunCMake/find_package/GlobalImportTarget-stdout.txt @@ -0,0 +1,31 @@ +-- IMPORTED TARGET imported_local_target has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_global_target has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_local_ex has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_global_ex has GLOBAL scope: TRUE +-- IMPORTED TARGET Foo1 has GLOBAL scope: TRUE +-- IMPORTED TARGET Foo2 has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_var_local_target has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_var_global_target has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_var_local_ex has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_var_global_ex has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_global_lib has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_explicit_global_ex has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_local_lib has GLOBAL scope: FALSE +-- IMPORTED TARGET imported_implied_local_ex has GLOBAL scope: FALSE +-- IMPORTED TARGET imported_no_var_local_target has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_no_var_global_target has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_no_var_local_ex has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_no_var_global_ex has GLOBAL scope: TRUE +-- IMPORTED TARGET not_imported_not_global has GLOBAL scope: FALSE +-- IMPORTED TARGET PackName has GLOBAL scope: TRUE +-- IMPORTED TARGET PackNameExe has GLOBAL scope: TRUE +-- IMPORTED TARGET PackName1 has GLOBAL scope: TRUE +-- IMPORTED TARGET PackNameExe1 has GLOBAL scope: TRUE +-- IMPORTED TARGET local_lib_glob has GLOBAL scope: TRUE +-- IMPORTED TARGET local_exe_glob has GLOBAL scope: TRUE +-- IMPORTED TARGET local_lib has GLOBAL scope: FALSE +-- IMPORTED TARGET local_exe has GLOBAL scope: FALSE +-- IMPORTED TARGET LT1 has GLOBAL scope: TRUE +-- IMPORTED TARGET LT2 has GLOBAL scope: TRUE +-- IMPORTED TARGET LT3 has GLOBAL scope: TRUE +-- IMPORTED TARGET LT4 has GLOBAL scope: TRUE diff --git a/Tests/RunCMake/find_package/GlobalImportTarget.cmake b/Tests/RunCMake/find_package/GlobalImportTarget.cmake new file mode 100644 index 0000000..7e6d2b8 --- /dev/null +++ b/Tests/RunCMake/find_package/GlobalImportTarget.cmake @@ -0,0 +1,57 @@ +function (assess_target_property target) + get_target_property(target_val "${target}" IMPORTED_GLOBAL) + message(STATUS "IMPORTED TARGET ${target} has GLOBAL scope: ${target_val}") +endfunction () + +list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot) + +find_package(GlobalTarget GLOBAL REQUIRED) +assess_target_property(imported_local_target) +assess_target_property(imported_global_target) +assess_target_property(imported_local_ex) +assess_target_property(imported_global_ex) +assess_target_property(Foo1) +assess_target_property(Foo2) + +set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE) +find_package(GlobalVarTarget) +assess_target_property(imported_var_local_target) +assess_target_property(imported_var_global_target) +assess_target_property(imported_var_local_ex) +assess_target_property(imported_var_global_ex) +set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL OFF) + +find_package(LocalTarget) +assess_target_property(imported_global_lib) +assess_target_property(imported_explicit_global_ex) +assess_target_property(imported_local_lib) +assess_target_property(imported_implied_local_ex) + +find_package(GlobalTargetNoVar GLOBAL) +assess_target_property(imported_no_var_local_target) +assess_target_property(imported_no_var_global_target) +assess_target_property(imported_no_var_local_ex) +assess_target_property(imported_no_var_global_ex) +assess_target_property(not_imported_not_global) + +set(Baz_DIR "${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot") +find_package(Baz GLOBAL REQUIRED) +assess_target_property(PackName) +assess_target_property(PackNameExe) +assess_target_property(PackName1) +assess_target_property(PackNameExe1) + +set(Biz_DIR "${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot") +find_package(Biz REQUIRED) +assess_target_property(local_lib_glob) +assess_target_property(local_exe_glob) +assess_target_property(local_lib) +assess_target_property(local_exe) + +set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE) +set(Simple_DIR "${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot") +find_package(Simple REQUIRED) +assess_target_property(LT1) +assess_target_property(LT2) +assess_target_property(LT3) +assess_target_property(LT4) diff --git a/Tests/RunCMake/find_package/PackageRoot/BazConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/BazConfig.cmake new file mode 100644 index 0000000..cca95a2 --- /dev/null +++ b/Tests/RunCMake/find_package/PackageRoot/BazConfig.cmake @@ -0,0 +1,3 @@ +include(CMakeFindDependencyMacro) + +find_dependency(PackName PATHS ${CMAKE_CURRENT_LIST_DIR}) diff --git a/Tests/RunCMake/find_package/PackageRoot/BizConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/BizConfig.cmake new file mode 100644 index 0000000..5b0e398 --- /dev/null +++ b/Tests/RunCMake/find_package/PackageRoot/BizConfig.cmake @@ -0,0 +1,3 @@ +include(CMakeFindDependencyMacro) + +find_dependency(LocalPack PATHS ${CMAKE_CURRENT_LIST_DIR}) diff --git a/Tests/RunCMake/find_package/PackageRoot/FindGlobalTarget.cmake b/Tests/RunCMake/find_package/PackageRoot/FindGlobalTarget.cmake new file mode 100644 index 0000000..9e34613 --- /dev/null +++ b/Tests/RunCMake/find_package/PackageRoot/FindGlobalTarget.cmake @@ -0,0 +1,7 @@ +add_library(imported_global_target SHARED IMPORTED GLOBAL) +add_executable(imported_global_ex IMPORTED GLOBAL) + +add_library(imported_local_target SHARED IMPORTED) +add_executable(imported_local_ex IMPORTED) + +find_package(SimpleTarget) diff --git a/Tests/RunCMake/find_package/PackageRoot/FindGlobalTargetNoVar.cmake b/Tests/RunCMake/find_package/PackageRoot/FindGlobalTargetNoVar.cmake new file mode 100644 index 0000000..a156f90 --- /dev/null +++ b/Tests/RunCMake/find_package/PackageRoot/FindGlobalTargetNoVar.cmake @@ -0,0 +1,7 @@ +add_library(imported_no_var_global_target SHARED IMPORTED GLOBAL) +add_executable(imported_no_var_global_ex IMPORTED GLOBAL) + +add_library(imported_no_var_local_target SHARED IMPORTED) +add_executable(imported_no_var_local_ex IMPORTED) + +add_library(not_imported_not_global INTERFACE) diff --git a/Tests/RunCMake/find_package/PackageRoot/FindGlobalVarTarget.cmake b/Tests/RunCMake/find_package/PackageRoot/FindGlobalVarTarget.cmake new file mode 100644 index 0000000..2e96a6c --- /dev/null +++ b/Tests/RunCMake/find_package/PackageRoot/FindGlobalVarTarget.cmake @@ -0,0 +1,5 @@ +add_library(imported_var_global_target SHARED IMPORTED GLOBAL) +add_executable(imported_var_global_ex IMPORTED GLOBAL) + +add_library(imported_var_local_target SHARED IMPORTED) +add_executable(imported_var_local_ex IMPORTED) diff --git a/Tests/RunCMake/find_package/PackageRoot/FindLocalTarget.cmake b/Tests/RunCMake/find_package/PackageRoot/FindLocalTarget.cmake new file mode 100644 index 0000000..d533405 --- /dev/null +++ b/Tests/RunCMake/find_package/PackageRoot/FindLocalTarget.cmake @@ -0,0 +1,5 @@ +add_library(imported_global_lib SHARED IMPORTED GLOBAL) +add_executable(imported_explicit_global_ex IMPORTED GLOBAL) + +add_library(imported_local_lib SHARED IMPORTED) +add_executable(imported_implied_local_ex IMPORTED) diff --git a/Tests/RunCMake/find_package/PackageRoot/FindSimpleTarget.cmake b/Tests/RunCMake/find_package/PackageRoot/FindSimpleTarget.cmake new file mode 100644 index 0000000..cd58004 --- /dev/null +++ b/Tests/RunCMake/find_package/PackageRoot/FindSimpleTarget.cmake @@ -0,0 +1,2 @@ +add_library(Foo1 SHARED IMPORTED) +add_executable(Foo2 IMPORTED) diff --git a/Tests/RunCMake/find_package/PackageRoot/LTConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/LTConfig.cmake new file mode 100644 index 0000000..f451eb6 --- /dev/null +++ b/Tests/RunCMake/find_package/PackageRoot/LTConfig.cmake @@ -0,0 +1,5 @@ +add_library(LT1 INTERFACE IMPORTED) +add_executable(LT2 IMPORTED) + +add_library(LT3 INTERFACE IMPORTED GLOBAL) +add_executable(LT4 IMPORTED GLOBAL) diff --git a/Tests/RunCMake/find_package/PackageRoot/LocalPackConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/LocalPackConfig.cmake new file mode 100644 index 0000000..a962849 --- /dev/null +++ b/Tests/RunCMake/find_package/PackageRoot/LocalPackConfig.cmake @@ -0,0 +1,5 @@ +add_library(local_lib_glob SHARED IMPORTED GLOBAL) +add_executable(local_exe_glob IMPORTED GLOBAL) + +add_library(local_lib SHARED IMPORTED) +add_executable(local_exe IMPORTED) diff --git a/Tests/RunCMake/find_package/PackageRoot/PackNameConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/PackNameConfig.cmake new file mode 100644 index 0000000..38dd2f8 --- /dev/null +++ b/Tests/RunCMake/find_package/PackageRoot/PackNameConfig.cmake @@ -0,0 +1,5 @@ +add_library(PackName INTERFACE IMPORTED GLOBAL) +add_executable(PackNameExe IMPORTED GLOBAL) + +add_library(PackName1 INTERFACE IMPORTED) +add_executable(PackNameExe1 IMPORTED) diff --git a/Tests/RunCMake/find_package/PackageRoot/SimpleConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/SimpleConfig.cmake new file mode 100644 index 0000000..44059c6 --- /dev/null +++ b/Tests/RunCMake/find_package/PackageRoot/SimpleConfig.cmake @@ -0,0 +1,3 @@ +include(CMakeFindDependencyMacro) + +find_dependency(LT PATHS ${CMAKE_CURRENT_LIST_DIR}) diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake index 5f4c6cb..2b5fb1f 100644 --- a/Tests/RunCMake/find_package/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake @@ -6,6 +6,7 @@ run_cmake(ComponentRequiredAndOptional) run_cmake(FromPATHEnv) run_cmake_with_options(FromPATHEnvDebugPkg --debug-find-pkg=Resolved) run_cmake(FromPrefixPath) +run_cmake(GlobalImportTarget) run_cmake(MissingNormal) run_cmake(MissingNormalForceRequired) run_cmake(MissingNormalRequired) diff --git a/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-new_rpath-stderr.txt b/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-new_rpath-stderr.txt index 2561263..8b0970a 100644 --- a/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-new_rpath-stderr.txt +++ b/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-new_rpath-stderr.txt @@ -1,3 +1,15 @@ +^CMake Deprecation Warning at TARGETS-FILE_RPATH_CHANGE-new_rpath.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0095 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\): + TARGETS-FILE_RPATH_CHANGE-new_rpath.cmake:[0-9]+ \(A_CMP0095\) + CMakeLists.txt:[0-9]+ \(include\)( ++ CMake Warning \(dev\) at TARGETS-FILE_RPATH_CHANGE-new_rpath\.cmake:[0-9]+ \(install\): Policy CMP0095 is not set: RPATH entries are properly escaped in the intermediary CMake install script\. Run "cmake --help-policy CMP0095" for @@ -8,8 +20,8 @@ CMake Warning \(dev\) at TARGETS-FILE_RPATH_CHANGE-new_rpath\.cmake:[0-9]+ \(ins intermediary cmake_install\.cmake script\. Call Stack \(most recent call first\): CMakeLists\.txt:[0-9]+ \(include\) -This warning is for project developers\. Use -Wno-dev to suppress it\. - +This warning is for project developers\. Use -Wno-dev to suppress it\.)+( ++ CMake Warning \(dev\) at TARGETS-FILE_RPATH_CHANGE-new_rpath\.cmake:[0-9]+ \(install\): Policy CMP0095 is not set: RPATH entries are properly escaped in the intermediary CMake install script\. Run "cmake --help-policy CMP0095" for @@ -20,4 +32,4 @@ CMake Warning \(dev\) at TARGETS-FILE_RPATH_CHANGE-new_rpath\.cmake:[0-9]+ \(ins intermediary cmake_install\.cmake script\. Call Stack \(most recent call first\): CMakeLists\.txt:[0-9]+ \(include\) -This warning is for project developers\. Use -Wno-dev to suppress it\. +This warning is for project developers\. Use -Wno-dev to suppress it\.)+$ diff --git a/Tests/RunCMake/project/CMP0096-OLD-stderr.txt b/Tests/RunCMake/project/CMP0096-OLD-stderr.txt new file mode 100644 index 0000000..beb7a84 --- /dev/null +++ b/Tests/RunCMake/project/CMP0096-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CMP0096-OLD.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0096 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/project/VersionMax-stderr.txt b/Tests/RunCMake/project/VersionMax-stderr.txt new file mode 100644 index 0000000..b789640 --- /dev/null +++ b/Tests/RunCMake/project/VersionMax-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at VersionMax.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0096 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/JSONWrongMode-stderr.txt b/Tests/RunCMake/string/JSONWrongMode-stderr.txt index c70991b..5668303 100644 --- a/Tests/RunCMake/string/JSONWrongMode-stderr.txt +++ b/Tests/RunCMake/string/JSONWrongMode-stderr.txt @@ -1,5 +1,5 @@ CMake Error at JSONWrongMode.cmake:1 \(string\): string sub-command JSON got an invalid mode 'FOO', expected one of GET, - GET_ARRAY, TYPE, MEMBER, MEMBERS, LENGTH, REMOVE, SET, EQUAL. + TYPE, MEMBER, LENGTH, REMOVE, SET, EQUAL. Call Stack \(most recent call first\): CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/CMakeLists.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/CMakeLists.txt new file mode 100644 index 0000000..915fc41 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.1...3.22) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-group-and-single-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-group-and-single-check.cmake new file mode 100644 index 0000000..3b8f3ba --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-group-and-single-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-START_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX} +.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base5${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-START_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX} +.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP") + set (RunCMake_TEST_FAILED "Not found expected '--START_GROUP <base1> <base3> --END_GROUP <base5> --START_GROUP <base1> <base3> --END_GROUP'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-group-and-single-result.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-group-and-single-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-group-and-single-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-definitions-result.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-definitions-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-definitions-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-groups-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-groups-check.cmake new file mode 100644 index 0000000..97732a5 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-groups-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-START_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX} +.*${LINK_SHARED_LIBRARY_PREFIX}base4${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP\"? +\"?(/|-)-START_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX} +.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP") + set (RunCMake_TEST_FAILED "Not found expected '--START_GROUP <base2> <base4> --END_GROUP --START_GROUP <base1> <base2> --END_GROUP'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-groups-result.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-groups-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-groups-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-mutiple-definitions-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-mutiple-definitions-check.cmake new file mode 100644 index 0000000..3e53d26 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-mutiple-definitions-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-START_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX} +.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP") + set (RunCMake_TEST_FAILED "Not found expected '--START_GROUP <base1> <base2> --END_GROUP'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple1-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple1-check.cmake new file mode 100644 index 0000000..3e53d26 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple1-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-START_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX} +.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP") + set (RunCMake_TEST_FAILED "Not found expected '--START_GROUP <base1> <base2> --END_GROUP'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple1-result.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple1-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple1-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple2-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple2-check.cmake new file mode 100644 index 0000000..475a0e2 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple2-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-START_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX} +.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}") + set (RunCMake_TEST_FAILED "Not found expected '--START_GROUP <base2> <base3> --END_GROUP <base1>'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple2-result.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple2-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple2-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY-check.cmake new file mode 100644 index 0000000..2b2460e --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-START_GROUP\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP") + set (RunCMake_TEST_FAILED "Not found expected '--START_GROUP --LIBFLAG<base1> <base2> --END_GROUP'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY-result.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY_OVERRIDE-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY_OVERRIDE-check.cmake new file mode 100644 index 0000000..5ef830c --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY_OVERRIDE-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-START_GROUP\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX}\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP") + set (RunCMake_TEST_FAILED "Not found expected '--START_GROUP --LIBFLAG<base1> --LIBFLAG<base3> <base2> --END_GROUP'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY_OVERRIDE-result.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY_OVERRIDE-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY_OVERRIDE-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP.cmake new file mode 100644 index 0000000..31eb7e2 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP.cmake @@ -0,0 +1,59 @@ +enable_language(C) + +# ensure command line is always displayed and do not use any response file +set(CMAKE_VERBOSE_MAKEFILE TRUE) +set(CMAKE_C_USE_RESPONSE_FILE_FOR_LIBRARIES FALSE) + +if (CMAKE_GENERATOR MATCHES "Borland|NMake") + string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY}") + string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY}") +endif() + + +add_library(base1 SHARED base.c) +add_library(base2 SHARED base.c) + + +set(CMAKE_C_LINK_GROUP_USING_feat1 "--START_GROUP" "--END_GROUP") +set(CMAKE_C_LINK_GROUP_USING_feat1_SUPPORTED TRUE) + +set(CMAKE_C_LINK_LIBRARY_USING_feat1 "--LIBFLAG<LIBRARY>") +set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE) + +set(CMAKE_C_LINK_GROUP_USING_feat2 "--START_GROUP" "--END_GROUP") +set(CMAKE_LINK_GROUP_USING_feat2 "--START_GROUP" "--END_GROUP") +set(CMAKE_LINK_GROUP_USING_feat2_SUPPORTED TRUE) + +add_library(LinkGroup_simple1 SHARED lib.c) +target_link_libraries(LinkGroup_simple1 PRIVATE "$<LINK_GROUP:feat1,base1,base2>") + + +add_library(base3 SHARED base.c) +target_link_libraries(base3 PUBLIC base1) +add_library(LinkGroup_simple2 SHARED lib.c) +target_link_libraries(LinkGroup_simple2 PRIVATE "$<LINK_GROUP:feat1,base2,base3>") + + +add_library(LinkGroup_multiple-definitions SHARED lib.c) +target_link_libraries(LinkGroup_multiple-definitions PRIVATE "$<LINK_GROUP:feat2,base1,base2>") + + +add_library(base4 SHARED base.c) +target_link_libraries(base4 INTERFACE "$<LINK_GROUP:feat1,base1,base2>") +add_library(LinkGroup_multiple-groups SHARED lib.c) +target_link_libraries(LinkGroup_multiple-groups PRIVATE "$<LINK_GROUP:feat1,base2,base4>") + + +add_library(base5 SHARED base.c) +target_link_libraries(base5 PUBLIC base1) +add_library(LinkGroup_group-and-single SHARED lib.c) +target_link_libraries(LinkGroup_group-and-single PRIVATE "$<LINK_GROUP:feat1,base1,base3>" base5) + + +add_library(LinkGroup_with-LINK_LIBRARY SHARED lib.c) +target_link_libraries(LinkGroup_with-LINK_LIBRARY PRIVATE "$<LINK_GROUP:feat1,$<LINK_LIBRARY:feat1,base1>,base2>") + + +add_library(LinkGroup_with-LINK_LIBRARY_OVERRIDE SHARED lib.c) +target_link_libraries(LinkGroup_with-LINK_LIBRARY_OVERRIDE PRIVATE "$<LINK_GROUP:feat1,$<LINK_LIBRARY:feat1,base1,base3>,base2>") +set_property(TARGET LinkGroup_with-LINK_LIBRARY_OVERRIDE PROPERTY LINK_LIBRARY_OVERRIDE_base1 feat1) diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/RunCMakeTest.cmake new file mode 100644 index 0000000..c1d74d0 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/RunCMakeTest.cmake @@ -0,0 +1,72 @@ + +include(RunCMake) + +cmake_policy(SET CMP0054 NEW) + +macro(run_cmake_target test subtest target) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(${test}-${subtest} ${CMAKE_COMMAND} --build . --target ${target} --config Release --verbose ${ARGN}) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) +endmacro() + + +# Some environments are excluded because they are not able to honor verbose mode +if ((RunCMake_GENERATOR MATCHES "Makefiles|Ninja|Xcode" + OR (RunCMake_GENERATOR MATCHES "Visual Studio" AND MSVC_VERSION GREATER_EQUAL "1600")) + AND NOT CMAKE_C_COMPILER_ID STREQUAL "Intel") + + set(RunCMake_TEST_OUTPUT_MERGE TRUE) + if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release) + endif() + + if (CMAKE_SYSTEM_NAME STREQUAL "Windows" + OR CMAKE_SYSTEM_NAME STREQUAL "CYGWIN" + OR CMAKE_SYSTEM_NAME STREQUAL "MSYS") + set(LINK_SHARED_LIBRARY_PREFIX ${CMAKE_IMPORT_LIBRARY_PREFIX}) + set(LINK_SHARED_LIBRARY_SUFFIX ${CMAKE_IMPORT_LIBRARY_SUFFIX}) + else() + set(LINK_SHARED_LIBRARY_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX}) + set(LINK_SHARED_LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX}) + endif() + if (MINGW OR MSYS OR CYGWIN) + set(LINK_EXTERN_LIBRARY_SUFFIX "") + else() + set(LINK_EXTERN_LIBRARY_SUFFIX "${CMAKE_IMPORT_LIBRARY_SUFFIX}") + endif() + + run_cmake(LINK_GROUP) + + run_cmake_target(LINK_GROUP simple1 LinkGroup_simple1) + run_cmake_target(LINK_GROUP simple2 LinkGroup_simple2) + run_cmake_target(LINK_GROUP multiple-definitions LinkGroup_multiple-definitions) + run_cmake_target(LINK_GROUP multiple-groups LinkGroup_multiple-groups) + run_cmake_target(LINK_GROUP group-and-single LinkGroup_group-and-single) + run_cmake_target(LINK_GROUP with-LINK_LIBRARY LinkGroup_with-LINK_LIBRARY) + run_cmake_target(LINK_GROUP with-LINK_LIBRARY_OVERRIDE LinkGroup_with-LINK_LIBRARY_OVERRIDE) + + run_cmake(imported-target) + + # tests using features as described in the documentation + if((CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux") + OR (CMAKE_C_COMPILER_ID STREQUAL "SunPro" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER "5.9" + AND CMAKE_SYSTEM_NAME STREQUAL "SunOS")) + run_cmake(cross_refs) + run_cmake_target(cross_refs link main) + endif() + + unset(RunCMake_TEST_OPTIONS) + unset(RunCMake_TEST_OUTPUT_MERGE) + +endif() + +# Feature RESCAN +if (CMAKE_SYSTEM_NAME MATCHES "Linux|BSD" + OR (CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND (NOT CMAKE_C_COMPILER_ID STREQUAL "SunPro" OR CMAKE_C_COMPILER_VERSION VERSION_GREATER "5.9")) + OR (WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "GNU")) + run_cmake(rescan) + run_cmake_target(rescan link main) +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/base.c b/Tests/RunCMake/target_link_libraries-LINK_GROUP/base.c new file mode 100644 index 0000000..a5075d4 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/base.c @@ -0,0 +1,9 @@ + +#if !defined(STATIC_BASE) +# if defined(_WIN32) +__declspec(dllexport) +# endif +#endif + void base() +{ +} diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/cross_refs.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/cross_refs.cmake new file mode 100644 index 0000000..f5f7857 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/cross_refs.cmake @@ -0,0 +1,22 @@ + +enable_language(C) + +set(CMAKE_C_LINK_GROUP_USING_cross_refs_SUPPORTED TRUE) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" + AND CMAKE_SYSTEM_NAME STREQUAL "Linux") +set(CMAKE_C_LINK_GROUP_USING_cross_refs "LINKER:--start-group" + "LINKER:--end-group") +elseif(CMAKE_C_COMPILER_ID STREQUAL "SunPro" + AND CMAKE_SYSTEM_NAME STREQUAL "SunOS") + set(CMAKE_C_LINK_GROUP_USING_cross_refs "LINKER:-z,rescan-start" + "LINKER:-z,rescan-end") +else() + # feature not yet supported for the other environments + set(CMAKE_C_LINK_GROUP_USING_cross_refs_SUPPORTED FALSE) +endif() + +add_library(func1 STATIC func1.c func3.c) +add_library(func2 STATIC func2.c) + +add_executable(main main.c) +target_link_libraries(main PRIVATE "$<LINK_GROUP:cross_refs,func1,func2>") diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/func1.c b/Tests/RunCMake/target_link_libraries-LINK_GROUP/func1.c new file mode 100644 index 0000000..3399e00 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/func1.c @@ -0,0 +1,7 @@ + +extern void func2(); + +void func1() +{ + func2(); +} diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/func2.c b/Tests/RunCMake/target_link_libraries-LINK_GROUP/func2.c new file mode 100644 index 0000000..0f9aa64 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/func2.c @@ -0,0 +1,7 @@ + +extern void func3(); + +void func2() +{ + func3(); +} diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/func3.c b/Tests/RunCMake/target_link_libraries-LINK_GROUP/func3.c new file mode 100644 index 0000000..0b7df64 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/func3.c @@ -0,0 +1,6 @@ + +extern void func3(); + +void func3() +{ +} diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target-result.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target-stdout.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target-stdout.txt new file mode 100644 index 0000000..16b93d1 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target-stdout.txt @@ -0,0 +1,16 @@ +CMake Warning \(dev\) at imported-target.cmake:[0-9]+ \(add_library\): + The 'IMPORTED' target 'NS::lib2' uses the generator-expression + '\$<LINK_GROUP>' with the feature 'feat', which is undefined or unsupported. + + Did you miss to define it by setting variables + "CMAKE_C_LINK_GROUP_USING_feat" and + "CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED"\? +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. + +CMake Error at imported-target.cmake:[0-9]+ \(add_library\): + Feature 'feat', specified through generator-expression '\$<LINK_GROUP>' to + link target 'lib', is not supported for the 'C' link language. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target.cmake new file mode 100644 index 0000000..bd83f97 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target.cmake @@ -0,0 +1,22 @@ + +enable_language(C) + +# Create imported target NS::lib +add_library(NS::lib STATIC IMPORTED) +set_target_properties(NS::lib PROPERTIES + IMPORTED_LOCATION "/path/to/lib" + IMPORTED_IMPLIB "/path/to/import.lib" +) + +# Create imported target NS::lib2 +add_library(NS::lib2 SHARED IMPORTED) + +set_target_properties(NS::lib2 PROPERTIES + IMPORTED_LOCATION "/path/to/lib" + IMPORTED_IMPLIB "/path/to/import.lib" + INTERFACE_LINK_LIBRARIES "$<LINK_GROUP:feat,NS::lib>" +) + + +add_library(lib SHARED lib.c) +target_link_libraries(lib PRIVATE NS::lib2) diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/lib.c b/Tests/RunCMake/target_link_libraries-LINK_GROUP/lib.c new file mode 100644 index 0000000..35ab367 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/lib.c @@ -0,0 +1,15 @@ + +#if !defined(STATIC_BASE) +# if defined(_WIN32) +__declspec(dllimport) +# endif +#endif + void base(); + +#if defined(_WIN32) +__declspec(dllexport) +#endif + void lib() +{ + base(); +} diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/main.c b/Tests/RunCMake/target_link_libraries-LINK_GROUP/main.c new file mode 100644 index 0000000..403583d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/main.c @@ -0,0 +1,7 @@ + +extern void func1(); + +int main() +{ + func1(); +} diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/rescan.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/rescan.cmake new file mode 100644 index 0000000..810b892 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/rescan.cmake @@ -0,0 +1,9 @@ + +enable_language(C) + +# Feature RESCAN +add_library(static1 STATIC func1.c func3.c) +add_library(static2 STATIC func2.c) + +add_executable(main main.c) +target_link_libraries(main PRIVATE "$<LINK_GROUP:RESCAN,static1,static2>") diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/CMakeLists.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/CMakeLists.txt new file mode 100644 index 0000000..915fc41 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.1...3.22) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/External/CMakeLists.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/External/CMakeLists.txt new file mode 100644 index 0000000..212741a --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/External/CMakeLists.txt @@ -0,0 +1,6 @@ + +cmake_minimum_required(VERSION 3.23) + +project(External LANGUAGES C) + +add_library(external SHARED ../unref.c) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group1-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group1-check.cmake new file mode 100644 index 0000000..255c9a6 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group1-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX}") + set (RunCMake_TEST_FAILED "Not found expected '--LIBFLAG<base1> --LIBFLAG<base2>'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group1-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group1-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group1-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group2-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group2-check.cmake new file mode 100644 index 0000000..a8e0da7 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group2-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP") + set (RunCMake_TEST_FAILED "Not found expected '--PREFIXGROUP --LIBGROUP<base1> --LIBGROUP<base2> --SUFFIXGROUP'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group2-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group2-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group2-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items1-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items1-check.cmake new file mode 100644 index 0000000..54cef2c --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items1-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-PREFIXGROUP\"? +\"?.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?${CMAKE_LINK_LIBRARY_FLAG}other${LINK_EXTERN_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP") + set (RunCMake_TEST_FAILED "Not found expected '--PREFIXGROUP <base1> <other> --SUFFIXGROUP'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items1-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items1-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items1-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items2-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items2-check.cmake new file mode 100644 index 0000000..7c38134 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items2-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBGROUPother${LINK_EXTERN_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP") + set (RunCMake_TEST_FAILED "Not found expected '--PREFIXGROUP --LIBGROUP<base1> --LIBGROUP<other> --SUFFIXGROUP'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items2-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items2-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items2-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items3-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items3-check.cmake new file mode 100644 index 0000000..88b5cf6 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items3-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-ITEMFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBFLAGother${LINK_EXTERN_LIBRARY_SUFFIX}\"? +\"?(/|-)-ITEMFLAGother\"? +\"?(/|-)-SUFFIXGROUP") + set (RunCMake_TEST_FAILED "Not found expected '--PREFIXGROUP --LIBFLAG<base1> --ITEMFLAG<base1> --LIBFLAG<other> --ITEMFLAG<other> --SUFFIXGROUP'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items3-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items3-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items3-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items4-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items4-check.cmake new file mode 100644 index 0000000..c473637 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items4-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-ITEMFLAGother\"? +\"?(/|-)-SUFFIXGROUP") + set (RunCMake_TEST_FAILED "Not found expected '--PREFIXGROUP --LIBFLAG<base1> --ITEMFLAG<other> --SUFFIXGROUP'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items4-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items4-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items4-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features1-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features1-check.cmake new file mode 100644 index 0000000..858dcfe --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features1-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP") + set (RunCMake_TEST_FAILED "Not found expected '--PREFIXGROUP --LIBGROUP<base1> --LIBGROUP<base3> --SUFFIXGROUP'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features1-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features1-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features1-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features2-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features2-check.cmake new file mode 100644 index 0000000..ab06726 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features2-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP") + set (RunCMake_TEST_FAILED "Not found expected '--PREFIXGROUP --LIBGROUP<base3> --LIBGROUP<base1> --SUFFIXGROUP'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features2-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features2-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features2-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features3-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features3-check.cmake new file mode 100644 index 0000000..62aa17c --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features3-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP\"? +\"?${CMAKE_LINK_LIBRARY_FLAG}other2${LINK_EXTERN_LIBRARY_SUFFIX}\"? +\"?(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP\"? +\"?${CMAKE_LINK_LIBRARY_FLAG}other1${LINK_EXTERN_LIBRARY_SUFFIX}") + set (RunCMake_TEST_FAILED "Not found expected '<base2> --PREFIXGROUP --LIBGROUP<base3> --SUFFIXGROUP <other2> --PREFIXGROUP --LIBGROUP<base1> --SUFFIXGROUP <other1>'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features3-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features3-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features3-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature1-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature1-check.cmake new file mode 100644 index 0000000..255c9a6 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature1-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX}") + set (RunCMake_TEST_FAILED "Not found expected '--LIBFLAG<base1> --LIBFLAG<base2>'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature1-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature1-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature1-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature2-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature2-check.cmake new file mode 100644 index 0000000..a8e0da7 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature2-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP") + set (RunCMake_TEST_FAILED "Not found expected '--PREFIXGROUP --LIBGROUP<base1> --LIBGROUP<base2> --SUFFIXGROUP'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature2-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature2-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature2-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features1-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features1-check.cmake new file mode 100644 index 0000000..a9fba20 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features1-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?${CMAKE_LINK_LIBRARY_FLAG}other1") + set (RunCMake_TEST_FAILED "Not found expected '--LIBFLAG<base3> --LIBFLAG<base1> <other1>'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features1-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features1-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features1-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features2-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features2-check.cmake new file mode 100644 index 0000000..58c117e --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features2-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBGROUPother1${LINK_EXTERN_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP") + set (RunCMake_TEST_FAILED "Not found expected '--LIBFLAG<base3> --PREFIXGROUP --LIBGROUP<base1> --LIBGROUP<other1> --SUFFIXGROUP'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features2-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features2-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features2-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features3-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features3-check.cmake new file mode 100644 index 0000000..a9fba20 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features3-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?${CMAKE_LINK_LIBRARY_FLAG}other1") + set (RunCMake_TEST_FAILED "Not found expected '--LIBFLAG<base3> --LIBFLAG<base1> <other1>'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features3-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features3-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features3-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features4-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features4-check.cmake new file mode 100644 index 0000000..58c117e --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features4-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBGROUPother1${LINK_EXTERN_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP") + set (RunCMake_TEST_FAILED "Not found expected '--LIBFLAG<base3> --PREFIXGROUP --LIBGROUP<base1> --LIBGROUP<other1> --SUFFIXGROUP'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features4-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features4-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features4-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-with-DEFAULT-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-with-DEFAULT-check.cmake new file mode 100644 index 0000000..d022f7e --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-with-DEFAULT-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?${CMAKE_LINK_LIBRARY_FLAG}other1${LINK_EXTERN_LIBRARY_SUFFIX}\"?") + set (RunCMake_TEST_FAILED "Not found expected '--LIBFLAG<base3> <base1> <other1>'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-with-DEFAULT-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-with-DEFAULT-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-with-DEFAULT-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple1-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple1-check.cmake new file mode 100644 index 0000000..32b58fe --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple1-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1") + set (RunCMake_TEST_FAILED "Not found expected '--LIBFLAG<base1>'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple1-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple1-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple1-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple2-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple2-check.cmake new file mode 100644 index 0000000..32b58fe --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple2-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1") + set (RunCMake_TEST_FAILED "Not found expected '--LIBFLAG<base1>'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple2-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple2-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple2-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY.cmake new file mode 100644 index 0000000..f19112a --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY.cmake @@ -0,0 +1,103 @@ +enable_language(C) + +# ensure command line is always displayed and do not use any response file +set(CMAKE_VERBOSE_MAKEFILE TRUE) +set(CMAKE_C_USE_RESPONSE_FILE_FOR_LIBRARIES FALSE) + +if (CMAKE_GENERATOR MATCHES "Borland|NMake") + string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY}") + string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY}") +endif() + +add_library(base1 SHARED base.c) +add_library(base2 SHARED base.c) + +set(CMAKE_C_LINK_LIBRARY_USING_feat1 "--LIBFLAG<LIBRARY>") +set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE) + +set(CMAKE_C_LINK_LIBRARY_USING_feat1_1 "--LIBFLAG_C<LIBRARY>") +set(CMAKE_LINK_LIBRARY_USING_feat1_1 "--LIBFLAG<LIBRARY>") +set(CMAKE_LINK_LIBRARY_USING_feat1_1_SUPPORTED TRUE) + +set(CMAKE_C_LINK_LIBRARY_USING_feat2 "--PREFIXGROUP" "--LIBGROUP<LIBRARY>" "--SUFFIXGROUP") +set(CMAKE_C_LINK_LIBRARY_USING_feat2_SUPPORTED TRUE) + +set(CMAKE_C_LINK_LIBRARY_USING_feat3 "--PREFIXGROUP" "<LINK_ITEM>" "--SUFFIXGROUP") +set(CMAKE_C_LINK_LIBRARY_USING_feat3_SUPPORTED TRUE) + +set(CMAKE_C_LINK_LIBRARY_USING_feat4 "--PREFIXGROUP" "--LIBFLAG<LIBRARY> --ITEMFLAG<LIB_ITEM>" "--SUFFIXGROUP") +set(CMAKE_C_LINK_LIBRARY_USING_feat4_SUPPORTED TRUE) + +set(CMAKE_C_LINK_LIBRARY_USING_feat5 "--PREFIXGROUP" "PATH{--LIBFLAG<LIBRARY>}NAME{--ITEMFLAG<LIB_ITEM>}" "--SUFFIXGROUP") +set(CMAKE_C_LINK_LIBRARY_USING_feat5_SUPPORTED TRUE) + +set(CMAKE_C_LINK_LIBRARY_USING_feat6 "<LINK_ITEM>") +set(CMAKE_C_LINK_LIBRARY_USING_feat6_SUPPORTED TRUE) + + +add_library(LinkLibrary_simple1 SHARED lib.c) +target_link_libraries(LinkLibrary_simple1 PRIVATE "$<LINK_LIBRARY:feat1,base1>") + +add_library(LinkLibrary_simple2 SHARED lib.c) +target_link_libraries(LinkLibrary_simple2 PRIVATE "$<LINK_LIBRARY:feat1_1,base1>") + +add_library(LinkLibrary_group1 SHARED lib.c) +target_link_libraries(LinkLibrary_group1 PRIVATE "$<LINK_LIBRARY:feat1,base1,base2>") + +add_library(LinkLibrary_group2 SHARED lib.c) +target_link_libraries(LinkLibrary_group2 PRIVATE "$<LINK_LIBRARY:feat2,base1,base2>") + +add_library(LinkLibrary_nested_feature1 SHARED lib.c) +target_link_libraries(LinkLibrary_nested_feature1 PRIVATE "$<LINK_LIBRARY:feat1,base1,$<LINK_LIBRARY:feat1,base2>>") + +add_library(LinkLibrary_nested_feature2 SHARED lib.c) +target_link_libraries(LinkLibrary_nested_feature2 PRIVATE "$<LINK_LIBRARY:feat2,base1,$<LINK_LIBRARY:feat2,base2>>") + +add_library(LinkLibrary_link_items1 SHARED lib.c) +target_link_libraries(LinkLibrary_link_items1 PRIVATE "$<LINK_LIBRARY:feat3,base1,other>") + +add_library(LinkLibrary_link_items2 SHARED lib.c) +target_link_libraries(LinkLibrary_link_items2 PRIVATE "$<LINK_LIBRARY:feat2,base1,other>") + +add_library(LinkLibrary_link_items3 SHARED lib.c) +target_link_libraries(LinkLibrary_link_items3 PRIVATE "$<LINK_LIBRARY:feat4,base1,other>") + +add_library(LinkLibrary_link_items4 SHARED lib.c) +target_link_libraries(LinkLibrary_link_items4 PRIVATE "$<LINK_LIBRARY:feat5,base1,other>") + +add_library(base3 SHARED base.c) +target_link_libraries(base3 PRIVATE "$<LINK_LIBRARY:feat6,base1>") +add_library(LinkLibrary_mix_features1 SHARED lib.c) +target_link_libraries(LinkLibrary_mix_features1 PRIVATE "$<LINK_LIBRARY:feat2,base1,base3>") + +target_link_libraries(base3 INTERFACE "$<LINK_LIBRARY:feat2,base1>") +add_library(LinkLibrary_mix_features2 SHARED lib.c) +target_link_libraries(LinkLibrary_mix_features2 PRIVATE "$<LINK_LIBRARY:feat2,base1,base3>") + +target_link_libraries(base3 INTERFACE other1) +add_library(LinkLibrary_mix_features3 SHARED lib.c) +target_link_libraries(LinkLibrary_mix_features3 PRIVATE base2 "$<LINK_LIBRARY:feat2,base1,base3>" other2) + +# testing LINK_LIBRARY_OVERRIDE property +add_library(LinkLibrary_override_features1 SHARED lib.c) +target_link_libraries(LinkLibrary_override_features1 PRIVATE "$<LINK_LIBRARY:feat1,base1,base3>") +set_property(TARGET LinkLibrary_override_features1 PROPERTY LINK_LIBRARY_OVERRIDE "feat1,base1") + +add_library(LinkLibrary_override_features2 SHARED lib.c) +target_link_libraries(LinkLibrary_override_features2 PRIVATE "$<LINK_LIBRARY:feat1,base1,base3>") +set_property(TARGET LinkLibrary_override_features2 PROPERTY LINK_LIBRARY_OVERRIDE "feat2,base1,other1") + +add_library(LinkLibrary_override_with_default SHARED lib.c) +target_link_libraries(LinkLibrary_override_with_default PRIVATE "$<LINK_LIBRARY:feat1,base1,base3>") +set_property(TARGET LinkLibrary_override_with_default PROPERTY LINK_LIBRARY_OVERRIDE "$<$<LINK_LANGUAGE:C>:DEFAULT,base1,other1>") + +# testing LINK_LIBRARY_OVERRIDE_<LIBRARY> property +add_library(LinkLibrary_override_features3 SHARED lib.c) +target_link_libraries(LinkLibrary_override_features3 PRIVATE "$<LINK_LIBRARY:feat1,base1,base3>") +set_property(TARGET LinkLibrary_override_features3 PROPERTY LINK_LIBRARY_OVERRIDE_base1 feat1) + +add_library(LinkLibrary_override_features4 SHARED lib.c) +target_link_libraries(LinkLibrary_override_features4 PRIVATE "$<LINK_LIBRARY:feat1,base1,base3>") +set_property(TARGET LinkLibrary_override_features4 PROPERTY LINK_LIBRARY_OVERRIDE "feat3,base1,other1") +set_property(TARGET LinkLibrary_override_features4 PROPERTY LINK_LIBRARY_OVERRIDE_base1 feat2) +set_property(TARGET LinkLibrary_override_features4 PROPERTY LINK_LIBRARY_OVERRIDE_other1 feat2) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake new file mode 100644 index 0000000..021de41 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake @@ -0,0 +1,122 @@ + +include(RunCMake) + +cmake_policy(SET CMP0054 NEW) + +macro(run_cmake_target test subtest target) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(${test}-${subtest} ${CMAKE_COMMAND} --build . --target ${target} --config Release --verbose ${ARGN}) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) +endmacro() + +# Some environments are excluded because they are not able to honor verbose mode +if ((RunCMake_GENERATOR MATCHES "Makefiles|Ninja|Xcode" + OR (RunCMake_GENERATOR MATCHES "Visual Studio" AND MSVC_VERSION GREATER_EQUAL "1600")) + AND NOT CMAKE_C_COMPILER_ID STREQUAL "Intel") + + set(RunCMake_TEST_OUTPUT_MERGE TRUE) + if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release) + endif() + + if (CMAKE_SYSTEM_NAME STREQUAL "Windows" + OR CMAKE_SYSTEM_NAME STREQUAL "CYGWIN" + OR CMAKE_SYSTEM_NAME STREQUAL "MSYS") + set(LINK_SHARED_LIBRARY_PREFIX ${CMAKE_IMPORT_LIBRARY_PREFIX}) + set(LINK_SHARED_LIBRARY_SUFFIX ${CMAKE_IMPORT_LIBRARY_SUFFIX}) + else() + set(LINK_SHARED_LIBRARY_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX}) + set(LINK_SHARED_LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX}) + endif() + if (MINGW OR MSYS OR CYGWIN) + set(LINK_EXTERN_LIBRARY_SUFFIX "") + else() + set(LINK_EXTERN_LIBRARY_SUFFIX "${CMAKE_IMPORT_LIBRARY_SUFFIX}") + endif() + + run_cmake(LINK_LIBRARY) + + run_cmake_target(LINK_LIBRARY simple1 LinkLibrary_simple1) + run_cmake_target(LINK_LIBRARY simple2 LinkLibrary_simple2) + run_cmake_target(LINK_LIBRARY group1 LinkLibrary_group1) + run_cmake_target(LINK_LIBRARY group2 LinkLibrary_group2) + run_cmake_target(LINK_LIBRARY nested-feature1 LinkLibrary_nested_feature1) + run_cmake_target(LINK_LIBRARY nested-feature2 LinkLibrary_nested_feature2) + run_cmake_target(LINK_LIBRARY link-items1 LinkLibrary_link_items1) + run_cmake_target(LINK_LIBRARY link-items2 LinkLibrary_link_items2) + run_cmake_target(LINK_LIBRARY link-items3 LinkLibrary_link_items3) + run_cmake_target(LINK_LIBRARY link-items4 LinkLibrary_link_items4) + run_cmake_target(LINK_LIBRARY mix-features1 LinkLibrary_mix_features1) + run_cmake_target(LINK_LIBRARY mix-features2 LinkLibrary_mix_features2) + run_cmake_target(LINK_LIBRARY mix-features3 LinkLibrary_mix_features3) + + # testing target property LINK_LIBRARY_OVERRIDE + run_cmake_target(LINK_LIBRARY override-features1 LinkLibrary_override_features1) + run_cmake_target(LINK_LIBRARY override-features2 LinkLibrary_override_features2) + run_cmake_target(LINK_LIBRARY override-with-DEFAULT LinkLibrary_override_with_default) + # testing target property LINK_LIBRARY_OVERRIDE_<LIBRARY> + run_cmake_target(LINK_LIBRARY override-features3 LinkLibrary_override_features3) + run_cmake_target(LINK_LIBRARY override-features4 LinkLibrary_override_features4) + + run_cmake(imported-target) + + # tests using features as described in the documentation + if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang" + OR (CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND MSVC_VERSION GREATER "1900") + OR (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux")) + run_cmake(load_archive) + run_cmake_target(load_archive link-exe main) + endif() + if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang") + run_cmake(weak_library) + run_cmake_target(weak_library link-exe main) + endif() + + unset(RunCMake_TEST_OPTIONS) + unset(RunCMake_TEST_OUTPUT_MERGE) + +endif() + +# Apple framework features +if(APPLE AND (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")) + run_cmake(apple_framework) + run_cmake_target(apple_framework framework main-framework) + run_cmake_target(apple_framework reexport_framework main-reexport_framework) + run_cmake_target(apple_framework weak_framework main-weak_framework) + + run_cmake_target(apple_framework target-framework main-target-framework) + run_cmake_target(apple_framework target-reexport_framework main-target-reexport_framework) + run_cmake_target(apple_framework target-weak_framework main-target-weak_framework) +endif() + +if (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_C_COMPILER_VERSION GREATER_EQUAL "12") + run_cmake_target(apple_framework needed_framework main-needed_framework) + + run_cmake_target(apple_framework target-needed_framework main-target-needed_framework) +endif() + +# Apple library features +if(APPLE AND (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")) + run_cmake(apple_library_external) + run_cmake_target(apple_library_external build external) + run_cmake_with_options(apple_library "-DRunCMake_BINARY_DIR=${RunCMake_BINARY_DIR}") + run_cmake_target(apple_library reexport_library main-reexport_library) + run_cmake_target(apple_library weak_library main-weak_library) +endif() + +if (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_C_COMPILER_VERSION GREATER_EQUAL "12") + run_cmake_target(apple_library needed_library main-needed_library) +endif() + +# WHOLE_ARCHIVE feature +if ((CMAKE_SYSTEM_NAME STREQUAL "Windows" AND + ((DEFINED MSVC_VERSION AND MSVC_VERSION GREATER "1900") OR (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang" AND NOT CMAKE_C_SIMULATE_ID STREQUAL "MSVC"))) + OR (CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND + (NOT CMAKE_C_COMPILER_ID STREQUAL "SunPro" OR CMAKE_C_COMPILER_VERSION GREATER "5.9")) + OR CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|watchOS|Linux|BSD|MSYS|CYGWIN") + run_cmake(feature-WHOLE_ARCHIVE) + run_cmake_target(feature-WHOLE_ARCHIVE link-exe main) +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/apple_framework.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/apple_framework.cmake new file mode 100644 index 0000000..e9a93e9 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/apple_framework.cmake @@ -0,0 +1,61 @@ + +enable_language(OBJCXX) + + +# feature FRAMEWORK +add_library(foo-framework SHARED foo.mm) +target_link_libraries(foo-framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>") + +add_executable(main-framework main.mm) +target_link_libraries(main-framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>" foo-framework) + + +# feature NEEDED_FRAMEWORK +add_library(foo-needed_framework SHARED foo.mm) +target_link_libraries(foo-needed_framework PRIVATE "$<LINK_LIBRARY:NEEDED_FRAMEWORK,Foundation>") + +add_executable(main-needed_framework main.mm) +target_link_libraries(main-needed_framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>" foo-needed_framework) + + +# feature REEXPORT_FRAMEWORK +add_library(foo-reexport_framework SHARED foo.mm) +target_link_libraries(foo-reexport_framework PRIVATE "$<LINK_LIBRARY:REEXPORT_FRAMEWORK,Foundation>") + +add_executable(main-reexport_framework main.mm) +target_link_libraries(main-reexport_framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>" foo-reexport_framework) + + +# feature WEAK_FRAMEWORK +add_library(foo-weak_framework SHARED foo.mm) +target_link_libraries(foo-weak_framework PRIVATE "$<LINK_LIBRARY:WEAK_FRAMEWORK,Foundation>") + +add_executable(main-weak_framework main.mm) +target_link_libraries(main-weak_framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>" foo-weak_framework) + + +## +## Consumption of target specified as FRAMEWORK +add_library(target-framework SHARED foo.mm) +set_target_properties(target-framework PROPERTIES FRAMEWORK TRUE) +target_link_libraries(target-framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>") + + +# feature FRAMEWORK +add_executable(main-target-framework main.mm) +target_link_libraries(main-target-framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>" "$<LINK_LIBRARY:FRAMEWORK,target-framework>") + + +# feature NEEDED_FRAMEWORK +add_executable(main-target-needed_framework main.mm) +target_link_libraries(main-target-needed_framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>" "$<LINK_LIBRARY:NEEDED_FRAMEWORK,target-framework>") + + +# feature REEXPORT_FRAMEWORK +add_executable(main-target-reexport_framework main.mm) +target_link_libraries(main-target-reexport_framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>" "$<LINK_LIBRARY:REEXPORT_FRAMEWORK,target-framework>") + + +# feature WEAK_FRAMEWORK +add_executable(main-target-weak_framework main.mm) +target_link_libraries(main-target-weak_framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>" "$<LINK_LIBRARY:REEXPORT_FRAMEWORK,target-framework>") diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/apple_library.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/apple_library.cmake new file mode 100644 index 0000000..fb85d05 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/apple_library.cmake @@ -0,0 +1,24 @@ + +enable_language(C) + +add_library(lib SHARED base.c lib.c) + +# feature NEEDED_FRAMEWORK +add_executable(main-needed_library main.c) +target_link_directories(main-needed_library PRIVATE "${RunCMake_BINARY_DIR}/apple_library_external-build" + "${RunCMake_BINARY_DIR}/apple_library_external-build/$<CONFIG>") +target_link_libraries(main-needed_library PRIVATE "$<LINK_LIBRARY:NEEDED_LIBRARY,lib,external>") + + +# feature REEXPORT_FRAMEWORK +add_executable(main-reexport_library main.c) +target_link_directories(main-reexport_library PRIVATE "${RunCMake_BINARY_DIR}/apple_library_external-build" + "${RunCMake_BINARY_DIR}/apple_library_external-build/$<CONFIG>") +target_link_libraries(main-reexport_library PRIVATE "$<LINK_LIBRARY:REEXPORT_LIBRARY,lib,external>") + + +# feature WEAK_FRAMEWORK +add_executable(main-weak_library main.c) +target_link_directories(main-weak_library PRIVATE "${RunCMake_BINARY_DIR}/apple_library_external-build" + "${RunCMake_BINARY_DIR}/apple_library_external-build/$<CONFIG>") +target_link_libraries(main-weak_library PRIVATE "$<LINK_LIBRARY:WEAK_LIBRARY,lib,external>") diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/apple_library_external.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/apple_library_external.cmake new file mode 100644 index 0000000..f5a566f --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/apple_library_external.cmake @@ -0,0 +1,4 @@ + +enable_language(C) + +add_library(external SHARED unref.c) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/base.c b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/base.c new file mode 100644 index 0000000..ed769a0 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/base.c @@ -0,0 +1,9 @@ + +#if !defined(STATIC_BASE) +# if defined(_WIN32) +__declspec(dllexport) +# endif +#endif + void base(void) +{ +} diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/feature-WHOLE_ARCHIVE.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/feature-WHOLE_ARCHIVE.cmake new file mode 100644 index 0000000..e525325 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/feature-WHOLE_ARCHIVE.cmake @@ -0,0 +1,11 @@ + +enable_language(C) + +add_library(base STATIC base.c unref.c) +target_compile_definitions(base PUBLIC STATIC_BASE) + +add_library(lib SHARED lib.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:WHOLE_ARCHIVE,base>") + +add_executable(main main.c) +target_link_libraries(main PRIVATE lib) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/foo.h b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/foo.h new file mode 100644 index 0000000..b3fb084 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/foo.h @@ -0,0 +1,9 @@ +#import <Foundation/Foundation.h> + +@interface Foo : NSObject { + NSNumber* age; +} + +@property (nonatomic, retain) NSNumber* age; + +@end diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/foo.mm b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/foo.mm new file mode 100644 index 0000000..2d452a8 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/foo.mm @@ -0,0 +1,7 @@ +#import "foo.h" + +@implementation Foo + +@synthesize age; + +@end diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target-stdout.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target-stdout.txt new file mode 100644 index 0000000..981376a --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target-stdout.txt @@ -0,0 +1,18 @@ +CMake Warning \(dev\) at imported-target.cmake:[0-9]+ \(add_library\): + The 'IMPORTED' target 'NS::lib2' uses the generator-expression + '\$<LINK_LIBRARY>' with the feature 'whole_archive', which is undefined or + unsupported. + + Did you miss to define it by setting variables + "CMAKE_C_LINK_LIBRARY_USING_whole_archive" and + "CMAKE_C_LINK_LIBRARY_USING_whole_archive_SUPPORTED"\? +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. + +CMake Error at imported-target.cmake:[0-9]+ \(add_library\): + Feature 'whole_archive', specified through generator-expression + '\$<LINK_LIBRARY>' to link target 'lib', is not supported for the 'C' link + language. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target.cmake new file mode 100644 index 0000000..9283054 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target.cmake @@ -0,0 +1,18 @@ + +enable_language(C) + +# Create imported target NS::lib +add_library(NS::lib STATIC IMPORTED) + +# Create imported target NS::lib2 +add_library(NS::lib2 SHARED IMPORTED) + +set_target_properties(NS::lib2 PROPERTIES + IMPORTED_LOCATION "/path/to/lib" + IMPORTED_IMPLIB "/path/to/import.lib" + INTERFACE_LINK_LIBRARIES "$<LINK_LIBRARY:whole_archive,NS::lib>" +) + + +add_library(lib SHARED lib.c) +target_link_libraries(lib PRIVATE NS::lib2) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/lib.c b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/lib.c new file mode 100644 index 0000000..21f559c --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/lib.c @@ -0,0 +1,15 @@ + +#if !defined(STATIC_BASE) +# if defined(_WIN32) +__declspec(dllimport) +# endif +#endif + void base(void); + +#if defined(_WIN32) +__declspec(dllexport) +#endif + void lib(void) +{ + base(); +} diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/load_archive.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/load_archive.cmake new file mode 100644 index 0000000..a0bbb43 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/load_archive.cmake @@ -0,0 +1,34 @@ + +enable_language(C) + +set(CMAKE_C_LINK_LIBRARY_USING_load_archive_SUPPORTED TRUE) +if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang") + set(CMAKE_C_LINK_LIBRARY_USING_load_archive "-force_load <LIB_ITEM>") +elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux") + execute_process(COMMAND "${CMAKE_LINKER}" --help + OUTPUT_VARIABLE linker_help + ERROR_VARIABLE linker_help) + if(linker_help MATCHES "--push-state" AND linker_help MATCHES "--pop-state") + set(CMAKE_C_LINK_LIBRARY_USING_load_archive "LINKER:--push-state,--whole-archive" + "<LINK_ITEM>" + "LINKER:--pop-state") + else() + set(CMAKE_C_LINK_LIBRARY_USING_load_archive "LINKER:--whole-archive" + "<LINK_ITEM>" + "LINKER:--no-whole-archive") + endif() +elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC") + set(CMAKE_C_LINK_LIBRARY_USING_load_archive "/WHOLEARCHIVE:<LIBRARY>") +else() + # feature not yet supported for the other environments + set(CMAKE_C_LINK_LIBRARY_USING_load_archive_SUPPORTED FALSE) +endif() + +add_library(base STATIC base.c unref.c) +target_compile_definitions(base PUBLIC STATIC_BASE) + +add_library(lib SHARED lib.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:load_archive,base>") + +add_executable(main main.c) +target_link_libraries(main PRIVATE lib) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/main.c b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/main.c new file mode 100644 index 0000000..2e39bce --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/main.c @@ -0,0 +1,18 @@ + +#if defined(_WIN32) +__declspec(dllimport) +#endif + void lib(void); + +#if defined(_WIN32) +__declspec(dllimport) +#endif + void unref(void); + +int main(void) +{ + lib(); + unref(); + + return 0; +} diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/main.mm b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/main.mm new file mode 100644 index 0000000..7c85551 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/main.mm @@ -0,0 +1,14 @@ +#import <Foundation/Foundation.h> +#import "foo.h" +#include <iostream> + +int main(int argc, char **argv) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + Foo *theFoo = [[Foo alloc] init]; + theFoo.age = [NSNumber numberWithInt:argc]; + NSLog(@"%d\n",[theFoo.age intValue]); + std::cout << [theFoo.age intValue] << std::endl; + [pool release]; + return 0; +} diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/unref.c b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/unref.c new file mode 100644 index 0000000..11922de --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/unref.c @@ -0,0 +1,8 @@ + + +#if defined(_WIN32) +__declspec(dllexport) +#endif + void unref(void) +{ +} diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/weak_library.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/weak_library.cmake new file mode 100644 index 0000000..45b4f66 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/weak_library.cmake @@ -0,0 +1,20 @@ + +enable_language(C) + +if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang") + set(CMAKE_LINK_LIBRARY_USING_weak_library "PATH{-weak_library <LIBRARY>}NAME{LINKER:-weak-l<LIB_ITEM>}") + set(CMAKE_LINK_LIBRARY_USING_weak_library_SUPPORTED TRUE) +else() + # feature not yet supported for the other environments + set(CMAKE_LINK_LIBRARY_USING_whole_library_SUPPORTED FALSE) +endif() + +add_library(lib SHARED base.c lib.c unref.c) +set_property(TARGET lib PROPERTY OUTPUT_NAME base) + +add_executable(main main.c) +target_link_libraries(main PRIVATE "$<LINK_LIBRARY:weak_library,lib>") + +add_executable(main2 main.c) +target_link_directories(main2 PRIVATE "$<TARGET_FILE_DIR:lib>") +target_link_libraries(main2 PRIVATE "$<LINK_LIBRARY:weak_library,base>") diff --git a/Tests/RunCMake/target_sources/FileSetFramework-result.txt b/Tests/RunCMake/target_sources/FileSetFramework-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetFramework-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetFramework-stderr.txt b/Tests/RunCMake/target_sources/FileSetFramework-stderr.txt new file mode 100644 index 0000000..ae7026a --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetFramework-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at FileSetFramework\.cmake:[0-9]+ \(target_sources\): + target_sources FILE_SETs may not be added to FRAMEWORK targets +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetFramework.cmake b/Tests/RunCMake/target_sources/FileSetFramework.cmake new file mode 100644 index 0000000..d8a924f --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetFramework.cmake @@ -0,0 +1,7 @@ +enable_language(C) + +add_library(lib1 SHARED lib1.c) +set_property(TARGET lib1 PROPERTY FRAMEWORK ON) +target_sources(lib1 + PUBLIC FILE_SET HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} FILES h1.h + ) diff --git a/Tests/RunCMake/target_sources/RunCMakeTest.cmake b/Tests/RunCMake/target_sources/RunCMakeTest.cmake index d23bce1..743879e 100644 --- a/Tests/RunCMake/target_sources/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_sources/RunCMakeTest.cmake @@ -40,6 +40,9 @@ run_cmake(FileSetNoExistInstall) run_cmake(FileSetDirectories) run_cmake(FileSetCustomTarget) run_cmake(FileSetBadName) +if(APPLE) + run_cmake(FileSetFramework) +endif() set(RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0115=NEW) run_cmake(FileSetFileNoExist) diff --git a/Tests/RunCMake/while/CMP0130-NEW-result.txt b/Tests/RunCMake/while/CMP0130-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/while/CMP0130-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/while/CMP0130-NEW-stderr.txt b/Tests/RunCMake/while/CMP0130-NEW-stderr.txt new file mode 100644 index 0000000..df492d5 --- /dev/null +++ b/Tests/RunCMake/while/CMP0130-NEW-stderr.txt @@ -0,0 +1,9 @@ +^CMake Error at CMP0130-common.cmake:[0-9]+ \(while\): + while\(\) given incorrect arguments: + + "\(" + + mismatched parenthesis in condition +Call Stack \(most recent call first\): + CMP0130-NEW.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/while/CMP0130-NEW.cmake b/Tests/RunCMake/while/CMP0130-NEW.cmake new file mode 100644 index 0000000..3cc5027 --- /dev/null +++ b/Tests/RunCMake/while/CMP0130-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0130 NEW) +include(CMP0130-common.cmake) diff --git a/Tests/RunCMake/while/unbalanced-parenthesis-stdout.txt b/Tests/RunCMake/while/CMP0130-OLD-stdout.txt index d45e194..d45e194 100644 --- a/Tests/RunCMake/while/unbalanced-parenthesis-stdout.txt +++ b/Tests/RunCMake/while/CMP0130-OLD-stdout.txt diff --git a/Tests/RunCMake/while/CMP0130-OLD.cmake b/Tests/RunCMake/while/CMP0130-OLD.cmake new file mode 100644 index 0000000..15a4290 --- /dev/null +++ b/Tests/RunCMake/while/CMP0130-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0130 OLD) +include(CMP0130-common.cmake) diff --git a/Tests/RunCMake/while/CMP0130-WARN-stderr.txt b/Tests/RunCMake/while/CMP0130-WARN-stderr.txt new file mode 100644 index 0000000..bc88c5e --- /dev/null +++ b/Tests/RunCMake/while/CMP0130-WARN-stderr.txt @@ -0,0 +1,14 @@ +^CMake Warning \(dev\) at CMP0130-common.cmake:[0-9]+ \(while\): + Policy CMP0130 is not set: while\(\) diagnoses condition evaluation errors. + Run "cmake --help-policy CMP0130" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + while\(\) given incorrect arguments: + + "\(" + + mismatched parenthesis in condition +Call Stack \(most recent call first\): + CMP0130-WARN.cmake:[0-9]+ \(include\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/while/CMP0130-WARN-stdout.txt b/Tests/RunCMake/while/CMP0130-WARN-stdout.txt new file mode 100644 index 0000000..d45e194 --- /dev/null +++ b/Tests/RunCMake/while/CMP0130-WARN-stdout.txt @@ -0,0 +1 @@ +-- Code incorrectly accepted diff --git a/Tests/RunCMake/while/CMP0130-WARN.cmake b/Tests/RunCMake/while/CMP0130-WARN.cmake new file mode 100644 index 0000000..562c25d --- /dev/null +++ b/Tests/RunCMake/while/CMP0130-WARN.cmake @@ -0,0 +1,2 @@ +# CMP0130 left unset +include(CMP0130-common.cmake) diff --git a/Tests/RunCMake/while/unbalanced-parenthesis.cmake b/Tests/RunCMake/while/CMP0130-common.cmake index 39d736b..15322e0 100644 --- a/Tests/RunCMake/while/unbalanced-parenthesis.cmake +++ b/Tests/RunCMake/while/CMP0130-common.cmake @@ -3,5 +3,4 @@ while(${paren}) message(STATUS "Condition incorrectly true") break() endwhile() -# FIXME(#23296): The above condition error is tolerated for compatibility. message(STATUS "Code incorrectly accepted") diff --git a/Tests/RunCMake/while/RunCMakeTest.cmake b/Tests/RunCMake/while/RunCMakeTest.cmake index bb9b991..d018b16 100644 --- a/Tests/RunCMake/while/RunCMakeTest.cmake +++ b/Tests/RunCMake/while/RunCMakeTest.cmake @@ -6,4 +6,6 @@ run_cmake(EndMismatch) run_cmake(EndAlone) run_cmake(EndAloneArgs) -run_cmake(unbalanced-parenthesis) +run_cmake(CMP0130-OLD) +run_cmake(CMP0130-WARN) +run_cmake(CMP0130-NEW) diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index b1b9d57..594f37a 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -32,7 +32,7 @@ endmacro() # try to compile a file that should compile # also check that COPY_FILE works try_compile(SHOULD_PASS - ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_BINARY_DIR} ${TryCompile_SOURCE_DIR}/pass.c OUTPUT_VARIABLE TRY_OUT COPY_FILE ${TryCompile_BINARY_DIR}/CopyOfPass @@ -51,7 +51,7 @@ endif() # also check that COPY_FILE_ERROR works file(WRITE ${TryCompile_BINARY_DIR}/invalid "") try_compile(SHOULD_PASS - ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_BINARY_DIR} ${TryCompile_SOURCE_DIR}/pass.c OUTPUT_VARIABLE TRY_OUT COPY_FILE ${TryCompile_BINARY_DIR}/invalid/path @@ -66,7 +66,7 @@ endif() # try to compile a file that should not compile try_compile(SHOULD_FAIL - ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_BINARY_DIR} ${TryCompile_SOURCE_DIR}/fail.c OUTPUT_VARIABLE TRY_OUT) if(SHOULD_FAIL) @@ -75,7 +75,7 @@ endif() # try to compile a file that should compile try_compile(SHOULD_PASS - ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_BINARY_DIR} ${TryCompile_SOURCE_DIR}/pass.c OUTPUT_VARIABLE TRY_OUT) if(NOT SHOULD_PASS) @@ -84,7 +84,7 @@ endif() # try to compile a file that should not compile try_compile(SHOULD_FAIL - ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_BINARY_DIR} ${TryCompile_SOURCE_DIR}/fail.c OUTPUT_VARIABLE TRY_OUT) if(SHOULD_FAIL) @@ -93,7 +93,7 @@ endif() # try to compile two files that should compile try_compile(SHOULD_PASS - ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_BINARY_DIR} SOURCES ${TryCompile_SOURCE_DIR}/pass2a.c ${TryCompile_SOURCE_DIR}/pass2b.cxx OUTPUT_VARIABLE TRY_OUT) if(NOT SHOULD_PASS) @@ -102,7 +102,7 @@ endif() # try to compile two files that should not compile try_compile(SHOULD_FAIL - ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_BINARY_DIR} SOURCES ${TryCompile_SOURCE_DIR}/fail2a.c ${TryCompile_SOURCE_DIR}/fail2b.c OUTPUT_VARIABLE TRY_OUT) if(SHOULD_FAIL) @@ -117,7 +117,7 @@ else() string(APPEND CMAKE_C_FLAGS " \"-DTESTDEF\"") endif() try_compile(SHOULD_PASS - ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_BINARY_DIR} ${TryCompile_SOURCE_DIR}/testdef.c OUTPUT_VARIABLE TRY_OUT) if(NOT SHOULD_PASS) @@ -135,7 +135,7 @@ else() message("Test failed") endif() try_compile(CMAKE_ANSI_FOR_SCOPE - ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_BINARY_DIR} ${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx OUTPUT_VARIABLE OUT) if (CMAKE_ANSI_FOR_SCOPE) message("Compiler supports ansi for") @@ -144,7 +144,7 @@ else() endif() try_compile(CMAKE_ANSI_FOR_SCOPE - ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_BINARY_DIR} ${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx OUTPUT_VARIABLE OUT) if (CMAKE_ANSI_FOR_SCOPE) message("Compiler supports ansi for") @@ -169,7 +169,7 @@ try_compile(TEST_INNER TEST_ASSERT(TEST_INNER "try_compile project mode failed:\n${output}") try_compile(COMPILE_DEFINITIONS_LIST_EXPANDED - ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_BINARY_DIR} ${TryCompile_SOURCE_DIR}/check_a_b.c OUTPUT_VARIABLE output COMPILE_DEFINITIONS "-DDEF_A;-DDEF_B" @@ -182,7 +182,7 @@ else() endif() try_compile(SHOULD_FAIL_DUE_TO_BAD_SOURCE - ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_BINARY_DIR} ${TryCompile_SOURCE_DIR}/pass.c OUTPUT_VARIABLE output COMPILE_DEFINITIONS "bad#source.c" @@ -207,7 +207,7 @@ add_executable(TryCompile pass.c) # also check that OUTPUT_VARIABLE contains both the compile output # and the run output try_run(SHOULD_RUN SHOULD_COMPILE - ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_BINARY_DIR} ${TryCompile_SOURCE_DIR}/exit_success.c OUTPUT_VARIABLE TRY_OUT) if(NOT SHOULD_COMPILE) @@ -226,7 +226,7 @@ if(NOT "${TRY_OUT}" MATCHES "hello world") endif() try_run(ARG_TEST_RUN ARG_TEST_COMPILE - ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_BINARY_DIR} ${TryCompile_SOURCE_DIR}/expect_arg.c OUTPUT_VARIABLE TRY_OUT ARGS arg1 arg2) @@ -239,7 +239,7 @@ endif() # try to run a file that should compile and run, but return an error try_run(SHOULD_EXIT_WITH_ERROR SHOULD_COMPILE - ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_BINARY_DIR} ${TryCompile_SOURCE_DIR}/exit_with_error.c COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT RUN_OUTPUT_VARIABLE RUN_OUTPUT) @@ -385,7 +385,7 @@ if (APPLE) # try to compile a file that should compile try_compile(SHOULD_PASS - ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_BINARY_DIR} ${TryCompile_SOURCE_DIR}/pass.m OUTPUT_VARIABLE TRY_OUT) if(NOT SHOULD_PASS) @@ -394,7 +394,7 @@ if (APPLE) # try to compile a file that should not compile try_compile(SHOULD_FAIL - ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_BINARY_DIR} ${TryCompile_SOURCE_DIR}/fail.m OUTPUT_VARIABLE TRY_OUT) if(SHOULD_FAIL) diff --git a/Tests/TryCompile/Inner/CMakeLists.txt b/Tests/TryCompile/Inner/CMakeLists.txt index d8c22d0..9f89af2 100644 --- a/Tests/TryCompile/Inner/CMakeLists.txt +++ b/Tests/TryCompile/Inner/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.12) project(TryCompileInner C) try_compile(SHOULD_PASS - ${TryCompileInner_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompileInner_BINARY_DIR} ${TryCompileInner_SOURCE_DIR}/../pass.c OUTPUT_VARIABLE TRY_OUT ) diff --git a/Tests/VSWinStorePhone/CMakeLists.txt b/Tests/VSWinStorePhone/CMakeLists.txt index edd4330..2cb80fa 100644 --- a/Tests/VSWinStorePhone/CMakeLists.txt +++ b/Tests/VSWinStorePhone/CMakeLists.txt @@ -63,7 +63,8 @@ set(VERTEXSHADER_FILES Direct3DApp1/SimpleVertexShader.hlsl ) -set(CONTENT_FILES ${PIXELSHADER_FILES} ${VERTEXSHADER_FILES}) + set(COPY_TO_OUTPUT_FILES Direct3DApp1/Simple.manifest) + set(CONTENT_FILES ${PIXELSHADER_FILES} ${VERTEXSHADER_FILES} ${COPY_TO_OUTPUT_FILES}) if (WINDOWS_PHONE8) set(CONTENT_FILES ${CONTENT_FILES} @@ -108,6 +109,7 @@ set(RESOURCE_FILES ${CONTENT_FILES} ${DEBUG_CONTENT_FILES} ${RELEASE_CONTENT_FILES} ${ASSET_FILES} ${STRING_FILES} Direct3DApp1/Direct3DApp1_TemporaryKey.pfx) +set_property(SOURCE ${COPY_TO_OUTPUT_FILES} PROPERTY VS_COPY_TO_OUT_DIR "PreserveNewest") set_property(SOURCE ${CONTENT_FILES} PROPERTY VS_DEPLOYMENT_CONTENT 1) set_property(SOURCE ${ASSET_FILES} PROPERTY VS_DEPLOYMENT_CONTENT 1) set_property(SOURCE ${ASSET_FILES} PROPERTY VS_DEPLOYMENT_LOCATION "Assets") diff --git a/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp b/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp index 595f553..d287857 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp +++ b/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp @@ -17,6 +17,13 @@ CubeRenderer::CubeRenderer() // Create a new WinRT object to validate that we can link properly Batman ^ hero = ref new Batman(); hero->savePeople(); + + // Test that .manifest files can be bundled with app + DX::ReadDataAsync("Direct3DApp1\\Simple.manifest") + .then([this](Platform::Array<byte> ^ fileData) { + std::string manifestContent(fileData->begin(), fileData->end()); + assert(manifestContent.find("hello") == 0); + }); } void CubeRenderer::CreateDeviceResources() diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Simple.manifest b/Tests/VSWinStorePhone/Direct3DApp1/Simple.manifest new file mode 100644 index 0000000..ce01362 --- /dev/null +++ b/Tests/VSWinStorePhone/Direct3DApp1/Simple.manifest @@ -0,0 +1 @@ +hello |