diff options
Diffstat (limited to 'Tests/RunCMake')
713 files changed, 6245 insertions, 134 deletions
diff --git a/Tests/RunCMake/AndroidMK/AndroidMK-check.cmake b/Tests/RunCMake/AndroidMK/AndroidMK-check.cmake index 691e326..03221c5 100644 --- a/Tests/RunCMake/AndroidMK/AndroidMK-check.cmake +++ b/Tests/RunCMake/AndroidMK/AndroidMK-check.cmake @@ -26,5 +26,5 @@ compare_file_to_expected( "${RunCMake_BINARY_DIR}/AndroidMK-build/Android.mk" "${RunCMake_TEST_SOURCE_DIR}/expectedBuildAndroidMK.txt") compare_file_to_expected( -"${RunCMake_BINARY_DIR}/AndroidMK-build/CMakeFiles/Export/share/ndk-modules/Android.mk" +"${RunCMake_BINARY_DIR}/AndroidMK-build/CMakeFiles/Export/c8a72b7cccded047a31c221a6b84dd48/Android.mk" "${RunCMake_TEST_SOURCE_DIR}/expectedInstallAndroidMK.txt") diff --git a/Tests/RunCMake/AutoExportDll/AutoExport.cmake b/Tests/RunCMake/AutoExportDll/AutoExport.cmake index 85eff7e..dbcf4b8 100644 --- a/Tests/RunCMake/AutoExportDll/AutoExport.cmake +++ b/Tests/RunCMake/AutoExportDll/AutoExport.cmake @@ -6,7 +6,8 @@ add_library(objlib OBJECT objlib.c) set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE 1) add_library(autoexport SHARED hello.cxx world.cxx foo.c $<TARGET_OBJECTS:objlib>) add_library(autoexport3 SHARED cppCLI.cxx) -if(MSVC AND NOT MSVC_VERSION VERSION_LESS 1600) +if(MSVC AND NOT MSVC_VERSION VERSION_LESS 1600 + AND NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64") set_property(TARGET autoexport3 PROPERTY COMMON_LANGUAGE_RUNTIME "") endif() @@ -15,7 +16,8 @@ if(MSVC) set_target_properties(say PROPERTIES ENABLE_EXPORTS ON) add_library(autoexport_for_exec SHARED hello2.c) target_link_libraries(autoexport_for_exec say) - if(NOT MSVC_VERSION VERSION_LESS 1600) + if(NOT MSVC_VERSION VERSION_LESS 1600 AND + NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64") enable_language(ASM_MASM) target_sources(autoexport PRIVATE nop.asm) set_property(SOURCE nop.asm PROPERTY COMPILE_FLAGS /safeseh) 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/CMP0135/CMP0135-Common.cmake b/Tests/RunCMake/CMP0135/CMP0135-Common.cmake new file mode 100644 index 0000000..4b7cce5 --- /dev/null +++ b/Tests/RunCMake/CMP0135/CMP0135-Common.cmake @@ -0,0 +1,18 @@ +include(ExternalProject) + +set(stamp_dir "${CMAKE_CURRENT_BINARY_DIR}/stamps") + +ExternalProject_Add(fake_ext_proj + # We don't actually do a build, so we never try to download from this URL + URL https://example.com/something.zip + STAMP_DIR ${stamp_dir} +) + +# Report whether the --touch option was added to the extraction script +set(extraction_script "${stamp_dir}/extract-fake_ext_proj.cmake") +file(STRINGS "${extraction_script}" results REGEX "--touch") +if("${results}" STREQUAL "") + message(STATUS "Using timestamps from archive") +else() + message(STATUS "Using extraction time for the timestamps") +endif() diff --git a/Tests/RunCMake/CMP0135/CMP0135-NEW-stdout.txt b/Tests/RunCMake/CMP0135/CMP0135-NEW-stdout.txt new file mode 100644 index 0000000..bf53c0b --- /dev/null +++ b/Tests/RunCMake/CMP0135/CMP0135-NEW-stdout.txt @@ -0,0 +1 @@ +Using extraction time for the timestamps diff --git a/Tests/RunCMake/CMP0135/CMP0135-NEW.cmake b/Tests/RunCMake/CMP0135/CMP0135-NEW.cmake new file mode 100644 index 0000000..1fd6354 --- /dev/null +++ b/Tests/RunCMake/CMP0135/CMP0135-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0135 NEW) +include(CMP0135-Common.cmake) diff --git a/Tests/RunCMake/CMP0135/CMP0135-OLD-stdout.txt b/Tests/RunCMake/CMP0135/CMP0135-OLD-stdout.txt new file mode 100644 index 0000000..ee57beb --- /dev/null +++ b/Tests/RunCMake/CMP0135/CMP0135-OLD-stdout.txt @@ -0,0 +1 @@ +Using timestamps from archive diff --git a/Tests/RunCMake/CMP0135/CMP0135-OLD.cmake b/Tests/RunCMake/CMP0135/CMP0135-OLD.cmake new file mode 100644 index 0000000..80d58a7 --- /dev/null +++ b/Tests/RunCMake/CMP0135/CMP0135-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0135 OLD) +include(CMP0135-Common.cmake) diff --git a/Tests/RunCMake/CMP0135/CMP0135-WARN-stderr.txt b/Tests/RunCMake/CMP0135/CMP0135-WARN-stderr.txt new file mode 100644 index 0000000..8ba0027 --- /dev/null +++ b/Tests/RunCMake/CMP0135/CMP0135-WARN-stderr.txt @@ -0,0 +1,10 @@ +CMake Warning \(dev\) at .*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is + not set\. The policy's OLD behavior will be used\. When using a URL + download, the timestamps of extracted files should preferably be that of + the time of extraction, otherwise code that depends on the extracted + contents might not be rebuilt if the URL changes\. The OLD behavior + preserves the timestamps from the archive instead, but this is usually not + what you want\. Update your project to the NEW behavior or specify the + DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this + robustness issue\. diff --git a/Tests/RunCMake/CMP0135/CMP0135-WARN-stdout.txt b/Tests/RunCMake/CMP0135/CMP0135-WARN-stdout.txt new file mode 100644 index 0000000..ee57beb --- /dev/null +++ b/Tests/RunCMake/CMP0135/CMP0135-WARN-stdout.txt @@ -0,0 +1 @@ +Using timestamps from archive diff --git a/Tests/RunCMake/CMP0135/CMP0135-WARN.cmake b/Tests/RunCMake/CMP0135/CMP0135-WARN.cmake new file mode 100644 index 0000000..ab71c40 --- /dev/null +++ b/Tests/RunCMake/CMP0135/CMP0135-WARN.cmake @@ -0,0 +1,2 @@ + +include(CMP0135-Common.cmake) diff --git a/Tests/RunCMake/CMP0135/CMakeLists.txt b/Tests/RunCMake/CMP0135/CMakeLists.txt new file mode 100644 index 0000000..5ff8d3e --- /dev/null +++ b/Tests/RunCMake/CMP0135/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/CMP0135/RunCMakeTest.cmake b/Tests/RunCMake/CMP0135/RunCMakeTest.cmake new file mode 100644 index 0000000..da92391 --- /dev/null +++ b/Tests/RunCMake/CMP0135/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0135-WARN) +run_cmake(CMP0135-OLD) +run_cmake(CMP0135-NEW) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index e97b7dc..4fe6ac1 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -76,7 +76,7 @@ function(add_RunCMake_test_group test types) endfunction() # Some tests use python for extra checks. -find_package(PythonInterp QUIET) +find_package(Python QUIET) if(XCODE_VERSION AND "${XCODE_VERSION}" VERSION_LESS 6.1) set(Swift_ARGS -DXCODE_BELOW_6_1=1) @@ -142,6 +142,15 @@ 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) +add_RunCMake_test(CMP0135) + # 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 +287,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() @@ -291,7 +303,7 @@ add_RunCMake_test(ExcludeFromAll) add_RunCMake_test(ExternalData) add_RunCMake_test(FeatureSummary) add_RunCMake_test(FPHSA) -add_RunCMake_test(FileAPI -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} +add_RunCMake_test(FileAPI -DPython_EXECUTABLE=${Python_EXECUTABLE} -DCMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID}) add_RunCMake_test(FindBoost) add_RunCMake_test(FindLua) @@ -313,6 +325,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) @@ -339,6 +353,9 @@ if(MSVC) add_RunCMake_test(MSVCRuntimeTypeInfo) add_RunCMake_test(MSVCWarningFlags) endif() +if(XCODE_VERSION) + set(ObjectLibrary_ARGS -DXCODE_VERSION=${XCODE_VERSION}) +endif() add_RunCMake_test(ObjectLibrary) add_RunCMake_test(ParseImplicitIncludeInfo) add_RunCMake_test(ParseImplicitLinkInfo) @@ -352,6 +369,7 @@ add_RunCMake_test(TargetProperties) add_RunCMake_test(ToolchainFile) add_RunCMake_test(find_dependency) add_RunCMake_test(CompileDefinitions) +add_RunCMake_test(CompileWarningAsError) add_RunCMake_test(CompileFeatures -DCMake_NO_C_STANDARD=${CMake_NO_C_STANDARD} -DCMake_NO_CXX_STANDARD=${CMake_NO_CXX_STANDARD}) add_RunCMake_test(Policy) add_RunCMake_test(PolicyScope) @@ -384,7 +402,7 @@ add_RunCMake_test(build_command) add_executable(exit_code exit_code.c) set(execute_process_ARGS -DEXIT_CODE_EXE=$<TARGET_FILE:exit_code> - -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} + -DPython_EXECUTABLE=${Python_EXECUTABLE} ) if(NOT CMake_TEST_EXTERNAL_CMAKE) list(APPEND execute_process_ARGS -DTEST_ENCODING_EXE=$<TARGET_FILE:testEncoding>) @@ -657,6 +675,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 +750,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,9 +781,13 @@ 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}) +add_RunCMake_test(FetchContent_find_package) +set(CTestCommandLine_ARGS -DPython_EXECUTABLE=${Python_EXECUTABLE}) if(NOT CMake_TEST_EXTERNAL_CMAKE) list(APPEND CTestCommandLine_ARGS -DTEST_AFFINITY=$<TARGET_FILE:testAffinity>) endif() @@ -770,6 +817,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) @@ -912,7 +960,9 @@ endif() if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([^9]|9[0-9])") add_RunCMake_test(CSharpCustomCommand) - add_RunCMake_test(CSharpReferenceImport) + if(NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64") + add_RunCMake_test(CSharpReferenceImport) + endif() endif() add_RunCMake_test("CTestCommandExpandLists") @@ -923,19 +973,21 @@ add_RunCMake_test(PrecompileHeaders -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} add_RunCMake_test("UnityBuild") add_RunCMake_test(CMakePresets - -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} + -DPython_EXECUTABLE=${Python_EXECUTABLE} -DCMake_TEST_JSON_SCHEMA=${CMake_TEST_JSON_SCHEMA} ) add_RunCMake_test(CMakePresetsBuild - -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} + -DPython_EXECUTABLE=${Python_EXECUTABLE} -DCMake_TEST_JSON_SCHEMA=${CMake_TEST_JSON_SCHEMA} -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} ) add_RunCMake_test(CMakePresetsTest - -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} + -DPython_EXECUTABLE=${Python_EXECUTABLE} -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 +995,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/CMakePresets/PathListSep.cmake b/Tests/RunCMake/CMakePresets/PathListSep.cmake new file mode 100644 index 0000000..52c225b --- /dev/null +++ b/Tests/RunCMake/CMakePresets/PathListSep.cmake @@ -0,0 +1,7 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +if(CMAKE_HOST_WIN32) + test_variable(TEST_PATH_LIST_SEP "" "${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_SOURCE_DIR}") +else() + test_variable(TEST_PATH_LIST_SEP "" "${CMAKE_CURRENT_SOURCE_DIR}:${CMAKE_CURRENT_SOURCE_DIR}") +endif() diff --git a/Tests/RunCMake/CMakePresets/PathListSep.json.in b/Tests/RunCMake/CMakePresets/PathListSep.json.in new file mode 100644 index 0000000..4c25029 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/PathListSep.json.in @@ -0,0 +1,13 @@ +{ + "version": 5, + "configurePresets": [ + { + "name": "PathListSep", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "TEST_PATH_LIST_SEP": "${sourceDir}${pathListSep}${sourceDir}" + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/PathListSepFuture-result.txt b/Tests/RunCMake/CMakePresets/PathListSepFuture-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/PathListSepFuture-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/PathListSepFuture-stderr.txt b/Tests/RunCMake/CMakePresets/PathListSepFuture-stderr.txt new file mode 100644 index 0000000..b961aaf --- /dev/null +++ b/Tests/RunCMake/CMakePresets/PathListSepFuture-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/PathListSepFuture: Invalid macro expansion$ diff --git a/Tests/RunCMake/CMakePresets/PathListSepFuture.json.in b/Tests/RunCMake/CMakePresets/PathListSepFuture.json.in new file mode 100644 index 0000000..2fd6b7e --- /dev/null +++ b/Tests/RunCMake/CMakePresets/PathListSepFuture.json.in @@ -0,0 +1,13 @@ +{ + "version": 4, + "configurePresets": [ + { + "name": "PathListSepFuture", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "TEST_PATH_LIST_SEP": "${sourceDir}${pathListSep}${sourceDir}" + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake index 5867efd..d097086 100644 --- a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake @@ -335,6 +335,12 @@ unset(CMakePresets_EXTRA_FILES) set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/FileDirFuture.json.in") run_cmake_presets(FileDirFuture) +# Test ${pathListSep} macro +set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/PathListSep.json.in") +run_cmake_presets(PathListSep) +set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/PathListSepFuture.json.in") +run_cmake_presets(PathListSepFuture) + # Test conditions set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/Conditions.json.in") run_cmake_presets(ListConditions --list-presets) diff --git a/Tests/RunCMake/CMakePresets/check.cmake b/Tests/RunCMake/CMakePresets/check.cmake index cef43f4..03f96a9 100644 --- a/Tests/RunCMake/CMakePresets/check.cmake +++ b/Tests/RunCMake/CMakePresets/check.cmake @@ -1,4 +1,4 @@ -if(PYTHON_EXECUTABLE AND CMake_TEST_JSON_SCHEMA) +if(Python_EXECUTABLE AND CMake_TEST_JSON_SCHEMA) if(NOT CMakePresets_SCHEMA_EXPECTED_RESULT) set(CMakePresets_SCHEMA_EXPECTED_RESULT 0) endif() diff --git a/Tests/RunCMake/CMakePresets/validate_schema.cmake b/Tests/RunCMake/CMakePresets/validate_schema.cmake index 68b638f..ed60760 100644 --- a/Tests/RunCMake/CMakePresets/validate_schema.cmake +++ b/Tests/RunCMake/CMakePresets/validate_schema.cmake @@ -4,7 +4,7 @@ function(validate_schema file expected_result) endif() execute_process( - COMMAND "${PYTHON_EXECUTABLE}" "${CMakePresets_VALIDATE_SCRIPT_PATH}" "${file}" + COMMAND "${Python_EXECUTABLE}" "${CMakePresets_VALIDATE_SCRIPT_PATH}" "${file}" RESULT_VARIABLE _result OUTPUT_VARIABLE _output ERROR_VARIABLE _error 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/CPackConfig/CMP0133-NEW-check.cmake b/Tests/RunCMake/CPackConfig/CMP0133-NEW-check.cmake new file mode 100644 index 0000000..c1ef0d1 --- /dev/null +++ b/Tests/RunCMake/CPackConfig/CMP0133-NEW-check.cmake @@ -0,0 +1,3 @@ +include(${RunCMake_SOURCE_DIR}/check.cmake) + +test_variable(CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE "") diff --git a/Tests/RunCMake/CPackConfig/CMP0133-NEW.cmake b/Tests/RunCMake/CPackConfig/CMP0133-NEW.cmake new file mode 100644 index 0000000..79c1a59 --- /dev/null +++ b/Tests/RunCMake/CPackConfig/CMP0133-NEW.cmake @@ -0,0 +1,2 @@ +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_LIST_DIR}/SLA.txt") +cmake_policy(SET CMP0133 NEW) diff --git a/Tests/RunCMake/CPackConfig/CMP0133-WARN-check.cmake b/Tests/RunCMake/CPackConfig/CMP0133-WARN-check.cmake new file mode 100644 index 0000000..01de980 --- /dev/null +++ b/Tests/RunCMake/CPackConfig/CMP0133-WARN-check.cmake @@ -0,0 +1,3 @@ +include(${RunCMake_SOURCE_DIR}/check.cmake) + +test_variable(CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE "ON") diff --git a/Tests/RunCMake/CPackConfig/CMP0133-WARN-stderr.txt b/Tests/RunCMake/CPackConfig/CMP0133-WARN-stderr.txt new file mode 100644 index 0000000..2858025 --- /dev/null +++ b/Tests/RunCMake/CPackConfig/CMP0133-WARN-stderr.txt @@ -0,0 +1,12 @@ +^CMake Warning \(dev\) at [^ +]*/Modules/CPack.cmake:[0-9]+ \(message\): + Policy CMP0133 is not set: The CPack module disables SLA by default in the + CPack DragNDrop Generator. Run "cmake --help-policy CMP0133" for policy + details. Use the cmake_policy command to set the policy and suppress this + warning. + + For compatibility, CMake will enable the SLA in the CPack DragNDrop + Generator. +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/CPackConfig/CMP0133-WARN.cmake b/Tests/RunCMake/CPackConfig/CMP0133-WARN.cmake new file mode 100644 index 0000000..3f2208b --- /dev/null +++ b/Tests/RunCMake/CPackConfig/CMP0133-WARN.cmake @@ -0,0 +1,2 @@ +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_LIST_DIR}/SLA.txt") +set(CMAKE_POLICY_WARNING_CMP0133 1) diff --git a/Tests/RunCMake/CPackConfig/CMakeLists.txt b/Tests/RunCMake/CPackConfig/CMakeLists.txt index 9a9e7b4..1e071ec 100644 --- a/Tests/RunCMake/CPackConfig/CMakeLists.txt +++ b/Tests/RunCMake/CPackConfig/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.3) project(${RunCMake_TEST}) -include(${RunCMake_TEST}.cmake) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) include(CPack) diff --git a/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake b/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake index 8f2196d..32c7296 100644 --- a/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake @@ -1,5 +1,7 @@ include(RunCMake) +run_cmake(CMP0133-NEW) +run_cmake(CMP0133-WARN) run_cmake(Simple) run_cmake(Default) run_cmake(Special) diff --git a/Tests/RunCMake/CPackConfig/SLA.txt b/Tests/RunCMake/CPackConfig/SLA.txt new file mode 100644 index 0000000..94b19c3 --- /dev/null +++ b/Tests/RunCMake/CPackConfig/SLA.txt @@ -0,0 +1,4 @@ +Example License File +-------------------- + +This is an example license file for a DMG. diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake index 7da95a2..8ac1747 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) @@ -321,14 +342,14 @@ endfunction() run_TestStdin() function(show_only_json_check_python v) - if(RunCMake_TEST_FAILED OR NOT PYTHON_EXECUTABLE) + if(RunCMake_TEST_FAILED OR NOT Python_EXECUTABLE) return() endif() set(json_file "${RunCMake_TEST_BINARY_DIR}/ctest.json") file(WRITE "${json_file}" "${actual_stdout}") set(actual_stdout "" PARENT_SCOPE) execute_process( - COMMAND ${PYTHON_EXECUTABLE} "${RunCMake_SOURCE_DIR}/show-only_json-v${v}_check.py" "${json_file}" + COMMAND ${Python_EXECUTABLE} "${RunCMake_SOURCE_DIR}/show-only_json-v${v}_check.py" "${json_file}" RESULT_VARIABLE result OUTPUT_VARIABLE output ERROR_VARIABLE output 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..3e6b3a5 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) @@ -19,3 +20,8 @@ if(CMAKE_CUDA_COMPILER_ID STREQUAL "Clang" AND CMAKE_CUDA_ARCHITECTURES) endif() run_cmake(architectures-off) unset(RunCMake_TEST_OPTIONS) + +if(CMAKE_CUDA_ARCHITECTURES MATCHES "([0-9]+)") + set(arch "${CMAKE_MATCH_1}") + run_cmake_with_options(architectures-suffix -Darch=${arch}) +endif() diff --git a/Tests/RunCMake/CUDA_architectures/architectures-all-major-stdout.txt b/Tests/RunCMake/CUDA_architectures/architectures-all-major-stdout.txt index c5cde8f..4153699 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_ALL='([0-9]+-real;)+[0-9]+' +-- CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR='([0-9]+-real;)+[0-9]+' +-- CMAKE_CUDA_ARCHITECTURES_NATIVE='([0-9]+-real;)*[0-9]+-real' 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..32c61de0 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_ALL='([0-9]+-real;)+[0-9]+' +-- CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR='([0-9]+-real;)+[0-9]+' +-- CMAKE_CUDA_ARCHITECTURES_NATIVE='([0-9]+-real;)*[0-9]+-real' 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-empty-stderr.txt b/Tests/RunCMake/CUDA_architectures/architectures-empty-stderr.txt index 39640fa..6c42612 100644 --- a/Tests/RunCMake/CUDA_architectures/architectures-empty-stderr.txt +++ b/Tests/RunCMake/CUDA_architectures/architectures-empty-stderr.txt @@ -1,5 +1,5 @@ ^CMake Error at .*/Modules/CMakeDetermineCUDACompiler\.cmake:[0-9]+ \(message\): - CMAKE_CUDA_ARCHITECTURES must be valid if set\. + CMAKE_CUDA_ARCHITECTURES must be non-empty if set\. Call Stack \(most recent call first\): architectures-empty\.cmake:2 \(enable_language\) CMakeLists\.txt:3 \(include\) diff --git a/Tests/RunCMake/CUDA_architectures/architectures-invalid-stderr.txt b/Tests/RunCMake/CUDA_architectures/architectures-invalid-stderr.txt index 7608730..14c76d2 100644 --- a/Tests/RunCMake/CUDA_architectures/architectures-invalid-stderr.txt +++ b/Tests/RunCMake/CUDA_architectures/architectures-invalid-stderr.txt @@ -1,5 +1,14 @@ ^CMake Error at .*/Modules/CMakeDetermineCUDACompiler\.cmake:[0-9]+ \(message\): - CMAKE_CUDA_ARCHITECTURES must be valid if set\. + CMAKE_CUDA_ARCHITECTURES: + + invalid + + is not one of the following: + + \* a semicolon-separated list of integers, each optionally + followed by '-real' or '-virtual' + \* a special value: all, all-major, native + Call Stack \(most recent call first\): architectures-invalid\.cmake:2 \(enable_language\) CMakeLists\.txt:3 \(include\)$ 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..7f6f19e --- /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]+-real;)+[0-9]+' +-- CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR='([0-9]+-real;)+[0-9]+' +-- CMAKE_CUDA_ARCHITECTURES_NATIVE='([0-9]+-real;)*[0-9]+-real' 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/CUDA_architectures/architectures-suffix-stderr.txt b/Tests/RunCMake/CUDA_architectures/architectures-suffix-stderr.txt new file mode 100644 index 0000000..7b6eb53 --- /dev/null +++ b/Tests/RunCMake/CUDA_architectures/architectures-suffix-stderr.txt @@ -0,0 +1,4 @@ +^(CMake Warning in [^ +]*/Tests/RunCMake/CUDA_architectures/architectures-suffix-build/CMakeFiles/CMakeTmp/CMakeLists.txt: + Clang doesn't support disabling CUDA real code generation. +*)*$ diff --git a/Tests/RunCMake/CUDA_architectures/architectures-suffix-stdout.txt b/Tests/RunCMake/CUDA_architectures/architectures-suffix-stdout.txt new file mode 100644 index 0000000..90b3552 --- /dev/null +++ b/Tests/RunCMake/CUDA_architectures/architectures-suffix-stdout.txt @@ -0,0 +1,4 @@ +-- CMAKE_CUDA_ARCHITECTURES='[0-9]+-real;[0-9]+-virtual;' +-- CMAKE_CUDA_ARCHITECTURES_ALL='([0-9]+-real;)+[0-9]+' +-- CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR='([0-9]+-real;)+[0-9]+' +-- CMAKE_CUDA_ARCHITECTURES_NATIVE='([0-9]+-real;)*[0-9]+-real' diff --git a/Tests/RunCMake/CUDA_architectures/architectures-suffix.cmake b/Tests/RunCMake/CUDA_architectures/architectures-suffix.cmake new file mode 100644 index 0000000..8d7ec03 --- /dev/null +++ b/Tests/RunCMake/CUDA_architectures/architectures-suffix.cmake @@ -0,0 +1,6 @@ +set(CMAKE_CUDA_ARCHITECTURES "${arch}-real;${arch}-virtual;") +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/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/Envgen-G-implicit-platform-stdout.txt b/Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt index 4dd6be1..a182e1c 100644 --- a/Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt +++ b/Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt @@ -1 +1 @@ --- CMAKE_VS_PLATFORM_NAME='(x64|Win32)' +-- CMAKE_VS_PLATFORM_NAME='(x64|Win32|ARM64)' 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.cmake b/Tests/RunCMake/CommandLine/trace-json-v1-check.cmake index 66af039..e9a4a59 100644 --- a/Tests/RunCMake/CommandLine/trace-json-v1-check.cmake +++ b/Tests/RunCMake/CommandLine/trace-json-v1-check.cmake @@ -1,6 +1,6 @@ -if(PYTHON_EXECUTABLE) +if(Python_EXECUTABLE) execute_process( - COMMAND ${PYTHON_EXECUTABLE} "${RunCMake_SOURCE_DIR}/trace-json-v1-check.py" "${RunCMake_BINARY_DIR}/json-v1.trace" + COMMAND ${Python_EXECUTABLE} "${RunCMake_SOURCE_DIR}/trace-json-v1-check.py" "${RunCMake_BINARY_DIR}/json-v1.trace" RESULT_VARIABLE result OUTPUT_VARIABLE output ERROR_VARIABLE output 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-expand-check.cmake b/Tests/RunCMake/CommandLine/trace-json-v1-expand-check.cmake index 7916d2e..79079e1 100644 --- a/Tests/RunCMake/CommandLine/trace-json-v1-expand-check.cmake +++ b/Tests/RunCMake/CommandLine/trace-json-v1-expand-check.cmake @@ -1,6 +1,6 @@ -if(PYTHON_EXECUTABLE) +if(Python_EXECUTABLE) execute_process( - COMMAND ${PYTHON_EXECUTABLE} "${RunCMake_SOURCE_DIR}/trace-json-v1-check.py" --expand "${RunCMake_BINARY_DIR}/json-v1-expand.trace" + COMMAND ${Python_EXECUTABLE} "${RunCMake_SOURCE_DIR}/trace-json-v1-check.py" --expand "${RunCMake_BINARY_DIR}/json-v1-expand.trace" RESULT_VARIABLE result OUTPUT_VARIABLE output ERROR_VARIABLE output 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/CompileWarningAsError/CMakeLists.txt b/Tests/RunCMake/CompileWarningAsError/CMakeLists.txt new file mode 100644 index 0000000..5ff8d3e --- /dev/null +++ b/Tests/RunCMake/CompileWarningAsError/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/CompileWarningAsError/RunCMakeTest.cmake b/Tests/RunCMake/CompileWarningAsError/RunCMakeTest.cmake new file mode 100644 index 0000000..059c80f --- /dev/null +++ b/Tests/RunCMake/CompileWarningAsError/RunCMakeTest.cmake @@ -0,0 +1,12 @@ +include(RunCMake) + +function(run_compile_warn test) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build) + set(RunCMake_TEST_OUTPUT_MERGE 1) + run_cmake(${test}) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(${test}-Build ${CMAKE_COMMAND} --build . ${verbose_args}) +endfunction() + +run_compile_warn(WerrorOn) +run_compile_warn(WerrorOff) diff --git a/Tests/RunCMake/CompileWarningAsError/WarningAsErrorOptions.cmake b/Tests/RunCMake/CompileWarningAsError/WarningAsErrorOptions.cmake new file mode 100644 index 0000000..ccc6cc5 --- /dev/null +++ b/Tests/RunCMake/CompileWarningAsError/WarningAsErrorOptions.cmake @@ -0,0 +1,18 @@ +# add compile options to warning_options to ensure unused-function throws a warning +# if warning_options is NOT DEFINED, assume compiler doesn't support warning as error +macro(get_warning_options warning_options) + if (CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang|XLClang|IBMClang|LCC|NVCC|IntelLLVM)$") + set(${warning_options} "-Wall") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" + OR (CMAKE_CXX_COMPILER_ID STREQUAL "Intel" AND CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")) + set(${warning_options} "-W4") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + set(${warning_options} "-w3") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "XL") + set(${warning_options} "-qinfo=all") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro") + set(${warning_options} "+w;+w2") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Fujitsu") + set(${warning_options} "SHELL:-w 8") + endif() +endmacro() diff --git a/Tests/RunCMake/CompileWarningAsError/WerrorOff.cmake b/Tests/RunCMake/CompileWarningAsError/WerrorOff.cmake new file mode 100644 index 0000000..b05d65e --- /dev/null +++ b/Tests/RunCMake/CompileWarningAsError/WerrorOff.cmake @@ -0,0 +1,8 @@ +enable_language(CXX) + +include(WarningAsErrorOptions.cmake) +get_warning_options(warning_options) + +add_executable(WerrorOff warn.cxx) +target_compile_options(WerrorOff PUBLIC "${warning_options}") +set_target_properties(WerrorOff PROPERTIES COMPILE_WARNING_AS_ERROR OFF) diff --git a/Tests/RunCMake/CompileWarningAsError/WerrorOn-Build-result.txt b/Tests/RunCMake/CompileWarningAsError/WerrorOn-Build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/CompileWarningAsError/WerrorOn-Build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/CompileWarningAsError/WerrorOn.cmake b/Tests/RunCMake/CompileWarningAsError/WerrorOn.cmake new file mode 100644 index 0000000..4310333 --- /dev/null +++ b/Tests/RunCMake/CompileWarningAsError/WerrorOn.cmake @@ -0,0 +1,13 @@ +enable_language(CXX) + +include(WarningAsErrorOptions.cmake) +get_warning_options(warning_options) + +if (DEFINED warning_options) + add_executable(WerrorOn warn.cxx) + target_compile_options(WerrorOn PUBLIC "${warning_options}") + set_target_properties(WerrorOn PROPERTIES COMPILE_WARNING_AS_ERROR ON) +else() + # if no werror option is set for the environment, use err.cxx so that build fails as expected + add_executable(WerrorOn err.cxx) +endif() diff --git a/Tests/RunCMake/CompileWarningAsError/err.cxx b/Tests/RunCMake/CompileWarningAsError/err.cxx new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CompileWarningAsError/err.cxx diff --git a/Tests/RunCMake/CompileWarningAsError/warn.cxx b/Tests/RunCMake/CompileWarningAsError/warn.cxx new file mode 100644 index 0000000..64a245a --- /dev/null +++ b/Tests/RunCMake/CompileWarningAsError/warn.cxx @@ -0,0 +1,17 @@ +static void unused_function(); + +#ifdef __SUNPRO_CC +struct A +{ + virtual ~A() throw(); +}; +struct B : public A +{ + virtual ~B() throw(int); +}; +#endif + +int main(int unused_argument, char* []) +{ + return 1; +} 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/Add_StepDependencies.cmake b/Tests/RunCMake/ExternalProject/Add_StepDependencies.cmake index bfed4fa..364bf9e 100644 --- a/Tests/RunCMake/ExternalProject/Add_StepDependencies.cmake +++ b/Tests/RunCMake/ExternalProject/Add_StepDependencies.cmake @@ -4,6 +4,7 @@ if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12) else() cmake_policy(SET CMP0114 OLD) # Test deprecated behavior. endif() +cmake_policy(SET CMP0135 NEW) include(ExternalProject) diff --git a/Tests/RunCMake/ExternalProject/Add_StepDependencies_no_target.cmake b/Tests/RunCMake/ExternalProject/Add_StepDependencies_no_target.cmake index 039dec6..da823cd 100644 --- a/Tests/RunCMake/ExternalProject/Add_StepDependencies_no_target.cmake +++ b/Tests/RunCMake/ExternalProject/Add_StepDependencies_no_target.cmake @@ -4,6 +4,7 @@ if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12) else() cmake_policy(SET CMP0114 OLD) # Test deprecated behavior. endif() +cmake_policy(SET CMP0135 NEW) include(ExternalProject) diff --git a/Tests/RunCMake/ExternalProject/CMakeLists.txt b/Tests/RunCMake/ExternalProject/CMakeLists.txt index 933a57a..b94f825 100644 --- a/Tests/RunCMake/ExternalProject/CMakeLists.txt +++ b/Tests/RunCMake/ExternalProject/CMakeLists.txt @@ -3,4 +3,5 @@ project(${RunCMake_TEST} NONE) if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12 AND NOT RunCMake_TEST STREQUAL "Xcode-CMP0114") cmake_policy(SET CMP0114 NEW) endif() +cmake_policy(SET CMP0135 NEW) include(${RunCMake_TEST}.cmake) 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/NO_DEPENDS-CMP0114-NEW-Direct.cmake b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-Direct.cmake index 7ec1a00..e257425 100644 --- a/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-Direct.cmake +++ b/Tests/RunCMake/ExternalProject/NO_DEPENDS-CMP0114-NEW-Direct.cmake @@ -1,4 +1,5 @@ cmake_policy(SET CMP0114 NEW) +cmake_policy(SET CMP0135 NEW) include(ExternalProject) ExternalProject_Add(BAR SOURCE_DIR . TEST_COMMAND echo test) ExternalProject_Add_StepTargets(BAR NO_DEPENDS test) 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/FetchContent_find_package/AddedProject/CMakeLists.txt b/Tests/RunCMake/FetchContent_find_package/AddedProject/CMakeLists.txt new file mode 100644 index 0000000..8be00ed --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/AddedProject/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.13...3.23) +project(AddedProject LANGUAGES NONE) + +message(STATUS "Confirmation project has been added") diff --git a/Tests/RunCMake/FetchContent_find_package/BadArgs_find_package-result.txt b/Tests/RunCMake/FetchContent_find_package/BadArgs_find_package-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/BadArgs_find_package-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FetchContent_find_package/BadArgs_find_package-stderr.txt b/Tests/RunCMake/FetchContent_find_package/BadArgs_find_package-stderr.txt new file mode 100644 index 0000000..b6996b5 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/BadArgs_find_package-stderr.txt @@ -0,0 +1,3 @@ +CMake Error at .*/FetchContent.cmake:[0-9]+ \(message\): + Cannot specify both OVERRIDE_FIND_PACKAGE and FIND_PACKAGE_ARGS when + declaring details for AddedProject diff --git a/Tests/RunCMake/FetchContent_find_package/BadArgs_find_package.cmake b/Tests/RunCMake/FetchContent_find_package/BadArgs_find_package.cmake new file mode 100644 index 0000000..c1272b4 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/BadArgs_find_package.cmake @@ -0,0 +1,9 @@ +include(FetchContent) + +FetchContent_Declare( + AddedProject + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/AddedProject + # The following two args are mutually exclusive + OVERRIDE_FIND_PACKAGE + FIND_PACKAGE_ARGS +) diff --git a/Tests/RunCMake/FetchContent_find_package/CMAKE_FIND_PACKAGE_REDIRECTS_DIR-AlwaysEmptied-Setup.cmake b/Tests/RunCMake/FetchContent_find_package/CMAKE_FIND_PACKAGE_REDIRECTS_DIR-AlwaysEmptied-Setup.cmake new file mode 100644 index 0000000..ea36bf0 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/CMAKE_FIND_PACKAGE_REDIRECTS_DIR-AlwaysEmptied-Setup.cmake @@ -0,0 +1,3 @@ +file(WRITE "${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/dummy_file.txt" + "This file should be deleted the next time CMake runs" +) diff --git a/Tests/RunCMake/FetchContent_find_package/CMAKE_FIND_PACKAGE_REDIRECTS_DIR-AlwaysEmptied.cmake b/Tests/RunCMake/FetchContent_find_package/CMAKE_FIND_PACKAGE_REDIRECTS_DIR-AlwaysEmptied.cmake new file mode 100644 index 0000000..07c45f2 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/CMAKE_FIND_PACKAGE_REDIRECTS_DIR-AlwaysEmptied.cmake @@ -0,0 +1,9 @@ +file(GLOB contents LIST_DIRECTORIES true "${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/*") + +if(NOT contents STREQUAL "") + list(JOIN contents "\n" fileList) + message(FATAL_ERROR + "CMAKE_FIND_PACKAGE_REDIRECTS_DIR is not empty:\n" + "${fileList}" + ) +endif() diff --git a/Tests/RunCMake/FetchContent_find_package/CMAKE_FIND_PACKAGE_REDIRECTS_DIR-Exists.cmake b/Tests/RunCMake/FetchContent_find_package/CMAKE_FIND_PACKAGE_REDIRECTS_DIR-Exists.cmake new file mode 100644 index 0000000..dd01333 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/CMAKE_FIND_PACKAGE_REDIRECTS_DIR-Exists.cmake @@ -0,0 +1,18 @@ +if(NOT DEFINED CMAKE_FIND_PACKAGE_REDIRECTS_DIR) + message(FATAL_ERROR "CMAKE_FIND_PACKAGE_REDIRECTS_DIR is not defined") +endif() + +if(NOT CMAKE_FIND_PACKAGE_REDIRECTS_DIR STREQUAL "${CMAKE_BINARY_DIR}/CMakeFiles/pkgRedirects") + message(FATAL_ERROR + "CMAKE_FIND_PACKAGE_REDIRECTS_DIR has wrong value\n" + " Expected: ${CMAKE_BINARY_DIR}/CMakeFiles/pkgRedirects\n" + " Actual: ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}" + ) +endif() + +if(NOT EXISTS "${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}") + message(FATAL_ERROR + "Directory CMAKE_FIND_PACKAGE_REDIRECTS_DIR points to does not exist:\n" + "${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}" + ) +endif() diff --git a/Tests/RunCMake/FetchContent_find_package/CMakeLists.txt b/Tests/RunCMake/FetchContent_find_package/CMakeLists.txt new file mode 100644 index 0000000..bd718c7 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.23) +project(${RunCMake_TEST} NONE) + +# Tests assume no previous downloads in the output directory +file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/_deps) + +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/FetchContent_find_package/FatalIfAdded/CMakeLists.txt b/Tests/RunCMake/FetchContent_find_package/FatalIfAdded/CMakeLists.txt new file mode 100644 index 0000000..6a3b931 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/FatalIfAdded/CMakeLists.txt @@ -0,0 +1 @@ +message(FATAL_ERROR "Unexpectedly added directory via FetchContent_MakeAvailable()") diff --git a/Tests/RunCMake/FetchContent_find_package/MissingDetails-result.txt b/Tests/RunCMake/FetchContent_find_package/MissingDetails-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/MissingDetails-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FetchContent_find_package/MissingDetails-stderr.txt b/Tests/RunCMake/FetchContent_find_package/MissingDetails-stderr.txt new file mode 100644 index 0000000..c4f1daf --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/MissingDetails-stderr.txt @@ -0,0 +1 @@ +No content details recorded for t1 diff --git a/Tests/RunCMake/FetchContent_find_package/MissingDetails.cmake b/Tests/RunCMake/FetchContent_find_package/MissingDetails.cmake new file mode 100644 index 0000000..ba8d121 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/MissingDetails.cmake @@ -0,0 +1,3 @@ +include(FetchContent) + +FetchContent_Populate(t1) diff --git a/Tests/RunCMake/FetchContent_find_package/PackageConfigs/AddedProjectConfig.cmake b/Tests/RunCMake/FetchContent_find_package/PackageConfigs/AddedProjectConfig.cmake new file mode 100644 index 0000000..a38159f --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/PackageConfigs/AddedProjectConfig.cmake @@ -0,0 +1,2 @@ +set(AddedProject_FOUND TRUE) +message(STATUS "Loaded AddedProject from package config") diff --git a/Tests/RunCMake/FetchContent_find_package/PackageConfigs/FirstProjectConfig.cmake b/Tests/RunCMake/FetchContent_find_package/PackageConfigs/FirstProjectConfig.cmake new file mode 100644 index 0000000..3a89969 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/PackageConfigs/FirstProjectConfig.cmake @@ -0,0 +1,2 @@ +set(FirstProject_FOUND TRUE) +message(STATUS "Loaded FirstProject from package config") diff --git a/Tests/RunCMake/FetchContent_find_package/PackageConfigs/SecondProjectConfig.cmake b/Tests/RunCMake/FetchContent_find_package/PackageConfigs/SecondProjectConfig.cmake new file mode 100644 index 0000000..a181ab8 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/PackageConfigs/SecondProjectConfig.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "Unexpectedly found SecondProject via find_package()") diff --git a/Tests/RunCMake/FetchContent_find_package/PackageFindModules/FindFirstProject.cmake b/Tests/RunCMake/FetchContent_find_package/PackageFindModules/FindFirstProject.cmake new file mode 100644 index 0000000..bdd3369 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/PackageFindModules/FindFirstProject.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "First project used Find module") diff --git a/Tests/RunCMake/FetchContent_find_package/PackageFindModules/FindSecondProject.cmake b/Tests/RunCMake/FetchContent_find_package/PackageFindModules/FindSecondProject.cmake new file mode 100644 index 0000000..09a4acf --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/PackageFindModules/FindSecondProject.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "Second project used Find module") diff --git a/Tests/RunCMake/FetchContent_find_package/PreferFetchContent-stdout.txt b/Tests/RunCMake/FetchContent_find_package/PreferFetchContent-stdout.txt new file mode 100644 index 0000000..5413a4b --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/PreferFetchContent-stdout.txt @@ -0,0 +1,3 @@ +Confirmation project has been added +(-- )?Lowercase extra file was read +(-- )?Uppercase extra file was read diff --git a/Tests/RunCMake/FetchContent_find_package/PreferFetchContent.cmake b/Tests/RunCMake/FetchContent_find_package/PreferFetchContent.cmake new file mode 100644 index 0000000..c1030fb --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/PreferFetchContent.cmake @@ -0,0 +1,20 @@ +include(FetchContent) + +FetchContent_Declare( + AddedProject + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/AddedProject + OVERRIDE_FIND_PACKAGE +) + +# The default generated config package files are expected to include these when present +file(WRITE ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/AddedProjectExtra.cmake [[ +message(STATUS "Uppercase extra file was read") +]] +) +file(WRITE ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/addedproject-extra.cmake [[ +message(STATUS "Lowercase extra file was read") +]] +) + +# This is expected to be re-routed to a FetchContent_MakeAvailable() call +find_package(AddedProject REQUIRED) diff --git a/Tests/RunCMake/FetchContent_find_package/Prefer_find_package-stdout.txt b/Tests/RunCMake/FetchContent_find_package/Prefer_find_package-stdout.txt new file mode 100644 index 0000000..dfb4238 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/Prefer_find_package-stdout.txt @@ -0,0 +1,3 @@ +Loaded AddedProject from package config +.*Loaded AddedProject from package config +.*Loaded AddedProject from package config diff --git a/Tests/RunCMake/FetchContent_find_package/Prefer_find_package.cmake b/Tests/RunCMake/FetchContent_find_package/Prefer_find_package.cmake new file mode 100644 index 0000000..f5454ab --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/Prefer_find_package.cmake @@ -0,0 +1,15 @@ +include(FetchContent) + +set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR}/PackageConfigs) + +FetchContent_Declare( + AddedProject + # Ensure failure if we don't re-route to find_package() + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/FatalIfAdded + FIND_PACKAGE_ARGS REQUIRED +) + +# Cycle through a few calls to exercise global property changes +FetchContent_MakeAvailable(AddedProject) +find_package(AddedProject REQUIRED) +FetchContent_MakeAvailable(AddedProject) # Will re-route to find_package() again diff --git a/Tests/RunCMake/FetchContent_find_package/PreserveEmptyArgs-stdout.txt b/Tests/RunCMake/FetchContent_find_package/PreserveEmptyArgs-stdout.txt new file mode 100644 index 0000000..a72d914 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/PreserveEmptyArgs-stdout.txt @@ -0,0 +1,4 @@ +.*-- Number of arguments: 6 +.*-- Argument 3: 'before' +.*-- Argument 4: '' +.*-- Argument 5: 'after' diff --git a/Tests/RunCMake/FetchContent_find_package/PreserveEmptyArgs.cmake b/Tests/RunCMake/FetchContent_find_package/PreserveEmptyArgs.cmake new file mode 100644 index 0000000..4f35448 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/PreserveEmptyArgs.cmake @@ -0,0 +1,13 @@ +include(FetchContent) + +# Need to see the download command output +set(FETCHCONTENT_QUIET OFF) + +FetchContent_Declare( + t1 + DOWNLOAD_COMMAND ${CMAKE_COMMAND} -P + ${CMAKE_CURRENT_LIST_DIR}/countArgs.cmake + before "" after +) + +FetchContent_Populate(t1) diff --git a/Tests/RunCMake/FetchContent_find_package/ProjectProvidesPackageConfigFiles-stdout.txt b/Tests/RunCMake/FetchContent_find_package/ProjectProvidesPackageConfigFiles-stdout.txt new file mode 100644 index 0000000..76c6916 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/ProjectProvidesPackageConfigFiles-stdout.txt @@ -0,0 +1,4 @@ +(-- )?ConfigForm1 override successful +(-- )?ConfigForm2 override successful +(-- )?ConfigForm1_VERSION = 1.8 +(-- )?ConfigForm2_VERSION = 1.9.7 diff --git a/Tests/RunCMake/FetchContent_find_package/ProjectProvidesPackageConfigFiles.cmake b/Tests/RunCMake/FetchContent_find_package/ProjectProvidesPackageConfigFiles.cmake new file mode 100644 index 0000000..32e3f73 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/ProjectProvidesPackageConfigFiles.cmake @@ -0,0 +1,40 @@ +include(FetchContent) + +FetchContent_Declare( + ConfigForm1 + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/FatalIfAdded + FIND_PACKAGE_ARGS 1.8 EXACT REQUIRED +) +file(WRITE ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/ConfigForm1Config.cmake [[ +set(ConfigForm1_FOUND TRUE) +message(STATUS "ConfigForm1 override successful") +]] +) +file(WRITE ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/ConfigForm1ConfigVersion.cmake [[ +set(PACKAGE_VERSION 1.8) +set(PACKAGE_VERSION_EXACT TRUE) +set(PACKAGE_VERSION_COMPATIBLE TRUE) +]] +) + +FetchContent_Declare( + ConfigForm2 + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/FatalIfAdded + FIND_PACKAGE_ARGS 1.8 REQUIRED +) +file(WRITE ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/configform2-config.cmake [[ +set(ConfigForm2_FOUND TRUE) +message(STATUS "ConfigForm2 override successful") +]] +) +file(WRITE ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/configform2-config-version.cmake [[ +set(PACKAGE_VERSION 1.9.7) +set(PACKAGE_VERSION_EXACT FALSE) +set(PACKAGE_VERSION_COMPATIBLE TRUE) +]] +) + +FetchContent_MakeAvailable(ConfigForm1 ConfigForm2) + +message(STATUS "ConfigForm1_VERSION = ${ConfigForm1_VERSION}") +message(STATUS "ConfigForm2_VERSION = ${ConfigForm2_VERSION}") diff --git a/Tests/RunCMake/FetchContent_find_package/Redirect_find_package_MODULE-stdout.txt b/Tests/RunCMake/FetchContent_find_package/Redirect_find_package_MODULE-stdout.txt new file mode 100644 index 0000000..fbe6e38 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/Redirect_find_package_MODULE-stdout.txt @@ -0,0 +1,9 @@ +(-- )?find_package\(FirstProject\): +(-- )?Confirmation project has been added +(-- )?FirstProject_FOUND = 1 +(-- )?FetchContent_MakeAvailable\(FirstProject\): +(-- )?FetchContent_MakeAvailable\(SecondProject\): +(-- )?Confirmation project has been added +(-- )?find_package\(SecondProject\): +(-- )?SecondProject_FOUND = 1 +(-- )?End of test diff --git a/Tests/RunCMake/FetchContent_find_package/Redirect_find_package_MODULE.cmake b/Tests/RunCMake/FetchContent_find_package/Redirect_find_package_MODULE.cmake new file mode 100644 index 0000000..95bc2dc --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/Redirect_find_package_MODULE.cmake @@ -0,0 +1,39 @@ +include(FetchContent) + +set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR}/PackageConfigs) + +FetchContent_Declare( + FirstProject + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/AddedProject + OVERRIDE_FIND_PACKAGE +) +FetchContent_Declare( + SecondProject + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/AddedProject + # Allow a call to find_package() that we know will fail. + # This enables redirection of calls to find_package(SecondProject) + # after FetchContent_MakeAvailable() populates. + FIND_PACKAGE_ARGS NAMES I_do_not_exist +) + +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/PackageFindModules) + +# Re-directs to FetchContent_MakeAvailable() +message(STATUS "find_package(FirstProject):") +find_package(FirstProject REQUIRED MODULE) +message(STATUS "FirstProject_FOUND = ${FirstProject_FOUND}") + +# Does nothing, already populated +message(STATUS "FetchContent_MakeAvailable(FirstProject):") +FetchContent_MakeAvailable(FirstProject) + +# Populates as normal +message(STATUS "FetchContent_MakeAvailable(SecondProject):") +FetchContent_MakeAvailable(SecondProject) + +# Redirects to config package file created by previous command +message(STATUS "find_package(SecondProject):") +find_package(SecondProject REQUIRED MODULE) +message(STATUS "SecondProject_FOUND = ${FirstProject_FOUND}") + +message(STATUS "End of test") diff --git a/Tests/RunCMake/FetchContent_find_package/RunCMakeTest.cmake b/Tests/RunCMake/FetchContent_find_package/RunCMakeTest.cmake new file mode 100644 index 0000000..c139f57 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/RunCMakeTest.cmake @@ -0,0 +1,22 @@ +include(RunCMake) + +unset(RunCMake_TEST_NO_CLEAN) + +function(run_FetchContent_pkgRedirects) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMAKE_FIND_PACKAGE_REDIRECTS_DIR-AlwaysEmptied-build) + run_cmake(CMAKE_FIND_PACKAGE_REDIRECTS_DIR-AlwaysEmptied-Setup) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake(CMAKE_FIND_PACKAGE_REDIRECTS_DIR-AlwaysEmptied) +endfunction() + +run_cmake(CMAKE_FIND_PACKAGE_REDIRECTS_DIR-Exists) +run_FetchContent_pkgRedirects() +run_cmake(BadArgs_find_package) +run_cmake(PreferFetchContent) +run_cmake(Prefer_find_package) +run_cmake(ProjectProvidesPackageConfigFiles) +run_cmake(Try_find_package-ALWAYS) +run_cmake(Try_find_package-NEVER) +run_cmake(Try_find_package-OPT_IN) +run_cmake(Try_find_package-BOGUS) +run_cmake(Redirect_find_package_MODULE) diff --git a/Tests/RunCMake/FetchContent_find_package/Try_find_package-ALWAYS-stdout.txt b/Tests/RunCMake/FetchContent_find_package/Try_find_package-ALWAYS-stdout.txt new file mode 100644 index 0000000..d43b8e8 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/Try_find_package-ALWAYS-stdout.txt @@ -0,0 +1,2 @@ +Loaded FirstProject from package config +(-- )?Confirmation project has been added diff --git a/Tests/RunCMake/FetchContent_find_package/Try_find_package-ALWAYS.cmake b/Tests/RunCMake/FetchContent_find_package/Try_find_package-ALWAYS.cmake new file mode 100644 index 0000000..0d7e289 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/Try_find_package-ALWAYS.cmake @@ -0,0 +1,18 @@ +include(FetchContent) + +set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR}/PackageConfigs) +set(FETCHCONTENT_TRY_FIND_PACKAGE_MODE ALWAYS) + +FetchContent_Declare( + FirstProject + # Ensure failure if we don't re-route to find_package() + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/FatalIfAdded +) + +FetchContent_Declare( + SecondProject + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/AddedProject + OVERRIDE_FIND_PACKAGE # Takes precedence over ALWAYS mode +) + +FetchContent_MakeAvailable(FirstProject SecondProject) diff --git a/Tests/RunCMake/FetchContent_find_package/Try_find_package-BOGUS-result.txt b/Tests/RunCMake/FetchContent_find_package/Try_find_package-BOGUS-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/Try_find_package-BOGUS-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FetchContent_find_package/Try_find_package-BOGUS-stderr.txt b/Tests/RunCMake/FetchContent_find_package/Try_find_package-BOGUS-stderr.txt new file mode 100644 index 0000000..4cc7347 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/Try_find_package-BOGUS-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at .*/FetchContent.cmake:[0-9]+ \(message\): + Unsupported value for FETCHCONTENT_TRY_FIND_PACKAGE_MODE: BOGUS diff --git a/Tests/RunCMake/FetchContent_find_package/Try_find_package-BOGUS.cmake b/Tests/RunCMake/FetchContent_find_package/Try_find_package-BOGUS.cmake new file mode 100644 index 0000000..f9c8ce7 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/Try_find_package-BOGUS.cmake @@ -0,0 +1,8 @@ +include(FetchContent) + +set(FETCHCONTENT_TRY_FIND_PACKAGE_MODE BOGUS) + +FetchContent_Declare( + AddedProject + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/AddedProject +) diff --git a/Tests/RunCMake/FetchContent_find_package/Try_find_package-NEVER-stdout.txt b/Tests/RunCMake/FetchContent_find_package/Try_find_package-NEVER-stdout.txt new file mode 100644 index 0000000..52398e7 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/Try_find_package-NEVER-stdout.txt @@ -0,0 +1 @@ +Confirmation project has been added diff --git a/Tests/RunCMake/FetchContent_find_package/Try_find_package-NEVER.cmake b/Tests/RunCMake/FetchContent_find_package/Try_find_package-NEVER.cmake new file mode 100644 index 0000000..92cb7d0 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/Try_find_package-NEVER.cmake @@ -0,0 +1,12 @@ +include(FetchContent) + +set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR}/PackageConfigs) +set(FETCHCONTENT_TRY_FIND_PACKAGE_MODE NEVER) + +FetchContent_Declare( + AddedProject + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/AddedProject + FIND_PACKAGE_ARGS REQUIRED +) + +FetchContent_MakeAvailable(AddedProject) diff --git a/Tests/RunCMake/FetchContent_find_package/Try_find_package-OPT_IN-stdout.txt b/Tests/RunCMake/FetchContent_find_package/Try_find_package-OPT_IN-stdout.txt new file mode 100644 index 0000000..d43b8e8 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/Try_find_package-OPT_IN-stdout.txt @@ -0,0 +1,2 @@ +Loaded FirstProject from package config +(-- )?Confirmation project has been added diff --git a/Tests/RunCMake/FetchContent_find_package/Try_find_package-OPT_IN.cmake b/Tests/RunCMake/FetchContent_find_package/Try_find_package-OPT_IN.cmake new file mode 100644 index 0000000..a549583 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/Try_find_package-OPT_IN.cmake @@ -0,0 +1,20 @@ +include(FetchContent) + +set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_LIST_DIR}/PackageConfigs) +set(FETCHCONTENT_TRY_FIND_PACKAGE_MODE OPT_IN) + +# With opt-in, should call find_package() +FetchContent_Declare( + FirstProject + # Ensure failure if we don't re-route to find_package() + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/FatalIfAdded + FIND_PACKAGE_ARGS REQUIRED +) + +# Without opt-in, shouldn't call find_package() +FetchContent_Declare( + SecondProject + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/AddedProject +) + +FetchContent_MakeAvailable(FirstProject SecondProject) diff --git a/Tests/RunCMake/FileAPI/RunCMakeTest.cmake b/Tests/RunCMake/FileAPI/RunCMakeTest.cmake index ae3d179..61dce17 100644 --- a/Tests/RunCMake/FileAPI/RunCMakeTest.cmake +++ b/Tests/RunCMake/FileAPI/RunCMakeTest.cmake @@ -18,12 +18,12 @@ in directory: endfunction() function(check_python case) - if(RunCMake_TEST_FAILED OR NOT PYTHON_EXECUTABLE) + if(RunCMake_TEST_FAILED OR NOT Python_EXECUTABLE) return() endif() file(GLOB index ${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/reply/index-*.json) execute_process( - COMMAND ${PYTHON_EXECUTABLE} "${RunCMake_SOURCE_DIR}/${case}-check.py" "${index}" "${CMAKE_CXX_COMPILER_ID}" + COMMAND ${Python_EXECUTABLE} "${RunCMake_SOURCE_DIR}/${case}-check.py" "${index}" "${CMAKE_CXX_COMPILER_ID}" "${RunCMake_TEST_BINARY_DIR}" RESULT_VARIABLE result OUTPUT_VARIABLE output diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json index 22b4536..e7b146f 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json @@ -496,7 +496,7 @@ "type": "export", "destination": "lib/cmake/foo", "paths": [ - "^CMakeFiles/Export/lib/cmake/foo/FooTargets\\.cmake$" + "^CMakeFiles/Export/22ecfa717ccadd33cf3e4bcbabcbde6b/FooTargets\\.cmake$" ], "isExcludeFromAll": null, "isForAllComponents": null, 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/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/GenEx-TARGET_FILE/ImportedTarget-TARGET_BUNDLE_DIR_NAME-result.txt b/Tests/RunCMake/GenEx-TARGET_FILE/ImportedTarget-TARGET_BUNDLE_DIR_NAME-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-TARGET_FILE/ImportedTarget-TARGET_BUNDLE_DIR_NAME-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-TARGET_FILE/ImportedTarget-TARGET_BUNDLE_DIR_NAME-stderr.txt b/Tests/RunCMake/GenEx-TARGET_FILE/ImportedTarget-TARGET_BUNDLE_DIR_NAME-stderr.txt new file mode 100644 index 0000000..f6e2df5 --- /dev/null +++ b/Tests/RunCMake/GenEx-TARGET_FILE/ImportedTarget-TARGET_BUNDLE_DIR_NAME-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at ImportedTarget-TARGET_BUNDLE_DIR_NAME.cmake:[0-9]* \(add_custom_target\): + Error evaluating generator expression: + + \$<TARGET_BUNDLE_DIR_NAME:empty> + + TARGET_BUNDLE_DIR_NAME not allowed for IMPORTED targets. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]* \(include\) diff --git a/Tests/RunCMake/GenEx-TARGET_FILE/ImportedTarget-TARGET_BUNDLE_DIR_NAME.cmake b/Tests/RunCMake/GenEx-TARGET_FILE/ImportedTarget-TARGET_BUNDLE_DIR_NAME.cmake new file mode 100644 index 0000000..f926f75 --- /dev/null +++ b/Tests/RunCMake/GenEx-TARGET_FILE/ImportedTarget-TARGET_BUNDLE_DIR_NAME.cmake @@ -0,0 +1,2 @@ +add_library(empty UNKNOWN IMPORTED) +add_custom_target(custom COMMAND echo $<TARGET_BUNDLE_DIR_NAME:empty>) diff --git a/Tests/RunCMake/GenEx-TARGET_FILE/NonValidTarget-TARGET_BUNDLE_DIR_NAME-result.txt b/Tests/RunCMake/GenEx-TARGET_FILE/NonValidTarget-TARGET_BUNDLE_DIR_NAME-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-TARGET_FILE/NonValidTarget-TARGET_BUNDLE_DIR_NAME-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-TARGET_FILE/NonValidTarget-TARGET_BUNDLE_DIR_NAME-stderr.txt b/Tests/RunCMake/GenEx-TARGET_FILE/NonValidTarget-TARGET_BUNDLE_DIR_NAME-stderr.txt new file mode 100644 index 0000000..dbbf63c --- /dev/null +++ b/Tests/RunCMake/GenEx-TARGET_FILE/NonValidTarget-TARGET_BUNDLE_DIR_NAME-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at NonValidTarget-TARGET_BUNDLE_DIR_NAME.cmake:[0-9]* \(file\): + Error evaluating generator expression: + + \$<TARGET_BUNDLE_DIR_NAME:empty> + + TARGET_BUNDLE_DIR_NAME is allowed only for Bundle targets. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]* \(include\) diff --git a/Tests/RunCMake/GenEx-TARGET_FILE/NonValidTarget-TARGET_BUNDLE_DIR_NAME.cmake b/Tests/RunCMake/GenEx-TARGET_FILE/NonValidTarget-TARGET_BUNDLE_DIR_NAME.cmake new file mode 100644 index 0000000..05b8e18 --- /dev/null +++ b/Tests/RunCMake/GenEx-TARGET_FILE/NonValidTarget-TARGET_BUNDLE_DIR_NAME.cmake @@ -0,0 +1,9 @@ + +enable_language(C) + +add_library(empty STATIC empty.c) + +file(GENERATE + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test.txt" + CONTENT "[$<TARGET_BUNDLE_DIR_NAME:empty>]" +) diff --git a/Tests/RunCMake/GenEx-TARGET_FILE/RunCMakeTest.cmake b/Tests/RunCMake/GenEx-TARGET_FILE/RunCMakeTest.cmake index 55b0f9b..148baac 100644 --- a/Tests/RunCMake/GenEx-TARGET_FILE/RunCMakeTest.cmake +++ b/Tests/RunCMake/GenEx-TARGET_FILE/RunCMakeTest.cmake @@ -17,8 +17,10 @@ run_cmake_with_options(TARGET_FILE_BASE_NAME-imported-target -DCMAKE_BUILD_TYPE: run_cmake(TARGET_FILE_BASE_NAME-non-valid-target) run_cmake(TARGET_LINKER_FILE_BASE_NAME-non-valid-target) run_cmake(NonValidTarget-TARGET_BUNDLE_DIR) +run_cmake(NonValidTarget-TARGET_BUNDLE_DIR_NAME) run_cmake(NonValidTarget-TARGET_BUNDLE_CONTENT_DIR) run_cmake(ImportedTarget-TARGET_BUNDLE_DIR) +run_cmake(ImportedTarget-TARGET_BUNDLE_DIR_NAME) run_cmake(ImportedTarget-TARGET_BUNDLE_CONTENT_DIR) run_cmake(ImportedTarget-TARGET_PDB_FILE) run_cmake(ImportedTarget-TARGET_PDB_FILE_BASE_NAME) diff --git a/Tests/RunCMake/GenerateExportHeader/GEH.cmake b/Tests/RunCMake/GenerateExportHeader/GEH.cmake index 431d1ce..bf9c302 100644 --- a/Tests/RunCMake/GenerateExportHeader/GEH.cmake +++ b/Tests/RunCMake/GenerateExportHeader/GEH.cmake @@ -43,14 +43,6 @@ endif() include(GenerateExportHeader) -set(CMAKE_CXX_STANDARD 98) - -# Clang/C2 in C++98 mode cannot properly handle some of MSVC headers -if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND - CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") - set(CMAKE_CXX_STANDARD 11) -endif() - add_subdirectory(lib_shared_and_static) if(CMAKE_SYSTEM_NAME MATCHES "AIX" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU" diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake index 854f3dc..5ea02a5 100644 --- a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake @@ -1,10 +1,15 @@ message(STATUS "CMAKE_VS_PLATFORM_TOOLSET='${CMAKE_VS_PLATFORM_TOOLSET}'") message(STATUS "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}'") +message(STATUS "CMAKE_HOST_SYSTEM_PROCESSOR='${CMAKE_HOST_SYSTEM_PROCESSOR}'") if(CMAKE_GENERATOR MATCHES "Visual Studio 1[67]") cmake_host_system_information(RESULT is_64_bit QUERY IS_64BIT) if(is_64_bit) - if(NOT "${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}" STREQUAL "x64") + if("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "ARM64") + if(NOT "${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}" STREQUAL "") + message(FATAL_ERROR "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE is not empty as expected.") + endif() + elseif(NOT "${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}" STREQUAL "x64") message(FATAL_ERROR "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE is not 'x64' as expected.") endif() endif() diff --git a/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake index 8515ba5..0e31b78 100644 --- a/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake +++ b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake @@ -8,12 +8,21 @@ run_cmake(BadObjSource2) if(RunCMake_GENERATOR STREQUAL "Xcode" AND "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]") run_cmake(ImportMultiArch) run_cmake(InstallNotSupported) + + set(osx_archs $ENV{CMAKE_OSX_ARCHITECTURES}) + list(GET osx_archs 0 osx_arch) + run_cmake_with_options(TargetOverrideSingleArch -Dosx_arch=${osx_arch}) else() run_cmake(Import) run_cmake(Install) run_cmake(InstallLinkedObj1) run_cmake(InstallLinkedObj2) + + if(RunCMake_GENERATOR STREQUAL "Xcode" AND XCODE_VERSION VERSION_GREATER_EQUAL 13) + run_cmake(TargetOverrideMultiArch) + endif() endif() + run_cmake(Export) function (run_object_lib_build name) diff --git a/Tests/RunCMake/ObjectLibrary/TargetOverrideMultiArch-result.txt b/Tests/RunCMake/ObjectLibrary/TargetOverrideMultiArch-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/TargetOverrideMultiArch-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ObjectLibrary/TargetOverrideMultiArch-stderr.txt b/Tests/RunCMake/ObjectLibrary/TargetOverrideMultiArch-stderr.txt new file mode 100644 index 0000000..eb0593c --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/TargetOverrideMultiArch-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at TargetOverrideMultiArch.cmake:[0-9]+ \(install\): + install TARGETS given OBJECT library "A" whose objects may not be installed + under Xcode with multiple architectures. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObjectLibrary/TargetOverrideMultiArch.cmake b/Tests/RunCMake/ObjectLibrary/TargetOverrideMultiArch.cmake new file mode 100644 index 0000000..ada77f8 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/TargetOverrideMultiArch.cmake @@ -0,0 +1,3 @@ +add_library(A OBJECT a.c) +set_target_properties(A PROPERTIES OSX_ARCHITECTURES "x86_64;arm64") +install(TARGETS A DESTINATION lib) diff --git a/Tests/RunCMake/ObjectLibrary/TargetOverrideSingleArch.cmake b/Tests/RunCMake/ObjectLibrary/TargetOverrideSingleArch.cmake new file mode 100644 index 0000000..3f400e8 --- /dev/null +++ b/Tests/RunCMake/ObjectLibrary/TargetOverrideSingleArch.cmake @@ -0,0 +1,3 @@ +add_library(A OBJECT a.c) +set_target_properties(A PROPERTIES OSX_ARCHITECTURES ${osx_arch}) +install(TARGETS A DESTINATION lib) diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index 3ddb890..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\\.\\.\\." 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..ee8821a 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) @@ -82,5 +83,7 @@ else() run_UnityBuildPCH() endif() +run_cmake(VsDotnetStartupObject) run_cmake(VsDotnetTargetFramework) run_cmake(VsDotnetTargetFrameworkVersion) +run_cmake(VsNoCompileBatching) diff --git a/Tests/RunCMake/VS10Project/VsCSharpCompilerOpts-check.cmake b/Tests/RunCMake/VS10Project/VsCSharpCompilerOpts-check.cmake index 3e418c3..2ba8c3b 100644 --- a/Tests/RunCMake/VS10Project/VsCSharpCompilerOpts-check.cmake +++ b/Tests/RunCMake/VS10Project/VsCSharpCompilerOpts-check.cmake @@ -17,9 +17,9 @@ set(releaseOK FALSE) file(STRINGS "${csProjectFile}" lines) foreach(line IN LISTS lines) #message(STATUS ${line}) - if(line MATCHES "^ *<PropertyGroup .*Debug\\|(Win32|x64).*") + if(line MATCHES "^ *<PropertyGroup .*Debug\\|(Win32|x64|ARM64).*") set(inDebug TRUE) - elseif(line MATCHES "^ *<PropertyGroup .*Release\\|(Win32|x64).*") + elseif(line MATCHES "^ *<PropertyGroup .*Release\\|(Win32|x64|ARM64).*") set(inRelease TRUE) elseif(line MATCHES "^ *</PropertyGroup> *$") set(inRelease FALSE) diff --git a/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake b/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake index 631abac..d47bac9 100644 --- a/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake +++ b/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake @@ -17,9 +17,9 @@ set(releaseOK FALSE) file(STRINGS "${csProjectFile}" lines) foreach(line IN LISTS lines) #message(STATUS ${line}) - if(line MATCHES "^ *<PropertyGroup .*Debug\\|(Win32|x64).*") + if(line MATCHES "^ *<PropertyGroup .*Debug\\|(Win32|x64|ARM64).*") set(inDebug TRUE) - elseif(line MATCHES "^ *<PropertyGroup .*Release\\|(Win32|x64).*") + elseif(line MATCHES "^ *<PropertyGroup .*Release\\|(Win32|x64|ARM64).*") set(inRelease TRUE) elseif(line MATCHES "^ *</PropertyGroup> *$") set(inRelease FALSE) diff --git a/Tests/RunCMake/VS10Project/VsDotnetStartupObject-check.cmake b/Tests/RunCMake/VS10Project/VsDotnetStartupObject-check.cmake new file mode 100644 index 0000000..b3e5e37 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDotnetStartupObject-check.cmake @@ -0,0 +1,22 @@ +set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.csproj") +if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") + return() +endif() + +set(startupObjectSet FALSE) + +file(STRINGS "${vcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES "^ *<StartupObject[^>]*>([^<>]+)</StartupObject>$") + if("${CMAKE_MATCH_1}" STREQUAL "MyCompany.Package.MyStarterClass") + message(STATUS "foo.csproj has StartupObject class set") + set(startupObjectSet TRUE) + endif() + endif() +endforeach() + +if(NOT startupObjectSet) + set(RunCMake_TEST_FAILED "StartupObject not found or not set correctly.") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsDotnetStartupObject.cmake b/Tests/RunCMake/VS10Project/VsDotnetStartupObject.cmake new file mode 100644 index 0000000..8a0ec5e --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDotnetStartupObject.cmake @@ -0,0 +1,10 @@ +enable_language(CSharp) +if(NOT CMAKE_CSharp_COMPILER) + return() +endif() + +set(CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION "v4.6.1") + +add_executable(foo foo.cs) + +set_target_properties(foo PROPERTIES VS_DOTNET_STARTUP_OBJECT "MyCompany.Package.MyStarterClass") 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/VsDotnetSdk/RunCMakeTest.cmake b/Tests/RunCMake/VsDotnetSdk/RunCMakeTest.cmake index b174c25..9c9074e 100644 --- a/Tests/RunCMake/VsDotnetSdk/RunCMakeTest.cmake +++ b/Tests/RunCMake/VsDotnetSdk/RunCMakeTest.cmake @@ -3,6 +3,7 @@ include(RunCMake) run_cmake(VsDotnetSdkCustomCommandsTarget) run_cmake(VsDotnetSdkCustomCommandsSource) +run_cmake(VsDotnetSdkStartupObject) run_cmake(DotnetSdkVariables) function(run_VsDotnetSdk) diff --git a/Tests/RunCMake/VsDotnetSdk/VsDotnetSdkStartupObject-check.cmake b/Tests/RunCMake/VsDotnetSdk/VsDotnetSdkStartupObject-check.cmake new file mode 100644 index 0000000..e81de30 --- /dev/null +++ b/Tests/RunCMake/VsDotnetSdk/VsDotnetSdkStartupObject-check.cmake @@ -0,0 +1,22 @@ +set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.csproj") +if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") + return() +endif() + +set(startupObjectSet FALSE) + +file(STRINGS "${vcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES "^ *<StartupObject[^>]*>([^<>]+)</StartupObject>$") + if("${CMAKE_MATCH_1}" STREQUAL "CSharpOnly.CSharpOnly") + message(STATUS "foo.csproj has StartupObject class set") + set(startupObjectSet TRUE) + endif() + endif() +endforeach() + +if(NOT startupObjectSet) + set(RunCMake_TEST_FAILED "StartupObject not found or not set correctly.") + return() +endif() diff --git a/Tests/RunCMake/VsDotnetSdk/VsDotnetSdkStartupObject.cmake b/Tests/RunCMake/VsDotnetSdk/VsDotnetSdkStartupObject.cmake new file mode 100644 index 0000000..9ccd4f2 --- /dev/null +++ b/Tests/RunCMake/VsDotnetSdk/VsDotnetSdkStartupObject.cmake @@ -0,0 +1,11 @@ +enable_language(CSharp) +if(NOT CMAKE_CSharp_COMPILER) + return() +endif() + +set(CMAKE_DOTNET_SDK "Microsoft.NET.Sdk") +set(CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION "net5.0") + +add_executable(foo csharponly.cs lib1.cs) + +set_target_properties(foo PROPERTIES VS_DOTNET_STARTUP_OBJECT "CSharpOnly.CSharpOnly") 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_host_system_information/Registry_BadKey1-result.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadKey1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadKey1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadKey1-stderr.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadKey1-stderr.txt new file mode 100644 index 0000000..1832ada --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadKey1-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at Registry_BadKey1.cmake:[0-9]+ \(message\): + WRONG_ROOT: invalid root key. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadKey1.cmake b/Tests/RunCMake/cmake_host_system_information/Registry_BadKey1.cmake new file mode 100644 index 0000000..6299f85 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadKey1.cmake @@ -0,0 +1,4 @@ +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY WRONG_ROOT/SUBKEY ERROR_VARIABLE error) +if (NOT error STREQUAL "") + message(FATAL_ERROR "${error}") +endif() diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadKey2-result.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadKey2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadKey2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadKey2-stderr.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadKey2-stderr.txt new file mode 100644 index 0000000..4be55bf --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadKey2-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at Registry_BadKey2.cmake:[0-9]+ \(message\): + HKLM-SUBKEY: invalid root key. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadKey2.cmake b/Tests/RunCMake/cmake_host_system_information/Registry_BadKey2.cmake new file mode 100644 index 0000000..1750078 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadKey2.cmake @@ -0,0 +1,4 @@ +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY HKLM-SUBKEY ERROR_VARIABLE error) +if (NOT error STREQUAL "") + message(FATAL_ERROR "${error}") +endif() diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery1-result.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery1-stderr.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery1-stderr.txt new file mode 100644 index 0000000..9510327 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery1-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at Registry_BadQuery1.cmake:[0-9]+ \(cmake_host_system_information\): + cmake_host_system_information given invalid argument\(s\) "BAD_OPTION". +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery1.cmake b/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery1.cmake new file mode 100644 index 0000000..a92f35c --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery1.cmake @@ -0,0 +1 @@ +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY HKLM/SOFTWARE BAD_OPTION) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery2-result.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery2-stderr.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery2-stderr.txt new file mode 100644 index 0000000..6a430f1 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery2-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at Registry_BadQuery2.cmake:[0-9]+ \(cmake_host_system_information\): + cmake_host_system_information missing expected value for argument\(s\) + "VALUE". +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery2.cmake b/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery2.cmake new file mode 100644 index 0000000..7c751cc --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadQuery2.cmake @@ -0,0 +1 @@ +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY HKLM/SOFTWARE VALUE) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadView1-result.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadView1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadView1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadView1-stderr.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadView1-stderr.txt new file mode 100644 index 0000000..5eda4ff --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadView1-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at Registry_BadView1.cmake:[0-9]+ \(cmake_host_system_information\): + cmake_host_system_information missing expected value for argument\(s\) + "VIEW". +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadView1.cmake b/Tests/RunCMake/cmake_host_system_information/Registry_BadView1.cmake new file mode 100644 index 0000000..6527784 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadView1.cmake @@ -0,0 +1 @@ +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY HKLM/SOFTWARE VIEW) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadView2-result.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadView2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadView2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadView2-stderr.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadView2-stderr.txt new file mode 100644 index 0000000..201d93a --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadView2-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at Registry_BadView2.cmake:[0-9]+ \(cmake_host_system_information\): + cmake_host_system_information given invalid value for "VIEW": BAD_VIEW. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadView2.cmake b/Tests/RunCMake/cmake_host_system_information/Registry_BadView2.cmake new file mode 100644 index 0000000..d116c76 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadView2.cmake @@ -0,0 +1 @@ +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY HKLM/SOFTWARE VIEW BAD_VIEW) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadView3-result.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadView3-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadView3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadView3-stderr.txt b/Tests/RunCMake/cmake_host_system_information/Registry_BadView3-stderr.txt new file mode 100644 index 0000000..5b7f7c7 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadView3-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at Registry_BadView3.cmake:[0-9]+ \(cmake_host_system_information\): + cmake_host_system_information given invalid argument\(s\) "64". +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_BadView3.cmake b/Tests/RunCMake/cmake_host_system_information/Registry_BadView3.cmake new file mode 100644 index 0000000..7c5f272 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_BadView3.cmake @@ -0,0 +1 @@ +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY HKLM/SOFTWARE VIEW 32 64) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_NoArgs-result.txt b/Tests/RunCMake/cmake_host_system_information/Registry_NoArgs-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_NoArgs-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_NoArgs-stderr.txt b/Tests/RunCMake/cmake_host_system_information/Registry_NoArgs-stderr.txt new file mode 100644 index 0000000..ff55fcb --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_NoArgs-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at Registry_NoArgs.cmake:[0-9]+ \(cmake_host_system_information\): + cmake_host_system_information missing <key> specification. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_NoArgs.cmake b/Tests/RunCMake/cmake_host_system_information/Registry_NoArgs.cmake new file mode 100644 index 0000000..87e253d --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_NoArgs.cmake @@ -0,0 +1 @@ +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY) diff --git a/Tests/RunCMake/cmake_host_system_information/Registry_Query.cmake b/Tests/RunCMake/cmake_host_system_information/Registry_Query.cmake new file mode 100644 index 0000000..97a4ecc --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/Registry_Query.cmake @@ -0,0 +1,336 @@ + +# helper function for test validation +function(CHECK key result status expression) + if(status STREQUAL "") + cmake_language(EVAL CODE + "if (NOT (${expression})) + message(SEND_ERROR \"wrong value for key '${key}': '${result}'\") + endif()") + else() + message(SEND_ERROR "query failed for key '${key}': '${status}'") + endif() +endfunction() + + +# HKCU/Software/Classes/CLSID/CMake-Tests/chsi-registry: Query default value +set(KEY "HKCU/Software/Classes/CLSID/CMake-Tests/chsi-registry") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" ERROR_VARIABLE status) +check("${KEY}" "${result}" "${status}" + "result STREQUAL \"default ${ARCH}\"") +# query value using special name should be identical to default value +cmake_host_system_information(RESULT result2 QUERY WINDOWS_REGISTRY "${KEY}" VALUE "(default)" ERROR_VARIABLE status) +check("${KEY}{(default)}" "${result2}" "${status}" "result2 STREQUAL result") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VIEW HOST ERROR_VARIABLE status) +check("${KEY}" "${result}" "${status}" + "result STREQUAL \"default ${ARCH}\"") +# VIEW TARGET should have same value as VIEW HOST +cmake_host_system_information(RESULT result2 QUERY WINDOWS_REGISTRY "${KEY}" VIEW TARGET ERROR_VARIABLE status) +check("${KEY}" "${result2}" "${status}" "result2 STREQUAL result") + +if (ARCH STREQUAL "64bit") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VIEW 64 ERROR_VARIABLE status) + check("${KEY}" "${result}" "${status}" "result STREQUAL \"default 64bit\"") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VIEW 32 ERROR_VARIABLE status) + check("${KEY}" "${result}" "${status}" "result STREQUAL \"default 32bit\"") + + # reg 64bit is read first + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VIEW 64_32 ERROR_VARIABLE status) + check("${KEY}" "${result}" "${status}" "result STREQUAL \"default 64bit\"") + + # reg 32bit is read first + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VIEW 32_64 ERROR_VARIABLE status) + check("${KEY}" "${result}" "${status}" "result STREQUAL \"default 32bit\"") + +else() #32bit + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VIEW 64 ERROR_VARIABLE status) + check("${KEY}" "${result}" "${status}" "result STREQUAL \"\"") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VIEW 32 ERROR_VARIABLE status) + check("${KEY}" "${result}" "${status}" "result STREQUAL \"default 32bit\"") + + # reg 64bit is read first + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VIEW 64_32 ERROR_VARIABLE status) + check("${KEY}" "${result}" "${status}" "result STREQUAL \"default 32bit\"") + + # reg 32bit is read first + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VIEW 32_64 ERROR_VARIABLE status) + check("${KEY}" "${result}" "${status}" "result STREQUAL \"default 32bit\"") + +endif() + + +# HKCU/Software/CMake-Tests/chsi-registry: Query named value +set(KEY "HKCU/Software/Classes/CLSID/CMake-Tests/chsi-registry") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE BYTE_SIZE + ERROR_VARIABLE status) +check("${KEY}{BYTE_SIZE}" "${result}" "${status}" + "result STREQUAL \"${ARCH}\"") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE BYTE_SIZE + VIEW HOST ERROR_VARIABLE status) +check("${KEY}{BYTE_SIZE}" "${result}" "${status}" + "result STREQUAL \"${ARCH}\"") +# VIEW TARGET should have same value as VIEW HOST +cmake_host_system_information(RESULT result2 QUERY WINDOWS_REGISTRY "${KEY}" VALUE BYTE_SIZE + VIEW TARGET ERROR_VARIABLE status) +check("${KEY}{BYTE_SIZE}" "${result2}" "${status}" "result2 STREQUAL result") + +if (ARCH STREQUAL "64bit") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE BYTE_SIZE + VIEW 64 ERROR_VARIABLE status) + check("${KEY}{BYTE_SIZE}" "${result}" "${status}" "result STREQUAL \"64bit\"") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE BYTE_SIZE + VIEW 32 ERROR_VARIABLE status) + check("${KEY}{BYTE_SIZE}" "${result}" "${status}" "result STREQUAL \"32bit\"") + + # reg 64bit is read first + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE BYTE_SIZE + VIEW 64_32 ERROR_VARIABLE status) + check("${KEY}{BYTE_SIZE}" "${result}" "${status}" "result STREQUAL \"64bit\"") + + # reg 32bit is read first + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE BYTE_SIZE + VIEW 32_64 ERROR_VARIABLE status) + check("${KEY}{BYTE_SIZE}" "${result}" "${status}" "result STREQUAL \"32bit\"") + +else() # 32bit + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE BYTE_SIZE + VIEW 64 ERROR_VARIABLE status) + check("${KEY}{BYTE_SIZE}" "${result}" "${status}" "result STREQUAL \"\"") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE BYTE_SIZE + VIEW 32 ERROR_VARIABLE status) + check("${KEY}{BYTE_SIZE}" "${result}" "${status}" "result STREQUAL \"32bit\"") + + # reg 64bit is read first + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE BYTE_SIZE + VIEW 64_32 ERROR_VARIABLE status) + check("${KEY}{BYTE_SIZE}" "${result}" "${status}" "result STREQUAL \"32bit\"") + + # reg 32bit is read first + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE BYTE_SIZE + VIEW 32_64 ERROR_VARIABLE status) + check("${KEY}{BYTE_SIZE}" "${result}" "${status}" "result STREQUAL \"32bit\"") + +endif() + +# HKCU/Software/CMake-Tests/chsi-registry: check retrieval of various types +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE VALUE_SZ ERROR_VARIABLE status) +check("${KEY}{VALUE_SZ}" "${result}" "${status}" "result STREQUAL \"data with space\"") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE VALUE_EXPAND_SZ ERROR_VARIABLE status) +check("${KEY}{VALUE_EXPAND_SZ}" "${result}" "${status}" + "(NOT result STREQUAL \"PATH=%PATH%\") AND (result MATCHES \"^PATH=\")") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE VALUE_MULTI_SZ ERROR_VARIABLE status) +check("${KEY}{VALUE_MULTI_SZ}" "${result}" "${status}" "result STREQUAL \"data1;data2\"") +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE VALUE2_MULTI_SZ + SEPARATOR "|" ERROR_VARIABLE status) +check("${KEY}{VALUE2_MULTI_SZ}" "${result}" "${status}" "result STREQUAL \"data1;data2\"") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE VALUE_DWORD ERROR_VARIABLE status) +check("${KEY}{VALUE_DWORD}" "${result}" "${status}" "result EQUAL \"129\"") + +cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE VALUE_QWORD ERROR_VARIABLE status) +check("${KEY}{VALUE_QWORD}" "${result}" "${status}" "result EQUAL \"513\"") + + +# HKCU/Software/CMake-Tests/chsi-registry: check retrieval of value names +if (ARCH STREQUAL "64bit") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + ERROR_VARIABLE status) + check("${KEY}[VALUE_NAMES]" "${result}" "${status}" "result STREQUAL \"(default);BYTE_SIZE;VALUE2_MULTI_SZ;VALUE2_SZ;VALUE_DWORD;VALUE_EXPAND_SZ;VALUE_MULTI_SZ;VALUE_QWORD;VALUE_SZ\"") + # VIEW BOTH should have same result as default view + cmake_host_system_information(RESULT result2 QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW BOTH ERROR_VARIABLE status) + check("${KEY}[VALUE_NAMES]" "${result2}" "${status}" "result2 STREQUAL result") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW HOST ERROR_VARIABLE status) + check("${KEY}[VALUE_NAMES]" "${result}" "${status}" + "result STREQUAL \"(default);BYTE_SIZE;VALUE2_MULTI_SZ;VALUE_DWORD;VALUE_EXPAND_SZ;VALUE_MULTI_SZ;VALUE_QWORD;VALUE_SZ\"") + # VIEW TARGET should have same result as VIEW HOST + cmake_host_system_information(RESULT result2 QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW TARGET ERROR_VARIABLE status) + check("${KEY}[VALUE_NAMES]" "${result2}" "${status}" "result2 STREQUAL result") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW 64 ERROR_VARIABLE status) + check("${KEY}[VALUE_NAMES]" "${result}" "${status}" + "result STREQUAL \"(default);BYTE_SIZE;VALUE2_MULTI_SZ;VALUE_DWORD;VALUE_EXPAND_SZ;VALUE_MULTI_SZ;VALUE_QWORD;VALUE_SZ\"") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW 32 ERROR_VARIABLE status) + check("${KEY}[VALUE_NAMES]" "${result}" "${status}" "result STREQUAL \"(default);BYTE_SIZE;VALUE2_SZ\"") + + # reg 64bit is read first + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW 64_32 ERROR_VARIABLE status) + check("${KEY}[VALUE_NAMES]" "${result}" "${status}" + "result STREQUAL \"(default);BYTE_SIZE;VALUE2_MULTI_SZ;VALUE2_SZ;VALUE_DWORD;VALUE_EXPAND_SZ;VALUE_MULTI_SZ;VALUE_QWORD;VALUE_SZ\"") + + # reg 32bit is read first. Result is the same as with view 64_32 + cmake_host_system_information(RESULT result2 QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW 32_64 ERROR_VARIABLE status) + check("${KEY}[VALUE_NAMES]" "${result2}" "${status}" "result2 STREQUAL result") + +else() + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + ERROR_VARIABLE status) + check("${KEY}[VALUE_NAMES]" "${result}" "${status}" "result STREQUAL \"(default);BYTE_SIZE;VALUE2_MULTI_SZ;VALUE_DWORD;VALUE_EXPAND_SZ;VALUE_MULTI_SZ;VALUE_QWORD;VALUE_SZ\"") + # VIEW BOTH should have same result as default view + cmake_host_system_information(RESULT result2 QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW BOTH ERROR_VARIABLE status) + check("${KEY}[VALUE_NAMES]" "${result2}" "${status}" "result STREQUAL result2") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW HOST ERROR_VARIABLE status) + check("${KEY}[VALUE_NAMES]" "${result}" "${status}" + "result STREQUAL \"(default);BYTE_SIZE;VALUE2_MULTI_SZ;VALUE_DWORD;VALUE_EXPAND_SZ;VALUE_MULTI_SZ;VALUE_QWORD;VALUE_SZ") + # VIEW TARGET should have same result as VIEW HOST + cmake_host_system_information(RESULT result2 QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW TARGET ERROR_VARIABLE status) + check("${KEY}[VALUE_NAMES]" "${result2}" "${status}" "result2 STREQUAL result") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW 64 ERROR_VARIABLE status) + check("${KEY}[VALUE_NAMES]" "${result}" "${status}" "result STREQUAL \"\"") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW 32 ERROR_VARIABLE status) + check("${KEY}[VALUE_NAMES]" "${result}" "${status}" "result STREQUAL \"(default);BYTE_SIZE;VALUE2_MULTI_SZ;VALUE_DWORD;VALUE_EXPAND_SZ;VALUE_MULTI_SZ;VALUE_QWORD;VALUE_SZ\"") + + # reg 64bit is read first + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW 64_32 ERROR_VARIABLE status) + check("${KEY}[VALUE_NAMES]" "${result}" "${status}" + "result STREQUAL \"(default);BYTE_SIZE;VALUE2_MULTI_SZ;VALUE_DWORD;VALUE_EXPAND_SZ;VALUE_MULTI_SZ;VALUE_QWORD;VALUE_SZ\"") + + # reg 32bit is read first. Result is the same as with view 64_32 + cmake_host_system_information(RESULT result2 QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW 32_64 ERROR_VARIABLE status) + check("${KEY}[VALUE_NAMES]" "${result2}" "${status}" "result2 STREQUAL result") + +endif() + + +# HKCU/Software/CMake-Tests/chsi-registry: check retrieval of sub keys +if (ARCH STREQUAL "64bit") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + ERROR_VARIABLE status) + check("${KEY}[SUBKEYS]" "${result}" "${status}" "result STREQUAL \"subkey1;subkey2;subkey3\"") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + VIEW HOST ERROR_VARIABLE status) + check("${KEY}[SUBKEYS]" "${result}" "${status}" "result STREQUAL \"subkey1;subkey2\"") + # VIEW TARGET should have same result as VIEW HOST + cmake_host_system_information(RESULT result2 QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + VIEW TARGET ERROR_VARIABLE status) + check("${KEY}[SUBKEYS]" "${result}" "${status}" "result2 STREQUAL result") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + VIEW 64 ERROR_VARIABLE status) + check("${KEY}[SUBKEYS]" "${result}" "${status}" "result STREQUAL \"subkey1;subkey2\"") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + VIEW 32 ERROR_VARIABLE status) + check("${KEY}[SUBKEYS]" "${result}" "${status}" "result STREQUAL \"subkey1;subkey3\"") + + # reg 64bit is read first + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + VIEW 64_32 ERROR_VARIABLE status) + check("${KEY}[SUBLEYS]" "${result}" "${status}" "result STREQUAL \"subkey1;subkey2;subkey3\"") + + # reg 32bit is read first. Result is the same as with view 64_32 + cmake_host_system_information(RESULT result2 QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + VIEW 32_64 ERROR_VARIABLE status) + check("${KEY}[SUBKEYS]" "${result2}" "${status}" "result2 STREQUAL result") + +else() + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + ERROR_VARIABLE status) + check("${KEY}[SUBKEYS]" "${result}" "${status}" "result STREQUAL \"subkey1;subkey2\"") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + VIEW HOST ERROR_VARIABLE status) + check("${KEY}[SUBKEYS]" "${result}" "${status}" "result STREQUAL \"subkey1;subkey2\"") + # VIEW TARGET should have same result as VIEW HOST + cmake_host_system_information(RESULT result2 QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + VIEW TARGET ERROR_VARIABLE status) + check("${KEY}[SUBKEYS]" "${result}" "${status}" "result2 STREQUAL result") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + VIEW 64 ERROR_VARIABLE status) + check("${KEY}[SUBKEYS]" "${result}" "${status}" "result STREQUAL \"\"") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + VIEW 32 ERROR_VARIABLE status) + check("${KEY}[SUBKEYS]" "${result}" "${status}" "result STREQUAL \"subkey1;subkey2\"") + + # reg 64bit is read first + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + VIEW 64_32 ERROR_VARIABLE status) + check("${KEY}[SUBLEYS]" "${result}" "${status}" "result STREQUAL \"subkey1;subkey2\"") + + # reg 32bit is read first. Result is the same as with view 64_32 + cmake_host_system_information(RESULT result2 QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + VIEW 32_64 ERROR_VARIABLE status) + check("${KEY}[SUBKEYS]" "${result2}" "${status}" "result2 STREQUAL result") + +endif() + + +if (ARCH STREQUAL "64bit") + + # Check influence of variable CMAKE_SIZEOF_VOID_P + set(CMAKE_SIZEOF_VOID_P 8) + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" + VIEW TARGET ERROR_VARIABLE status) + check("${KEY}" "${result}" "${status}" "result STREQUAL \"default 64bit\"") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE BYTE_SIZE + VIEW TARGET ERROR_VARIABLE status) + check("${KEY}" "${result}" "${status}" "result STREQUAL \"64bit\"") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW TARGET ERROR_VARIABLE status) + check("${KEY}" "${result}" "${status}" "result STREQUAL \"(default);BYTE_SIZE;VALUE2_MULTI_SZ;VALUE_DWORD;VALUE_EXPAND_SZ;VALUE_MULTI_SZ;VALUE_QWORD;VALUE_SZ\"") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + VIEW TARGET ERROR_VARIABLE status) + check("${KEY}" "${result}" "${status}" "result STREQUAL \"subkey1;subkey2\"") + + + set(CMAKE_SIZEOF_VOID_P 4) + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" + VIEW TARGET ERROR_VARIABLE status) + check("${KEY}" "${result}" "${status}" "result STREQUAL \"default 32bit\"") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE BYTE_SIZE + VIEW TARGET ERROR_VARIABLE status) + check("${KEY}" "${result}" "${status}" "result STREQUAL \"32bit\"") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" VALUE_NAMES + VIEW TARGET ERROR_VARIABLE status) + check("${KEY}" "${result}" "${status}" "result STREQUAL \"(default);BYTE_SIZE;VALUE2_SZ\"") + + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "${KEY}" SUBKEYS + VIEW TARGET ERROR_VARIABLE status) + check("${KEY}" "${result}" "${status}" "result STREQUAL \"subkey1;subkey3\"") + +endif() diff --git a/Tests/RunCMake/cmake_host_system_information/RunCMakeTest.cmake b/Tests/RunCMake/cmake_host_system_information/RunCMakeTest.cmake index 87b6944..9122470 100644 --- a/Tests/RunCMake/cmake_host_system_information/RunCMakeTest.cmake +++ b/Tests/RunCMake/cmake_host_system_information/RunCMakeTest.cmake @@ -21,3 +21,39 @@ if(RunCMake_GENERATOR MATCHES "^Visual Studio " AND NOT RunCMake_GENERATOR STREQ else() run_cmake(VsMSBuildMissing) endif() + +# WINDOWS_REGISTRY tests +run_cmake(Registry_NoArgs) +run_cmake(Registry_BadQuery1) +run_cmake(Registry_BadQuery2) +run_cmake(Registry_BadView1) +run_cmake(Registry_BadView2) +run_cmake(Registry_BadView3) +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + run_cmake(Registry_BadKey1) + run_cmake(Registry_BadKey2) + + # Tests using the Windows registry + find_program(REG NAMES "reg.exe" NO_CACHE) + if (REG) + ## check host architecture + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "HKCU" SUBKEYS VIEW 64 ERROR_VARIABLE status) + if (status STREQUAL "") + set(ARCH "64bit") + else() + set(ARCH "32bit") + endif() + + # crete some entries in the registry + cmake_path(CONVERT "${RunCMake_SOURCE_DIR}/registry_host${ARCH}.reg" TO_NATIVE_PATH_LIST registry_data) + execute_process(COMMAND "${REG}" import "${registry_data}" OUTPUT_QUIET ERROR_QUIET) + + run_cmake_with_options(Registry_Query -DARCH=${ARCH}) + + # clean-up registry + execute_process(COMMAND "${REG}" delete "HKCU\\SOFTWARE\\Classes\\CLSID\\CMake-Tests\\chsi-registry" /f OUTPUT_QUIET ERROR_QUIET) + if (ARCH STREQUAL "64bit") + execute_process(COMMAND "${REG}" delete "HKCU\\SOFTWARE\\Classes\\WOW6432Node\\CLSID\\CMake-Tests\\chsi-registry" /f OUTPUT_QUIET ERROR_QUIET) + endif() + endif() +endif() diff --git a/Tests/RunCMake/cmake_host_system_information/registry_host32bit.reg b/Tests/RunCMake/cmake_host_system_information/registry_host32bit.reg Binary files differnew file mode 100644 index 0000000..2bbd6a2 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/registry_host32bit.reg diff --git a/Tests/RunCMake/cmake_host_system_information/registry_host64bit.reg b/Tests/RunCMake/cmake_host_system_information/registry_host64bit.reg Binary files differnew file mode 100644 index 0000000..8596648 --- /dev/null +++ b/Tests/RunCMake/cmake_host_system_information/registry_host64bit.reg 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/execute_process/AnyCommandAbnormalExit.cmake b/Tests/RunCMake/execute_process/AnyCommandAbnormalExit.cmake index 5ac0c21..1017e0f 100644 --- a/Tests/RunCMake/execute_process/AnyCommandAbnormalExit.cmake +++ b/Tests/RunCMake/execute_process/AnyCommandAbnormalExit.cmake @@ -1,4 +1,4 @@ -execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c +execute_process(COMMAND "${Python_EXECUTABLE}" -c "import os; os.kill(os.getpid(),11)" COMMAND ${CMAKE_COMMAND} -E true COMMAND_ERROR_IS_FATAL ANY diff --git a/Tests/RunCMake/execute_process/LastCommandAbnormalExit-1.cmake b/Tests/RunCMake/execute_process/LastCommandAbnormalExit-1.cmake index 5a4574c..e4a125d 100644 --- a/Tests/RunCMake/execute_process/LastCommandAbnormalExit-1.cmake +++ b/Tests/RunCMake/execute_process/LastCommandAbnormalExit-1.cmake @@ -1,11 +1,11 @@ -execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c +execute_process(COMMAND "${Python_EXECUTABLE}" -c "import os; os.kill(os.getpid(),11)" COMMAND ${CMAKE_COMMAND} -E true RESULT_VARIABLE result ) if(result EQUAL "0") - execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c + execute_process(COMMAND "${Python_EXECUTABLE}" -c "import os; os.kill(os.getpid(),11)" COMMAND ${CMAKE_COMMAND} -E true COMMAND_ERROR_IS_FATAL LAST diff --git a/Tests/RunCMake/execute_process/LastCommandAbnormalExit-2.cmake b/Tests/RunCMake/execute_process/LastCommandAbnormalExit-2.cmake index b87e0f7..6c3fbf8 100644 --- a/Tests/RunCMake/execute_process/LastCommandAbnormalExit-2.cmake +++ b/Tests/RunCMake/execute_process/LastCommandAbnormalExit-2.cmake @@ -1,12 +1,12 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E true - COMMAND "${PYTHON_EXECUTABLE}" -c + COMMAND "${Python_EXECUTABLE}" -c "import os; os.kill(os.getpid(),11)" RESULT_VARIABLE result ) if(NOT result EQUAL "0") execute_process(COMMAND ${CMAKE_COMMAND} -E true - COMMAND "${PYTHON_EXECUTABLE}" -c + COMMAND "${Python_EXECUTABLE}" -c "import os; os.kill(os.getpid(),11)" COMMAND_ERROR_IS_FATAL LAST ) diff --git a/Tests/RunCMake/execute_process/RunCMakeTest.cmake b/Tests/RunCMake/execute_process/RunCMakeTest.cmake index 35712f6..c2f9144 100644 --- a/Tests/RunCMake/execute_process/RunCMakeTest.cmake +++ b/Tests/RunCMake/execute_process/RunCMakeTest.cmake @@ -35,8 +35,8 @@ run_cmake_command(LastCommandError ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/La run_cmake_command(LastCommandTimeout ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/LastCommandTimeout.cmake) run_cmake_command(LastCommandGood ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/LastCommandGood.cmake) -if(UNIX AND PYTHON_EXECUTABLE) - run_cmake_command(AnyCommandAbnormalExit ${CMAKE_COMMAND} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -P ${RunCMake_SOURCE_DIR}/AnyCommandAbnormalExit.cmake) - run_cmake_command(LastCommandAbnormalExit-1 ${CMAKE_COMMAND} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -P ${RunCMake_SOURCE_DIR}/LastCommandAbnormalExit-1.cmake) - run_cmake_command(LastCommandAbnormalExit-2 ${CMAKE_COMMAND} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -P ${RunCMake_SOURCE_DIR}/LastCommandAbnormalExit-2.cmake) +if(UNIX AND Python_EXECUTABLE) + run_cmake_command(AnyCommandAbnormalExit ${CMAKE_COMMAND} -DPython_EXECUTABLE=${Python_EXECUTABLE} -P ${RunCMake_SOURCE_DIR}/AnyCommandAbnormalExit.cmake) + run_cmake_command(LastCommandAbnormalExit-1 ${CMAKE_COMMAND} -DPython_EXECUTABLE=${Python_EXECUTABLE} -P ${RunCMake_SOURCE_DIR}/LastCommandAbnormalExit-1.cmake) + run_cmake_command(LastCommandAbnormalExit-2 ${CMAKE_COMMAND} -DPython_EXECUTABLE=${Python_EXECUTABLE} -P ${RunCMake_SOURCE_DIR}/LastCommandAbnormalExit-2.cmake) endif() diff --git a/Tests/RunCMake/find_file/32bit/file.txt b/Tests/RunCMake/find_file/32bit/file.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_file/32bit/file.txt diff --git a/Tests/RunCMake/find_file/32bit/file32bit.txt b/Tests/RunCMake/find_file/32bit/file32bit.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_file/32bit/file32bit.txt diff --git a/Tests/RunCMake/find_file/64bit/file.txt b/Tests/RunCMake/find_file/64bit/file.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_file/64bit/file.txt diff --git a/Tests/RunCMake/find_file/64bit/file64bit.txt b/Tests/RunCMake/find_file/64bit/file64bit.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_file/64bit/file64bit.txt diff --git a/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stderr.txt b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stderr.txt index 38ed98c..edf2cab 100644 --- a/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stderr.txt +++ b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stderr.txt @@ -8,6 +8,7 @@ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 0 CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + CMAKE_FIND_USE_INSTALL_PREFIX: 1 find_file considered the following locations:.* The item was not found.* @@ -21,5 +22,6 @@ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 0 CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + CMAKE_FIND_USE_INSTALL_PREFIX: 1 find_file considered the following locations:.* diff --git a/Tests/RunCMake/find_file/PrefixInPATH-stderr.txt b/Tests/RunCMake/find_file/PrefixInPATH-stderr.txt index 0d77571..93e6253 100644 --- a/Tests/RunCMake/find_file/PrefixInPATH-stderr.txt +++ b/Tests/RunCMake/find_file/PrefixInPATH-stderr.txt @@ -8,6 +8,7 @@ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1 CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + CMAKE_FIND_USE_INSTALL_PREFIX: 1 find_file considered the following locations:.* .*include/PrefixInPATH.* diff --git a/Tests/RunCMake/find_file/REGISTRY_VIEW-no-view-result.txt b/Tests/RunCMake/find_file/REGISTRY_VIEW-no-view-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_file/REGISTRY_VIEW-no-view-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_file/REGISTRY_VIEW-no-view-stderr.txt b/Tests/RunCMake/find_file/REGISTRY_VIEW-no-view-stderr.txt new file mode 100644 index 0000000..28e3e12 --- /dev/null +++ b/Tests/RunCMake/find_file/REGISTRY_VIEW-no-view-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at REGISTRY_VIEW-no-view.cmake:[0-9]+ \(find_file\): + find_file missing required argument for "REGISTRY_VIEW" +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/find_file/REGISTRY_VIEW-no-view.cmake b/Tests/RunCMake/find_file/REGISTRY_VIEW-no-view.cmake new file mode 100644 index 0000000..fc24f7b --- /dev/null +++ b/Tests/RunCMake/find_file/REGISTRY_VIEW-no-view.cmake @@ -0,0 +1,2 @@ + +find_file(result NAMES input.txt REGISTRY_VIEW) diff --git a/Tests/RunCMake/find_file/REGISTRY_VIEW-wrong-view-result.txt b/Tests/RunCMake/find_file/REGISTRY_VIEW-wrong-view-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_file/REGISTRY_VIEW-wrong-view-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_file/REGISTRY_VIEW-wrong-view-stderr.txt b/Tests/RunCMake/find_file/REGISTRY_VIEW-wrong-view-stderr.txt new file mode 100644 index 0000000..42843f3 --- /dev/null +++ b/Tests/RunCMake/find_file/REGISTRY_VIEW-wrong-view-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at REGISTRY_VIEW-wrong-view.cmake:[0-9]+ \(find_file\): + find_file given invalid value for "REGISTRY_VIEW": WRONG_VIEW +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/find_file/REGISTRY_VIEW-wrong-view.cmake b/Tests/RunCMake/find_file/REGISTRY_VIEW-wrong-view.cmake new file mode 100644 index 0000000..a2c73d6 --- /dev/null +++ b/Tests/RunCMake/find_file/REGISTRY_VIEW-wrong-view.cmake @@ -0,0 +1,2 @@ + +find_file(result NAMES input.txt REGISTRY_VIEW WRONG_VIEW) diff --git a/Tests/RunCMake/find_file/Registry-query.cmake b/Tests/RunCMake/find_file/Registry-query.cmake new file mode 100644 index 0000000..ea2f0f1 --- /dev/null +++ b/Tests/RunCMake/find_file/Registry-query.cmake @@ -0,0 +1,218 @@ + +# helper function for test validation +function(CHECK query result expression) + cmake_language(EVAL CODE + "if (NOT (${expression})) + message(SEND_ERROR \"wrong value for query '${query}': '${result}'\") + endif()") +endfunction() + + +cmake_policy(SET CMP0134 NEW) + +# HKCU/Software/Classes/CLSID/CMake-Tests/find_file: Query default value +set(FILE_DIR "[HKCU/Software/Classes/CLSID/CMake-Tests/find_file]") +set(FILE_DIR2 "[HKCU/Software/Classes/CLSID/CMake-Tests/find_file;(default)]") + +unset(result) +find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result}" "result MATCHES \"default.${ARCH}/file.txt$\"") + +# query value using special name should be identical to default value +unset(result) +find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR2}" REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR2}" "${result}" "result MATCHES \"default.${ARCH}/file.txt$\"") + +unset(result) +find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result}" "result MATCHES \"default.${ARCH}/file.txt$\"") +# VIEW TARGET should have same value as VIEW HOST +unset(result2) +find_file(result2 NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result2}" "result2 STREQUAL result") + +if (ARCH STREQUAL "64bit") + + unset(result) + find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.64bit/file.txt$\"") + + unset(result) + find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file.txt$\"") + + unset(result) + find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.64bit/file.txt$\"") + unset(result) + + find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file.txt$\"") + + # check the second view is taken into account + unset(result) + find_file(result NAMES file32bit.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file32bit.txt$\"") + + unset(result) + find_file(result NAMES file64bit.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.64bit/file64bit.txt$\"") + + # check the both views are taken into account + unset(result) + find_file(result NAMES file32bit.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file32bit.txt$\"") + + unset(result) + find_file(result NAMES file64bit.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.64bit/file64bit.txt$\"") + +else() # 32bit + + # no 64bit registry: file not found + unset(result) + find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"result-NOTFOUND$\"") + + unset(result) + find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file.txt$\"") + + # views 64_32 and 32_64 give same result + unset(result) + find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file.txt$\"") + + unset(result) + find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file.txt$\"") + + # check the both views are usable on 32bit platforms + unset(result) + find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file.txt$\"") + +endif() + +# HKCU/Software/Classes/CLSID/CMake-Tests/find_file: Query specific value +set(FILE_DIR "[{|}HKCU/Software/Classes/CLSID/CMake-Tests/find_file|FILE_DIR]") +set(FILE_DIR2 "[HKCU\\Software\\Classes\\CLSID\\CMake-Tests\\find_file;FILE_DIR]") + +unset(result) +find_file(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.txt$\"") + +# query value using special name should be identical to default value +unset(result) +find_file(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR2}" REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR2}" "${result}" "result MATCHES \"/${ARCH}/file.txt$\"") + +unset(result) +find_file(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.txt$\"") +# VIEW TARGET should have same value as VIEW HOST +unset(result2) +find_file(result2 NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result2}" "result2 STREQUAL result") + +if (ARCH STREQUAL "64bit") + + unset(result) + find_file(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file.txt$\"") + + unset(result) + find_file(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.txt$\"") + + unset(result) + find_file(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file.txt$\"") + unset(result) + + find_file(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.txt$\"") + + # check the second view is taken into account + unset(result) + find_file(result NAMES file32bit.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file32bit.txt$\"") + + unset(result) + find_file(result NAMES file64bit.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file64bit.txt$\"") + + # check the both views are taken into account + unset(result) + find_file(result NAMES file32bit.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file32bit.txt$\"") + + unset(result) + find_file(result NAMES file64bit.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file64bit.txt$\"") + +else() # 32bit + + # no 64bit registry: file not found + unset(result) + find_file(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"result-NOTFOUND$\"") + + unset(result) + find_file(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.txt$\"") + + unset(result) + find_file(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.txt$\"") + + unset(result) + find_file(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.txt$\"") + + # check the both views are taken into account + unset(result) + find_file(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.txt$\"") + +endif() + +if (ARCH STREQUAL "64bit") + + # Check influence of variable CMAKE_SIZEOF_VOID_P + set(CMAKE_SIZEOF_VOID_P 8) + unset(result) + find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file.txt$\"") + + unset(result) + find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.txt$\"") + + + set(CMAKE_SIZEOF_VOID_P 4) + unset(result) + find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.txt$\"") + + unset(result) + find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.txt$\"") + + unset(CMAKE_SIZEOF_VOID_P) + + + # Check influence of CMP0134 policy with OLD value + cmake_policy(SET CMP0134 OLD) + # CMAKE_SIZEOF_VOID_P is not set, so search first 32bit registry + unset(result) + find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.txt$\"") + + cmake_policy(SET CMP0134 NEW) + # CMAKE_SIZEOF_VOID_P is not set, so search first the HOST architecture registry + unset(result) + find_file(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.txt$\"") + +endif() diff --git a/Tests/RunCMake/find_file/RunCMakeTest.cmake b/Tests/RunCMake/find_file/RunCMakeTest.cmake index c5cd5fa..23765d4 100644 --- a/Tests/RunCMake/find_file/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_file/RunCMakeTest.cmake @@ -5,5 +5,33 @@ run_cmake(FromPrefixPath) run_cmake(PrefixInPATH) run_cmake(Required) run_cmake(NO_CACHE) +run_cmake(REGISTRY_VIEW-no-view) +run_cmake(REGISTRY_VIEW-wrong-view) run_cmake_with_options(FromPATHEnvDebugVar --debug-find-var=PrefixInPATH_File) + +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + # Tests using the Windows registry + find_program(REG NAMES "reg.exe" NO_CACHE) + if (REG) + ## check host architecture + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "HKCU" SUBKEYS VIEW 64 ERROR_VARIABLE status) + if (status STREQUAL "") + set(ARCH "64bit") + else() + set(ARCH "32bit") + endif() + + # crete some entries in the registry + cmake_path(CONVERT "${RunCMake_SOURCE_DIR}/registry_host${ARCH}.reg" TO_NATIVE_PATH_LIST registry_data) + execute_process(COMMAND "${REG}" import "${registry_data}" OUTPUT_QUIET ERROR_QUIET) + + run_cmake_with_options(Registry-query -DARCH=${ARCH}) + + # clean-up registry + execute_process(COMMAND "${REG}" delete "HKCU\\SOFTWARE\\Classes\\CLSID\\CMake-Tests\\find_file" /f OUTPUT_QUIET ERROR_QUIET) + if (ARCH STREQUAL "64bit") + execute_process(COMMAND "${REG}" delete "HKCU\\SOFTWARE\\Classes\\WOW6432Node\\CLSID\\CMake-Tests\\find_file" /f OUTPUT_QUIET ERROR_QUIET) + endif() + endif() +endif() diff --git a/Tests/RunCMake/find_file/default.32bit/file.txt b/Tests/RunCMake/find_file/default.32bit/file.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_file/default.32bit/file.txt diff --git a/Tests/RunCMake/find_file/default.32bit/file32bit.txt b/Tests/RunCMake/find_file/default.32bit/file32bit.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_file/default.32bit/file32bit.txt diff --git a/Tests/RunCMake/find_file/default.64bit/file.txt b/Tests/RunCMake/find_file/default.64bit/file.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_file/default.64bit/file.txt diff --git a/Tests/RunCMake/find_file/default.64bit/file64bit.txt b/Tests/RunCMake/find_file/default.64bit/file64bit.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_file/default.64bit/file64bit.txt diff --git a/Tests/RunCMake/find_file/registry_host32bit.reg b/Tests/RunCMake/find_file/registry_host32bit.reg Binary files differnew file mode 100644 index 0000000..2987185 --- /dev/null +++ b/Tests/RunCMake/find_file/registry_host32bit.reg diff --git a/Tests/RunCMake/find_file/registry_host64bit.reg b/Tests/RunCMake/find_file/registry_host64bit.reg Binary files differnew file mode 100644 index 0000000..2d70fa9 --- /dev/null +++ b/Tests/RunCMake/find_file/registry_host64bit.reg diff --git a/Tests/RunCMake/find_library/32bit/file.lib b/Tests/RunCMake/find_library/32bit/file.lib new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_library/32bit/file.lib diff --git a/Tests/RunCMake/find_library/32bit/file32bit.lib b/Tests/RunCMake/find_library/32bit/file32bit.lib new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_library/32bit/file32bit.lib diff --git a/Tests/RunCMake/find_library/64bit/file.lib b/Tests/RunCMake/find_library/64bit/file.lib new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_library/64bit/file.lib diff --git a/Tests/RunCMake/find_library/64bit/file64bit.lib b/Tests/RunCMake/find_library/64bit/file64bit.lib new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_library/64bit/file64bit.lib diff --git a/Tests/RunCMake/find_library/FromPATHEnv-stderr.txt b/Tests/RunCMake/find_library/FromPATHEnv-stderr.txt index a690eec..f367b3f 100644 --- a/Tests/RunCMake/find_library/FromPATHEnv-stderr.txt +++ b/Tests/RunCMake/find_library/FromPATHEnv-stderr.txt @@ -9,6 +9,7 @@ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 0 CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + CMAKE_FIND_USE_INSTALL_PREFIX: 1 find_library considered the following locations:.* The item was not found.* @@ -22,6 +23,7 @@ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1 CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + CMAKE_FIND_USE_INSTALL_PREFIX: 1 find_library considered the following locations:.* The item was found at.* diff --git a/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stderr.txt b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stderr.txt index a690eec..f367b3f 100644 --- a/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stderr.txt +++ b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stderr.txt @@ -9,6 +9,7 @@ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 0 CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + CMAKE_FIND_USE_INSTALL_PREFIX: 1 find_library considered the following locations:.* The item was not found.* @@ -22,6 +23,7 @@ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1 CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + CMAKE_FIND_USE_INSTALL_PREFIX: 1 find_library considered the following locations:.* The item was found at.* diff --git a/Tests/RunCMake/find_library/IgnoreInstallPrefix-stderr.txt b/Tests/RunCMake/find_library/IgnoreInstallPrefix-stderr.txt new file mode 100644 index 0000000..e977374 --- /dev/null +++ b/Tests/RunCMake/find_library/IgnoreInstallPrefix-stderr.txt @@ -0,0 +1,43 @@ + find_library called with the following settings:.* + VAR: CREATED_LIBRARY + NAMES: \"created\" + Documentation.* + Framework.* + AppBundle.* + CMAKE_FIND_USE_CMAKE_PATH: 1 + CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + CMAKE_FIND_USE_INSTALL_PREFIX: 0 + + find_library considered the following locations:.* + The item was not found.* + find_library called with the following settings:.* + VAR: CREATED_LIBRARY + NAMES: \"created\" + Documentation.* + Framework.* + AppBundle.* + CMAKE_FIND_USE_CMAKE_PATH: 1 + CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + CMAKE_FIND_USE_INSTALL_PREFIX: 1 + + find_library considered the following locations:.* + The item was found at.* + .*IgnoreInstallPrefix-build/lib.* + find_library called with the following settings:.* + VAR: CREATED_LIBRARY + NAMES: \"created\" + Documentation.* + Framework.* + AppBundle.* + CMAKE_FIND_USE_CMAKE_PATH: 1 + CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1 + CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + CMAKE_FIND_USE_INSTALL_PREFIX: 0 + + find_library considered the following locations:.* + The item was not found.* diff --git a/Tests/RunCMake/find_library/IgnoreInstallPrefix-stdout.txt b/Tests/RunCMake/find_library/IgnoreInstallPrefix-stdout.txt new file mode 100644 index 0000000..0c28243 --- /dev/null +++ b/Tests/RunCMake/find_library/IgnoreInstallPrefix-stdout.txt @@ -0,0 +1,3 @@ +-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' +-- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/IgnoreInstallPrefix-build/lib/libcreated.a' +-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND' diff --git a/Tests/RunCMake/find_library/IgnoreInstallPrefix.cmake b/Tests/RunCMake/find_library/IgnoreInstallPrefix.cmake new file mode 100644 index 0000000..7ca8bcf --- /dev/null +++ b/Tests/RunCMake/find_library/IgnoreInstallPrefix.cmake @@ -0,0 +1,32 @@ +set(ENV_PATH "$ENV{PATH}") +set(ENV_CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}") +set(ENV{PATH} "") +set(ENV{CMAKE_PREFIX_PATH} "") + +list(APPEND CMAKE_FIND_LIBRARY_PREFIXES lib) +list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .a) + +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/lib/libcreated.a" "created") + +set(CMAKE_FIND_DEBUG_MODE 1) +set(CMAKE_FIND_USE_INSTALL_PREFIX OFF) + +find_library(CREATED_LIBRARY NAMES created) +message(STATUS "CREATED_LIBRARY='${CREATED_LIBRARY}'") + +set(CMAKE_FIND_USE_INSTALL_PREFIX ON) +find_library(CREATED_LIBRARY NAMES created) +message(STATUS "CREATED_LIBRARY='${CREATED_LIBRARY}'") + +unset(CREATED_LIBRARY) +unset(CREATED_LIBRARY CACHE) + +unset(CMAKE_FIND_USE_INSTALL_PREFIX) +find_library(CREATED_LIBRARY NAMES created NO_CMAKE_INSTALL_PREFIX) +message(STATUS "CREATED_LIBRARY='${CREATED_LIBRARY}'") + +set(CMAKE_FIND_DEBUG_MODE 0) + +set(ENV{PATH} "${ENV_PATH}") +set(ENV{CMAKE_PREFIX_PATH} "${ENV_CMAKE_PREFIX_PATH}") diff --git a/Tests/RunCMake/find_library/PrefixInPATH-stderr.txt b/Tests/RunCMake/find_library/PrefixInPATH-stderr.txt index 1d24c84..899b471 100644 --- a/Tests/RunCMake/find_library/PrefixInPATH-stderr.txt +++ b/Tests/RunCMake/find_library/PrefixInPATH-stderr.txt @@ -8,6 +8,7 @@ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1 CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + CMAKE_FIND_USE_INSTALL_PREFIX: 1 find_library considered the following locations:.* .*/does_not_exist.* diff --git a/Tests/RunCMake/find_library/REGISTRY_VIEW-no-view-result.txt b/Tests/RunCMake/find_library/REGISTRY_VIEW-no-view-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_library/REGISTRY_VIEW-no-view-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_library/REGISTRY_VIEW-no-view-stderr.txt b/Tests/RunCMake/find_library/REGISTRY_VIEW-no-view-stderr.txt new file mode 100644 index 0000000..ec1877c --- /dev/null +++ b/Tests/RunCMake/find_library/REGISTRY_VIEW-no-view-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at REGISTRY_VIEW-no-view.cmake:[0-9]+ \(find_library\): + find_library missing required argument for "REGISTRY_VIEW" +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/find_library/REGISTRY_VIEW-no-view.cmake b/Tests/RunCMake/find_library/REGISTRY_VIEW-no-view.cmake new file mode 100644 index 0000000..e87a6c3 --- /dev/null +++ b/Tests/RunCMake/find_library/REGISTRY_VIEW-no-view.cmake @@ -0,0 +1,2 @@ + +find_library(result NAMES input.txt REGISTRY_VIEW) diff --git a/Tests/RunCMake/find_library/REGISTRY_VIEW-wrong-view-result.txt b/Tests/RunCMake/find_library/REGISTRY_VIEW-wrong-view-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_library/REGISTRY_VIEW-wrong-view-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_library/REGISTRY_VIEW-wrong-view-stderr.txt b/Tests/RunCMake/find_library/REGISTRY_VIEW-wrong-view-stderr.txt new file mode 100644 index 0000000..3e7f814 --- /dev/null +++ b/Tests/RunCMake/find_library/REGISTRY_VIEW-wrong-view-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at REGISTRY_VIEW-wrong-view.cmake:[0-9]+ \(find_library\): + find_library given invalid value for "REGISTRY_VIEW": WRONG_VIEW +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/find_library/REGISTRY_VIEW-wrong-view.cmake b/Tests/RunCMake/find_library/REGISTRY_VIEW-wrong-view.cmake new file mode 100644 index 0000000..e4a636a --- /dev/null +++ b/Tests/RunCMake/find_library/REGISTRY_VIEW-wrong-view.cmake @@ -0,0 +1,2 @@ + +find_library(result NAMES input.txt REGISTRY_VIEW WRONG_VIEW) diff --git a/Tests/RunCMake/find_library/Registry-query.cmake b/Tests/RunCMake/find_library/Registry-query.cmake new file mode 100644 index 0000000..22968aa --- /dev/null +++ b/Tests/RunCMake/find_library/Registry-query.cmake @@ -0,0 +1,218 @@ + +# helper function for test validation +function(CHECK query result expression) + cmake_language(EVAL CODE + "if (NOT (${expression})) + message(SEND_ERROR \"wrong value for query '${query}': '${result}'\") + endif()") +endfunction() + +cmake_policy(SET CMP0134 NEW) + +# HKCU/Software/Classes/CLSID/CMake-Tests/find_library: Query default value +set(FILE_DIR "[HKCU/Software/Classes/CLSID/CMake-Tests/find_library]") +set(FILE_DIR2 "[HKCU/Software/Classes/CLSID/CMake-Tests/find_library;(default)]") + +unset(result) +find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result}" "result MATCHES \"default.${ARCH}/file.lib$\"") + +# query value using special name should be identical to default value +unset(result) +find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR2}" REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR2}" "${result}" "result MATCHES \"default.${ARCH}/file.lib$\"") + +unset(result) +find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result}" "result MATCHES \"default.${ARCH}/file.lib$\"") +# VIEW TARGET should have same value as VIEW HOST +unset(result2) +find_library(result2 NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result2}" "result2 STREQUAL result") + +if (ARCH STREQUAL "64bit") + + unset(result) + find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.64bit/file.lib$\"") + + unset(result) + find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file.lib$\"") + + unset(result) + find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.64bit/file.lib$\"") + + unset(result) + find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file.lib$\"") + + # check the second view is taken into account + unset(result) + find_library(result NAMES file32bit.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file32bit.lib$\"") + + unset(result) + find_library(result NAMES file64bit.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.64bit/file64bit.lib$\"") + unset(result) + + # check the both views are taken into account + unset(result) + find_library(result NAMES file32bit.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file32bit.lib$\"") + + unset(result) + find_library(result NAMES file64bit.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.64bit/file64bit.lib$\"") + unset(result) + +else() # 32bit + + # no 64bit registry: file not found + unset(result) + find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"result-NOTFOUND$\"") + + unset(result) + find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file.lib$\"") + + # views 64_32 and 32_64 give same result + unset(result) + find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file.lib$\"") + + unset(result) + find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file.lib$\"") + + # check the both views are usable on 32bit platforms + unset(result) + find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file.lib$\"") + +endif() + +# HKCU/Software/Classes/CLSID/CMake-Tests/find_library: Query specific value +set(FILE_DIR "[{|}HKCU/Software/Classes/CLSID/CMake-Tests/find_library|FILE_DIR]") +set(FILE_DIR2 "[HKCU\\Software\\Classes\\CLSID\\CMake-Tests\\find_library;FILE_DIR]") + +unset(result) +find_library(result NAMES file.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.lib$\"") + +# query value using special name should be identical to default value +unset(result) +find_library(result NAMES file.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR2}" REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR2}" "${result}" "result MATCHES \"/${ARCH}/file.lib$\"") + +unset(result) +find_library(result NAMES file.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.lib$\"") +# VIEW TARGET should have same value as VIEW HOST +unset(result2) +find_library(result2 NAMES file.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result2}" "result2 STREQUAL result") + +if (ARCH STREQUAL "64bit") + + unset(result) + find_library(result NAMES file.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file.lib$\"") + + unset(result) + find_library(result NAMES file.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.lib$\"") + + unset(result) + find_library(result NAMES file.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file.lib$\"") + + unset(result) + find_library(result NAMES file.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.lib$\"") + + # check the second view is taken into account + unset(result) + find_library(result NAMES file32bit.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file32bit.lib$\"") + + unset(result) + find_library(result NAMES file64bit.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file64bit.lib$\"") + + # check the both views are taken into account + unset(result) + find_library(result NAMES file32bit.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file32bit.lib$\"") + + unset(result) + find_library(result NAMES file64bit.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file64bit.lib$\"") + +else() # 32bit + + # no 64bit registry: file not found + unset(result) + find_library(result NAMES file.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"result-NOTFOUND$\"") + + unset(result) + find_library(result NAMES file.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.lib$\"") + + unset(result) + find_library(result NAMES file.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.lib$\"") + + unset(result) + find_library(result NAMES file.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.lib$\"") + + unset(result) + find_library(result NAMES file.lib HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.lib$\"") + +endif() + +if (ARCH STREQUAL "64bit") + + # Check influence of variable CMAKE_SIZEOF_VOID_P + set(CMAKE_SIZEOF_VOID_P 8) + unset(result) + find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file.lib$\"") + + unset(result) + find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.lib$\"") + + + set(CMAKE_SIZEOF_VOID_P 4) + unset(result) + find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.lib$\"") + + unset(result) + find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.lib$\"") + + unset(CMAKE_SIZEOF_VOID_P) + + + # Check influence of CMP0134 policy with OLD value + cmake_policy(SET CMP0134 OLD) + # CMAKE_SIZEOF_VOID_P is not set, so search first 32bit registry + unset(result) + find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.lib$\"") + + cmake_policy(SET CMP0134 NEW) + # CMAKE_SIZEOF_VOID_P is not set, so search first the HOST architecture registry + unset(result) + find_library(result NAMES file.lib PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.lib$\"") + +endif() diff --git a/Tests/RunCMake/find_library/RunCMakeTest.cmake b/Tests/RunCMake/find_library/RunCMakeTest.cmake index eaaecf0..de0ee14 100644 --- a/Tests/RunCMake/find_library/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_library/RunCMakeTest.cmake @@ -3,6 +3,7 @@ include(RunCMake) run_cmake(Created) run_cmake(FromPrefixPath) run_cmake(FromPATHEnv) +run_cmake_with_options(IgnoreInstallPrefix "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/IgnoreInstallPrefix-build/") if(UNIX AND NOT CYGWIN) run_cmake(LibArchLink) run_cmake(LibSymLink) @@ -10,7 +11,35 @@ endif() run_cmake(PrefixInPATH) run_cmake(Required) run_cmake(NO_CACHE) +run_cmake(REGISTRY_VIEW-no-view) +run_cmake(REGISTRY_VIEW-wrong-view) run_cmake_script(FromScriptMode "-DTEMP_DIR=${RunCMake_BINARY_DIR}/FromScriptMode-temp") run_cmake_with_options(FromPATHEnvDebugVar --debug-find-var=CREATED_LIBRARY) + +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + # Tests using the Windows registry + find_program(REG NAMES "reg.exe" NO_CACHE) + if (REG) + ## check host architecture + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "HKCU" SUBKEYS VIEW 64 ERROR_VARIABLE status) + if (status STREQUAL "") + set(ARCH "64bit") + else() + set(ARCH "32bit") + endif() + + # crete some entries in the registry + cmake_path(CONVERT "${RunCMake_SOURCE_DIR}/registry_host${ARCH}.reg" TO_NATIVE_PATH_LIST registry_data) + execute_process(COMMAND "${REG}" import "${registry_data}" OUTPUT_QUIET ERROR_QUIET) + + run_cmake_with_options(Registry-query -DARCH=${ARCH}) + + # clean-up registry + execute_process(COMMAND "${REG}" delete "HKCU\\SOFTWARE\\Classes\\CLSID\\CMake-Tests\\find_library" /f OUTPUT_QUIET ERROR_QUIET) + if (ARCH STREQUAL "64bit") + execute_process(COMMAND "${REG}" delete "HKCU\\SOFTWARE\\Classes\\WOW6432Node\\CLSID\\CMake-Tests\\find_library" /f OUTPUT_QUIET ERROR_QUIET) + endif() + endif() +endif() diff --git a/Tests/RunCMake/find_library/default.32bit/file.lib b/Tests/RunCMake/find_library/default.32bit/file.lib new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_library/default.32bit/file.lib diff --git a/Tests/RunCMake/find_library/default.32bit/file32bit.lib b/Tests/RunCMake/find_library/default.32bit/file32bit.lib new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_library/default.32bit/file32bit.lib diff --git a/Tests/RunCMake/find_library/default.64bit/file.lib b/Tests/RunCMake/find_library/default.64bit/file.lib new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_library/default.64bit/file.lib diff --git a/Tests/RunCMake/find_library/default.64bit/file64bit.lib b/Tests/RunCMake/find_library/default.64bit/file64bit.lib new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_library/default.64bit/file64bit.lib diff --git a/Tests/RunCMake/find_library/registry_host32bit.reg b/Tests/RunCMake/find_library/registry_host32bit.reg Binary files differnew file mode 100644 index 0000000..cf36b34 --- /dev/null +++ b/Tests/RunCMake/find_library/registry_host32bit.reg diff --git a/Tests/RunCMake/find_library/registry_host64bit.reg b/Tests/RunCMake/find_library/registry_host64bit.reg Binary files differnew file mode 100644 index 0000000..8a87c98 --- /dev/null +++ b/Tests/RunCMake/find_library/registry_host64bit.reg diff --git a/Tests/RunCMake/find_package/32bit/RegistryView32Config.cmake b/Tests/RunCMake/find_package/32bit/RegistryView32Config.cmake new file mode 100644 index 0000000..63f9622 --- /dev/null +++ b/Tests/RunCMake/find_package/32bit/RegistryView32Config.cmake @@ -0,0 +1,4 @@ + +if (NOT EXPECTED_LOCATION STREQUAL "32bit") + message (SEND_ERROR "RegistryViewConfig: location is '32bit' but expects '${EXPECTED_LOCATION}'") +endif() diff --git a/Tests/RunCMake/find_package/32bit/RegistryViewConfig.cmake b/Tests/RunCMake/find_package/32bit/RegistryViewConfig.cmake new file mode 100644 index 0000000..63f9622 --- /dev/null +++ b/Tests/RunCMake/find_package/32bit/RegistryViewConfig.cmake @@ -0,0 +1,4 @@ + +if (NOT EXPECTED_LOCATION STREQUAL "32bit") + message (SEND_ERROR "RegistryViewConfig: location is '32bit' but expects '${EXPECTED_LOCATION}'") +endif() diff --git a/Tests/RunCMake/find_package/64bit/RegistryView64Config.cmake b/Tests/RunCMake/find_package/64bit/RegistryView64Config.cmake new file mode 100644 index 0000000..3d64301 --- /dev/null +++ b/Tests/RunCMake/find_package/64bit/RegistryView64Config.cmake @@ -0,0 +1,4 @@ + +if (NOT EXPECTED_LOCATION STREQUAL "64bit") + message (SEND_ERROR "RegistryViewConfig: location is '64bit' but expects '${EXPECTED_LOCATION}'") +endif() diff --git a/Tests/RunCMake/find_package/64bit/RegistryViewConfig.cmake b/Tests/RunCMake/find_package/64bit/RegistryViewConfig.cmake new file mode 100644 index 0000000..3d64301 --- /dev/null +++ b/Tests/RunCMake/find_package/64bit/RegistryViewConfig.cmake @@ -0,0 +1,4 @@ + +if (NOT EXPECTED_LOCATION STREQUAL "64bit") + message (SEND_ERROR "RegistryViewConfig: location is '64bit' but expects '${EXPECTED_LOCATION}'") +endif() diff --git a/Tests/RunCMake/find_package/FindRegistryView.cmake b/Tests/RunCMake/find_package/FindRegistryView.cmake new file mode 100644 index 0000000..e4080a6 --- /dev/null +++ b/Tests/RunCMake/find_package/FindRegistryView.cmake @@ -0,0 +1,11 @@ + +if (EXPECTED_REGISTRY_VIEW STREQUAL "UNDEFINED") + if (DEFINED ${CMAKE_FIND_PACKAGE_NAME}_FIND_REGISTRY_VIEW) + message(SEND_ERROR "${CMAKE_FIND_PACKAGE_NAME}_FIND_REGISTRY_VIEW: unexpectedly defined as '${${CMAKE_FIND_PACKAGE_NAME}_FIND_REGISTRY_VIEW}' instead of '${EXPECTED_REGISTRY_VIEW}'") + endif() + return() +endif() + +if (NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_REGISTRY_VIEW STREQUAL EXPECTED_REGISTRY_VIEW) + message(SEND_ERROR "${CMAKE_FIND_PACKAGE_NAME}_FIND_REGISTRY_VIEW: '${${CMAKE_FIND_PACKAGE_NAME}_FIND_REGISTRY_VIEW}' instead of '${EXPECTED_REGISTRY_VIEW}'") +endif() diff --git a/Tests/RunCMake/find_package/FromPATHEnv-stderr.txt b/Tests/RunCMake/find_package/FromPATHEnv-stderr.txt index 691d7f0..fdf098d 100644 --- a/Tests/RunCMake/find_package/FromPATHEnv-stderr.txt +++ b/Tests/RunCMake/find_package/FromPATHEnv-stderr.txt @@ -6,6 +6,11 @@ The file was not found. + The internally managed CMAKE_FIND_PACKAGE_REDIRECTS_DIR. + + [^ +]*/Tests/RunCMake/find_package/FromPATHEnv-build/CMakeFiles/pkgRedirects + <PackageName>_ROOT CMake variable \[CMAKE_FIND_USE_PACKAGE_ROOT_PATH\]. none @@ -69,6 +74,10 @@ module: [^ +]*/Tests/RunCMake/find_package/FromPATHEnv-build/CMakeFiles/pkgRedirects/ResolvedConfig.cmake + [^ +]*/Tests/RunCMake/find_package/FromPATHEnv-build/CMakeFiles/pkgRedirects/resolved-config.cmake + [^ ]*/Tests/RunCMake/find_package/PackageRoot/ResolvedConfig.cmake The file was found at diff --git a/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stderr.txt b/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stderr.txt index ef5ec33..5140616 100644 --- a/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stderr.txt +++ b/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stderr.txt @@ -6,6 +6,11 @@ The file was not found. + The internally managed CMAKE_FIND_PACKAGE_REDIRECTS_DIR. + + [^ +]*/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-build/CMakeFiles/pkgRedirects + <PackageName>_ROOT CMake variable \[CMAKE_FIND_USE_PACKAGE_ROOT_PATH\]. none @@ -69,6 +74,10 @@ module: [^ +]*/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-build/CMakeFiles/pkgRedirects/ResolvedConfig.cmake + [^ +]*/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-build/CMakeFiles/pkgRedirects/resolved-config.cmake + [^ ]*/Tests/RunCMake/find_package/PackageRoot/ResolvedConfig.cmake The file was found at 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/IgnoreInstallPrefix.cmake b/Tests/RunCMake/find_package/IgnoreInstallPrefix.cmake new file mode 100644 index 0000000..ee40d88 --- /dev/null +++ b/Tests/RunCMake/find_package/IgnoreInstallPrefix.cmake @@ -0,0 +1,17 @@ + +find_package(Bar QUIET CONFIG NO_CMAKE_INSTALL_PREFIX) +if(Bar_FOUND) + message(SEND_ERROR "Bar should not be found, was found in ${Bar_DIR}") +endif() + +set(CMAKE_FIND_USE_INSTALL_PREFIX OFF) +find_package(Bar QUIET CONFIG) +if(Bar_FOUND) + message(SEND_ERROR "Bar should not be found, was found in ${Bar_DIR}") +endif() + +set(CMAKE_FIND_USE_INSTALL_PREFIX ON) +find_package(Bar QUIET CONFIG) +if(NOT Bar_FOUND) + message(SEND_ERROR "Bar should be found via CMAKE_INSTALL_PREFIX") +endif() diff --git a/Tests/RunCMake/find_package/ModuleModeDebugPkg-stderr.txt b/Tests/RunCMake/find_package/ModuleModeDebugPkg-stderr.txt index e4fd7c5..9757803 100644 --- a/Tests/RunCMake/find_package/ModuleModeDebugPkg-stderr.txt +++ b/Tests/RunCMake/find_package/ModuleModeDebugPkg-stderr.txt @@ -97,6 +97,11 @@ Call Stack \(most recent call first\): FindBar processed here. + CMake Debug Log at ModuleModeDebugPkg/FindFoo.cmake:[0-9]+ \(find_package\): + The internally managed CMAKE_FIND_PACKAGE_REDIRECTS_DIR. + + [^ +]*/Tests/RunCMake/find_package/ModuleModeDebugPkg-build/CMakeFiles/pkgRedirects + Paths specified by the find_package HINTS option. none @@ -107,6 +112,11 @@ CMake Debug Log at ModuleModeDebugPkg/FindFoo.cmake:[0-9]+ \(find_package\): find_package considered the following locations for Zot's Config module: + [^ +]*/Tests/RunCMake/find_package/ModuleModeDebugPkg-build/CMakeFiles/pkgRedirects/ZotConfig.cmake + [^ +]*/Tests/RunCMake/find_package/ModuleModeDebugPkg-build/CMakeFiles/pkgRedirects/zot-config.cmake + The file was not found. Call Stack \(most recent call first\): 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/REGISTRY_VIEW-no-view-result.txt b/Tests/RunCMake/find_package/REGISTRY_VIEW-no-view-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_package/REGISTRY_VIEW-no-view-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_package/REGISTRY_VIEW-no-view-stderr.txt b/Tests/RunCMake/find_package/REGISTRY_VIEW-no-view-stderr.txt new file mode 100644 index 0000000..9dbcc93 --- /dev/null +++ b/Tests/RunCMake/find_package/REGISTRY_VIEW-no-view-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at REGISTRY_VIEW-no-view.cmake:[0-9]+ \(find_package\): + find_package missing required argument for "REGISTRY_VIEW" +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/find_package/REGISTRY_VIEW-no-view.cmake b/Tests/RunCMake/find_package/REGISTRY_VIEW-no-view.cmake new file mode 100644 index 0000000..866cc54 --- /dev/null +++ b/Tests/RunCMake/find_package/REGISTRY_VIEW-no-view.cmake @@ -0,0 +1,2 @@ + +find_package(result NAMES input.txt REGISTRY_VIEW) diff --git a/Tests/RunCMake/find_package/REGISTRY_VIEW-propagated.cmake b/Tests/RunCMake/find_package/REGISTRY_VIEW-propagated.cmake new file mode 100644 index 0000000..8d8fec7 --- /dev/null +++ b/Tests/RunCMake/find_package/REGISTRY_VIEW-propagated.cmake @@ -0,0 +1,16 @@ + +set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") + +# when REGISTRY_VIEW is not specified, should not be defined in module +set (EXPECTED_REGISTRY_VIEW "UNDEFINED") +find_package(RegistryView) + +# query package to check if variable is propagated correctly +set(EXPECTED_REGISTRY_VIEW "TARGET") +find_package(RegistryView REGISTRY_VIEW TARGET) + +set(EXPECTED_REGISTRY_VIEW "64_32") +find_package(RegistryView REGISTRY_VIEW 64_32) + +set(EXPECTED_REGISTRY_VIEW "32") +find_package(RegistryView REGISTRY_VIEW 32) diff --git a/Tests/RunCMake/find_package/REGISTRY_VIEW-wrong-view-result.txt b/Tests/RunCMake/find_package/REGISTRY_VIEW-wrong-view-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_package/REGISTRY_VIEW-wrong-view-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_package/REGISTRY_VIEW-wrong-view-stderr.txt b/Tests/RunCMake/find_package/REGISTRY_VIEW-wrong-view-stderr.txt new file mode 100644 index 0000000..e65af62 --- /dev/null +++ b/Tests/RunCMake/find_package/REGISTRY_VIEW-wrong-view-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at REGISTRY_VIEW-wrong-view.cmake:[0-9]+ \(find_package\): + find_package given invalid value for "REGISTRY_VIEW": WRONG_VIEW +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/find_package/REGISTRY_VIEW-wrong-view.cmake b/Tests/RunCMake/find_package/REGISTRY_VIEW-wrong-view.cmake new file mode 100644 index 0000000..e2aff3cf --- /dev/null +++ b/Tests/RunCMake/find_package/REGISTRY_VIEW-wrong-view.cmake @@ -0,0 +1,2 @@ + +find_package(result NAMES input.txt REGISTRY_VIEW WRONG_VIEW) diff --git a/Tests/RunCMake/find_package/Registry-query.cmake b/Tests/RunCMake/find_package/Registry-query.cmake new file mode 100644 index 0000000..181c479 --- /dev/null +++ b/Tests/RunCMake/find_package/Registry-query.cmake @@ -0,0 +1,216 @@ + +# helper macro for test clean-up +macro(CLEAN) + unset(RegistryView_DIR CACHE) + unset(RegistryView_FOUND) + unset(RegistryView64_DIR CACHE) + unset(RegistryView64_FOUND) + unset(RegistryView32_DIR CACHE) + unset(RegistryView32_FOUND) +endmacro() + + +cmake_policy(SET CMP0134 NEW) + +# HKCU/Software/Classes/CLSID/CMake-Tests/find_package: Query default value +set(FILE_DIR "[HKCU/Software/Classes/CLSID/CMake-Tests/find_package]") +set(FILE_DIR2 "[HKCU/Software/Classes/CLSID/CMake-Tests/find_package;(default)]") + +set(EXPECTED_LOCATION "default.${ARCH}") + +find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_DEFAULT_PATH) +clean() + +# query value using special name should be identical to default value +find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR2}" REQUIRED NO_DEFAULT_PATH) +clean() + +find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_DEFAULT_PATH) +clean() + +# VIEW TARGET should have same value as VIEW HOST +find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_DEFAULT_PATH) +clean() + +if (ARCH STREQUAL "64bit") + + set(EXPECTED_LOCATION "default.64bit") + find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 REQUIRED NO_DEFAULT_PATH) + clean() + + set(EXPECTED_LOCATION "default.32bit") + find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_DEFAULT_PATH) + clean() + + set(EXPECTED_LOCATION "default.64bit") + find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_DEFAULT_PATH) + clean() + + set(EXPECTED_LOCATION "default.32bit") + find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_DEFAULT_PATH) + clean() + + # check the second view is taken into account + set(EXPECTED_LOCATION "default.32bit") + find_package(RegistryView32 PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_DEFAULT_PATH) + clean() + + set(EXPECTED_LOCATION "default.64bit") + find_package(RegistryView64 PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_DEFAULT_PATH) + clean() + + # check the both views are taken into account + set(EXPECTED_LOCATION "default.32bit") + find_package(RegistryView32 PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_DEFAULT_PATH) + clean() + + set(EXPECTED_LOCATION "default.64bit") + find_package(RegistryView64 PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_DEFAULT_PATH) + clean() + +else() # 32bit + + # no 64bit registry: file not found + find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 NO_DEFAULT_PATH) + if (RegistryView_FOUND) + message (SEND_ERROR "Unexpectedly found file '${RegistryView_DIR}/RegistryViewConfog.cmake'") + endif() + clean() + + set(EXPECTED_LOCATION "default.32bit") + + find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_DEFAULT_PATH) + clean() + + # views 64_32 and 32_64 give same result + find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_DEFAULT_PATH) + clean() + + find_package(RegistryView PATHS "${CMAKE_ CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_DEFAULT_PATH) + clean() + + # check the both views are usable on 32bit platforms + find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_DEFAULT_PATH) + clean() + +endif() + + +# HKCU/Software/Classes/CLSID/CMake-Tests/find_package: Query specific value +set(FILE_DIR "[{|}HKCU/Software/Classes/CLSID/CMake-Tests/find_package|FILE_DIR]") +set(FILE_DIR2 "[HKCU\\Software\\Classes\\CLSID\\CMake-Tests\\find_package;FILE_DIR]") + +set(EXPECTED_LOCATION "${ARCH}") + +find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_DEFAULT_PATH) +clean() + +# query value using special name should be identical to default value +find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR2}" REQUIRED NO_DEFAULT_PATH) +clean() + +find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_DEFAULT_PATH) +clean() +# VIEW TARGET should have same value as VIEW HOST +find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_DEFAULT_PATH) +clean() + +if (ARCH STREQUAL "64bit") + + set(EXPECTED_LOCATION "64bit") + find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 REQUIRED NO_DEFAULT_PATH) + clean() + + set(EXPECTED_LOCATION "32bit") + find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_DEFAULT_PATH) + clean() + + set(EXPECTED_LOCATION "64bit") + find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_DEFAULT_PATH) + clean() + + set(EXPECTED_LOCATION "32bit") + find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_DEFAULT_PATH) + clean() + + # check the second view is taken into account + find_package(RegistryView32 HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_DEFAULT_PATH) + clean() + + set(EXPECTED_LOCATION "64bit") + find_package(RegistryView64 HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_DEFAULT_PATH) + clean() + + # check the both views are taken into account + set(EXPECTED_LOCATION "32bit") + find_package(RegistryView32 HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_DEFAULT_PATH) + clean() + + set(EXPECTED_LOCATION "64bit") + find_package(RegistryView64 NAMES HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_DEFAULT_PATH) + clean() + +else() # 32bit + + # no 64bit registry: file not found + find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 NO_DEFAULT_PATH) + if (RegistryView_FOUND) + message (SEND_ERROR "Unexpectedly found file '${RegistryView_DIR}/RegistryViewConfog.cmake'") + endif() + clean() + + set(EXPECTED_LOCATION "32bit") + + find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_DEFAULT_PATH) + clean() + + find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_DEFAULT_PATH) + clean() + + find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_DEFAULT_PATH) + clean() + + # check the both views are taken into account + find_package(RegistryView HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_DEFAULT_PATH) + clean() + +endif() + +if (ARCH STREQUAL "64bit") + + # Check influence of variable CMAKE_SIZEOF_VOID_P + set(CMAKE_SIZEOF_VOID_P 8) + set(EXPECTED_LOCATION "64bit") + find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET) + clean() + + find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST) + clean() + + + set(CMAKE_SIZEOF_VOID_P 4) + set(EXPECTED_LOCATION "32bit") + find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET) + clean() + + set(EXPECTED_LOCATION "64bit") + find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST) + clean() + + unset(CMAKE_SIZEOF_VOID_P) + + + # Check influence of CMP0134 policy with OLD value + cmake_policy(SET CMP0134 OLD) + # CMAKE_SIZEOF_VOID_P is not set, so search first 32bit registry + set(EXPECTED_LOCATION "32bit") + find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}") + clean() + + cmake_policy(SET CMP0134 NEW) + # CMAKE_SIZEOF_VOID_P is not set, so search first the HOST architecture registry + set(EXPECTED_LOCATION "64bit") + find_package(RegistryView PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}") + clean() + +endif() diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake index 5f4c6cb..32e54d5 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) @@ -47,10 +48,41 @@ run_cmake(VersionRangeConfig2) run_cmake(VersionRangeConfig02) run_cmake(VersionRangeConfigStd) run_cmake(VersionRangeConfigStd2) +run_cmake_with_options(IgnoreInstallPrefix "-DCMAKE_INSTALL_PREFIX=${RunCMake_SOURCE_DIR}/PackageRoot/foo/cmake_root") run_cmake(IgnorePath) run_cmake(IgnorePrefixPath) +run_cmake(REGISTRY_VIEW-no-view) +run_cmake(REGISTRY_VIEW-wrong-view) +run_cmake(REGISTRY_VIEW-propagated) + if(UNIX AND NOT MSYS # FIXME: This works on CYGWIN but not on MSYS ) run_cmake(SetFoundResolved) endif() + +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + # Tests using the Windows registry + find_program(REG NAMES "reg.exe" NO_CACHE) + if (REG) + ## check host architecture + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "HKCU" SUBKEYS VIEW 64 ERROR_VARIABLE status) + if (status STREQUAL "") + set(ARCH "64bit") + else() + set(ARCH "32bit") + endif() + + # crete some entries in the registry + cmake_path(CONVERT "${RunCMake_SOURCE_DIR}/registry_host${ARCH}.reg" TO_NATIVE_PATH_LIST registry_data) + execute_process(COMMAND "${REG}" import "${registry_data}" OUTPUT_QUIET ERROR_QUIET) + + run_cmake_with_options(Registry-query -DARCH=${ARCH}) + + # clean-up registry + execute_process(COMMAND "${REG}" delete "HKCU\\SOFTWARE\\Classes\\CLSID\\CMake-Tests\\find_package" /f OUTPUT_QUIET ERROR_QUIET) + if (ARCH STREQUAL "64bit") + execute_process(COMMAND "${REG}" delete "HKCU\\SOFTWARE\\Classes\\WOW6432Node\\CLSID\\CMake-Tests\\find_package" /f OUTPUT_QUIET ERROR_QUIET) + endif() + endif() +endif() diff --git a/Tests/RunCMake/find_package/default.32bit/RegistryView32Config.cmake b/Tests/RunCMake/find_package/default.32bit/RegistryView32Config.cmake new file mode 100644 index 0000000..8d13254 --- /dev/null +++ b/Tests/RunCMake/find_package/default.32bit/RegistryView32Config.cmake @@ -0,0 +1,4 @@ + +if (NOT EXPECTED_LOCATION STREQUAL "default.32bit") + message (SEND_ERROR "RegistryViewConfig: location is 'default.32bit' but expects '${EXPECTED_LOCATION}'") +endif() diff --git a/Tests/RunCMake/find_package/default.32bit/RegistryViewConfig.cmake b/Tests/RunCMake/find_package/default.32bit/RegistryViewConfig.cmake new file mode 100644 index 0000000..8d13254 --- /dev/null +++ b/Tests/RunCMake/find_package/default.32bit/RegistryViewConfig.cmake @@ -0,0 +1,4 @@ + +if (NOT EXPECTED_LOCATION STREQUAL "default.32bit") + message (SEND_ERROR "RegistryViewConfig: location is 'default.32bit' but expects '${EXPECTED_LOCATION}'") +endif() diff --git a/Tests/RunCMake/find_package/default.64bit/RegistryView64Config.cmake b/Tests/RunCMake/find_package/default.64bit/RegistryView64Config.cmake new file mode 100644 index 0000000..1d3d78c --- /dev/null +++ b/Tests/RunCMake/find_package/default.64bit/RegistryView64Config.cmake @@ -0,0 +1,4 @@ + +if (NOT EXPECTED_LOCATION STREQUAL "default.64bit") + message (SEND_ERROR "RegistryViewConfig: location is 'default.64bit' but expects '${EXPECTED_LOCATION}'") +endif() diff --git a/Tests/RunCMake/find_package/default.64bit/RegistryViewConfig.cmake b/Tests/RunCMake/find_package/default.64bit/RegistryViewConfig.cmake new file mode 100644 index 0000000..1d3d78c --- /dev/null +++ b/Tests/RunCMake/find_package/default.64bit/RegistryViewConfig.cmake @@ -0,0 +1,4 @@ + +if (NOT EXPECTED_LOCATION STREQUAL "default.64bit") + message (SEND_ERROR "RegistryViewConfig: location is 'default.64bit' but expects '${EXPECTED_LOCATION}'") +endif() diff --git a/Tests/RunCMake/find_package/registry_host32bit.reg b/Tests/RunCMake/find_package/registry_host32bit.reg Binary files differnew file mode 100644 index 0000000..3b2fb50 --- /dev/null +++ b/Tests/RunCMake/find_package/registry_host32bit.reg diff --git a/Tests/RunCMake/find_package/registry_host64bit.reg b/Tests/RunCMake/find_package/registry_host64bit.reg Binary files differnew file mode 100644 index 0000000..07eb9b7 --- /dev/null +++ b/Tests/RunCMake/find_package/registry_host64bit.reg diff --git a/Tests/RunCMake/find_path/32bit/file.txt b/Tests/RunCMake/find_path/32bit/file.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_path/32bit/file.txt diff --git a/Tests/RunCMake/find_path/32bit/file32bit.txt b/Tests/RunCMake/find_path/32bit/file32bit.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_path/32bit/file32bit.txt diff --git a/Tests/RunCMake/find_path/64bit/file.txt b/Tests/RunCMake/find_path/64bit/file.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_path/64bit/file.txt diff --git a/Tests/RunCMake/find_path/64bit/file64bit.txt b/Tests/RunCMake/find_path/64bit/file64bit.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_path/64bit/file64bit.txt diff --git a/Tests/RunCMake/find_path/FromPATHEnv-stderr.txt b/Tests/RunCMake/find_path/FromPATHEnv-stderr.txt index 088efd5..9340c7a 100644 --- a/Tests/RunCMake/find_path/FromPATHEnv-stderr.txt +++ b/Tests/RunCMake/find_path/FromPATHEnv-stderr.txt @@ -8,6 +8,7 @@ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 0 CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + CMAKE_FIND_USE_INSTALL_PREFIX: 1 find_path considered the following locations:.* The item was not found.* @@ -21,6 +22,7 @@ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1 CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + CMAKE_FIND_USE_INSTALL_PREFIX: 1 find_path considered the following locations:.* The item was found at.* diff --git a/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stderr.txt b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stderr.txt index 088efd5..9340c7a 100644 --- a/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stderr.txt +++ b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stderr.txt @@ -8,6 +8,7 @@ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 0 CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + CMAKE_FIND_USE_INSTALL_PREFIX: 1 find_path considered the following locations:.* The item was not found.* @@ -21,6 +22,7 @@ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1 CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + CMAKE_FIND_USE_INSTALL_PREFIX: 1 find_path considered the following locations:.* The item was found at.* diff --git a/Tests/RunCMake/find_path/REGISTRY_VIEW-no-view-result.txt b/Tests/RunCMake/find_path/REGISTRY_VIEW-no-view-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_path/REGISTRY_VIEW-no-view-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_path/REGISTRY_VIEW-no-view-stderr.txt b/Tests/RunCMake/find_path/REGISTRY_VIEW-no-view-stderr.txt new file mode 100644 index 0000000..662d2d3 --- /dev/null +++ b/Tests/RunCMake/find_path/REGISTRY_VIEW-no-view-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at REGISTRY_VIEW-no-view.cmake:[0-9]+ \(find_path\): + find_path missing required argument for "REGISTRY_VIEW" +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/find_path/REGISTRY_VIEW-no-view.cmake b/Tests/RunCMake/find_path/REGISTRY_VIEW-no-view.cmake new file mode 100644 index 0000000..e76d9dc --- /dev/null +++ b/Tests/RunCMake/find_path/REGISTRY_VIEW-no-view.cmake @@ -0,0 +1,2 @@ + +find_path(result NAMES input.txt REGISTRY_VIEW) diff --git a/Tests/RunCMake/find_path/REGISTRY_VIEW-wrong-view-result.txt b/Tests/RunCMake/find_path/REGISTRY_VIEW-wrong-view-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_path/REGISTRY_VIEW-wrong-view-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_path/REGISTRY_VIEW-wrong-view-stderr.txt b/Tests/RunCMake/find_path/REGISTRY_VIEW-wrong-view-stderr.txt new file mode 100644 index 0000000..075d6af --- /dev/null +++ b/Tests/RunCMake/find_path/REGISTRY_VIEW-wrong-view-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at REGISTRY_VIEW-wrong-view.cmake:[0-9]+ \(find_path\): + find_path given invalid value for "REGISTRY_VIEW": WRONG_VIEW +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/find_path/REGISTRY_VIEW-wrong-view.cmake b/Tests/RunCMake/find_path/REGISTRY_VIEW-wrong-view.cmake new file mode 100644 index 0000000..9f46538 --- /dev/null +++ b/Tests/RunCMake/find_path/REGISTRY_VIEW-wrong-view.cmake @@ -0,0 +1,2 @@ + +find_path(result NAMES input.txt REGISTRY_VIEW WRONG_VIEW) diff --git a/Tests/RunCMake/find_path/Registry-query.cmake b/Tests/RunCMake/find_path/Registry-query.cmake new file mode 100644 index 0000000..6d26cd0 --- /dev/null +++ b/Tests/RunCMake/find_path/Registry-query.cmake @@ -0,0 +1,218 @@ + +# helper function for test validation +function(CHECK query result expression) + cmake_language(EVAL CODE + "if (NOT (${expression})) + message(SEND_ERROR \"wrong value for query '${query}': '${result}'\") + endif()") +endfunction() + +cmake_policy(SET CMP0134 NEW) + +# HKCU/Software/Classes/CLSID/CMake-Tests/find_path: Query default value +set(FILE_DIR "[HKCU/Software/Classes/CLSID/CMake-Tests/find_path]") +set(FILE_DIR2 "[HKCU/Software/Classes/CLSID/CMake-Tests/find_path;(default)]") + +unset(result) +find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result}" "result MATCHES \"default.${ARCH}/$\"") + +# query value using special name should be identical to default value +unset(result) +find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR2}" REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR2}" "${result}" "result MATCHES \"default.${ARCH}/$\"") + +unset(result) +find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result}" "result MATCHES \"default.${ARCH}/$\"") +# VIEW TARGET should have same value as VIEW HOST +unset(result2) +find_path(result2 NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result2}" "result2 STREQUAL result") + +if (ARCH STREQUAL "64bit") + + unset(result) + find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.64bit/$\"") + + unset(result) + find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/$\"") + + unset(result) + find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.64bit/$\"") + unset(result) + + find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/$\"") + + # check the second view is taken into account + unset(result) + find_path(result NAMES file32bit.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/$\"") + + unset(result) + find_path(result NAMES file64bit.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.64bit/$\"") + + # check the both views are taken into account + unset(result) + find_path(result NAMES file32bit.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/$\"") + + unset(result) + find_path(result NAMES file64bit.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.64bit/$\"") + +else() # 32bit + + # no 64bit registry: file not found + unset(result) + find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"result-NOTFOUND$\"") + + unset(result) + find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/$\"") + + # views 64_32 and 32_64 give same result + unset(result) + find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/$\"") + + unset(result) + find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/$\"") + + # check the both views are usable on 32bit platforms + unset(result) + find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/$\"") + +endif() + + +# HKCU/Software/Classes/CLSID/CMake-Tests/find_path: Query specific value +set(FILE_DIR "[{|}HKCU/Software/Classes/CLSID/CMake-Tests/find_path|FILE_DIR]") +set(FILE_DIR2 "[HKCU\\Software\\Classes\\CLSID\\CMake-Tests\\find_path;FILE_DIR]") + +unset(result) +find_path(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" NO_CACHE REQUIRED NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/$\"") + +# query value using special name should be identical to default value +unset(result) +find_path(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR2}" NO_CACHE REQUIRED NO_DEFAULT_PATH) +check("${FILE_DIR2}" "${result}" "result MATCHES \"/${ARCH}/$\"") + +unset(result) +find_path(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/$\"") +# VIEW TARGET should have same value as VIEW HOST +unset(result2) +find_path(result2 NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result2}" "result2 STREQUAL result") + +if (ARCH STREQUAL "64bit") + +unset(result) +find_path(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/$\"") + +unset(result) +find_path(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/$\"") + +unset(result) +find_path(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/$\"") + +unset(result) +find_path(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/$\"") + +# check the second view is taken into account +unset(result) +find_path(result NAMES file32bit.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/$\"") + +unset(result) +find_path(result NAMES file64bit.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/$\"") + +# check the both views are taken into account +unset(result) +find_path(result NAMES file32bit.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/$\"") + +unset(result) +find_path(result NAMES file64bit.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/$\"") + +else() # 32bit + + # no 64bit registry: file not found + unset(result) + find_path(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"result-NOTFOUND$\"") + + unset(result) + find_path(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/$\"") + + unset(result) + find_path(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/$\"") + + unset(result) + find_path(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/$\"") + + unset(result) + find_path(result NAMES file.txt HINTS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/$\"") + +endif() + + +if (ARCH STREQUAL "64bit") + + # Check influence of variable CMAKE_SIZEOF_VOID_P + set(CMAKE_SIZEOF_VOID_P 8) + unset(result) + find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/$\"") + + unset(result) + find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/$\"") + + + set(CMAKE_SIZEOF_VOID_P 4) + unset(result) + find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/$\"") + + unset(result) + find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/$\"") + + unset(CMAKE_SIZEOF_VOID_P) + + + # Check influence of CMP0134 policy with OLD value + cmake_policy(SET CMP0134 OLD) + # CMAKE_SIZEOF_VOID_P is not set, so search first 32bit registry + unset(result) + find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" NO_CACHE REQUIRED NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/$\"") + + cmake_policy(SET CMP0134 NEW) + # CMAKE_SIZEOF_VOID_P is not set, so search first the HOST architecture registry + unset(result) + find_path(result NAMES file.txt PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" NO_CACHE REQUIRED NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/$\"") + +endif() diff --git a/Tests/RunCMake/find_path/RunCMakeTest.cmake b/Tests/RunCMake/find_path/RunCMakeTest.cmake index 5b52f90..63cadc2 100644 --- a/Tests/RunCMake/find_path/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_path/RunCMakeTest.cmake @@ -5,9 +5,37 @@ run_cmake(FromPATHEnv) run_cmake(PrefixInPATH) run_cmake(Required) run_cmake(NO_CACHE) +run_cmake(REGISTRY_VIEW-no-view) +run_cmake(REGISTRY_VIEW-wrong-view) if(APPLE) run_cmake(FrameworksWithSubdirs) endif() run_cmake_with_options(FromPATHEnvDebugVar --debug-find-var=PATH_IN_ENV_PATH) + +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + # Tests using the Windows registry + find_program(REG NAMES "reg.exe" NO_CACHE) + if (REG) + ## check host architecture + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "HKCU" SUBKEYS VIEW 64 ERROR_VARIABLE status) + if (status STREQUAL "") + set(ARCH "64bit") + else() + set(ARCH "32bit") + endif() + + # crete some entries in the registry + cmake_path(CONVERT "${RunCMake_SOURCE_DIR}/registry_host${ARCH}.reg" TO_NATIVE_PATH_LIST registry_data) + execute_process(COMMAND "${REG}" import "${registry_data}" OUTPUT_QUIET ERROR_QUIET) + + run_cmake_with_options(Registry-query -DARCH=${ARCH}) + + # clean-up registry + execute_process(COMMAND "${REG}" delete "HKCU\\SOFTWARE\\Classes\\CLSID\\CMake-Tests\\find_path" /f OUTPUT_QUIET ERROR_QUIET) + if (ARCH STREQUAL "64bit") + execute_process(COMMAND "${REG}" delete "HKCU\\SOFTWARE\\Classes\\WOW6432Node\\CLSID\\CMake-Tests\\find_path" /f OUTPUT_QUIET ERROR_QUIET) + endif() + endif() +endif() diff --git a/Tests/RunCMake/find_path/default.32bit/file.txt b/Tests/RunCMake/find_path/default.32bit/file.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_path/default.32bit/file.txt diff --git a/Tests/RunCMake/find_path/default.32bit/file32bit.txt b/Tests/RunCMake/find_path/default.32bit/file32bit.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_path/default.32bit/file32bit.txt diff --git a/Tests/RunCMake/find_path/default.64bit/file.txt b/Tests/RunCMake/find_path/default.64bit/file.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_path/default.64bit/file.txt diff --git a/Tests/RunCMake/find_path/default.64bit/file64bit.txt b/Tests/RunCMake/find_path/default.64bit/file64bit.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_path/default.64bit/file64bit.txt diff --git a/Tests/RunCMake/find_path/registry_host32bit.reg b/Tests/RunCMake/find_path/registry_host32bit.reg Binary files differnew file mode 100644 index 0000000..a56d79c --- /dev/null +++ b/Tests/RunCMake/find_path/registry_host32bit.reg diff --git a/Tests/RunCMake/find_path/registry_host64bit.reg b/Tests/RunCMake/find_path/registry_host64bit.reg Binary files differnew file mode 100644 index 0000000..705b073 --- /dev/null +++ b/Tests/RunCMake/find_path/registry_host64bit.reg diff --git a/Tests/RunCMake/find_program/32bit/file.exe b/Tests/RunCMake/find_program/32bit/file.exe new file mode 100755 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_program/32bit/file.exe diff --git a/Tests/RunCMake/find_program/32bit/file32bit.exe b/Tests/RunCMake/find_program/32bit/file32bit.exe new file mode 100755 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_program/32bit/file32bit.exe diff --git a/Tests/RunCMake/find_program/64bit/file.exe b/Tests/RunCMake/find_program/64bit/file.exe new file mode 100755 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_program/64bit/file.exe diff --git a/Tests/RunCMake/find_program/64bit/file64bit.exe b/Tests/RunCMake/find_program/64bit/file64bit.exe new file mode 100755 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_program/64bit/file64bit.exe diff --git a/Tests/RunCMake/find_program/EnvAndHints-stderr.txt b/Tests/RunCMake/find_program/EnvAndHints-stderr.txt index 8951345..83263e4 100644 --- a/Tests/RunCMake/find_program/EnvAndHints-stderr.txt +++ b/Tests/RunCMake/find_program/EnvAndHints-stderr.txt @@ -8,6 +8,7 @@ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1 CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + CMAKE_FIND_USE_INSTALL_PREFIX: 1 find_program considered the following locations:.* The item was found at.* @@ -23,6 +24,7 @@ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 0 CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + CMAKE_FIND_USE_INSTALL_PREFIX: 1 find_program considered the following locations:.* The item was not found.* diff --git a/Tests/RunCMake/find_program/EnvAndHintsDebugVar-stderr.txt b/Tests/RunCMake/find_program/EnvAndHintsDebugVar-stderr.txt index 8951345..83263e4 100644 --- a/Tests/RunCMake/find_program/EnvAndHintsDebugVar-stderr.txt +++ b/Tests/RunCMake/find_program/EnvAndHintsDebugVar-stderr.txt @@ -8,6 +8,7 @@ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1 CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + CMAKE_FIND_USE_INSTALL_PREFIX: 1 find_program considered the following locations:.* The item was found at.* @@ -23,6 +24,7 @@ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1 CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 0 CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1 + CMAKE_FIND_USE_INSTALL_PREFIX: 1 find_program considered the following locations:.* The item was not found.* diff --git a/Tests/RunCMake/find_program/REGISTRY_VIEW-no-view-result.txt b/Tests/RunCMake/find_program/REGISTRY_VIEW-no-view-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_program/REGISTRY_VIEW-no-view-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_program/REGISTRY_VIEW-no-view-stderr.txt b/Tests/RunCMake/find_program/REGISTRY_VIEW-no-view-stderr.txt new file mode 100644 index 0000000..dbe38a1 --- /dev/null +++ b/Tests/RunCMake/find_program/REGISTRY_VIEW-no-view-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at REGISTRY_VIEW-no-view.cmake:[0-9]+ \(find_program\): + find_program missing required argument for "REGISTRY_VIEW" +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/find_program/REGISTRY_VIEW-no-view.cmake b/Tests/RunCMake/find_program/REGISTRY_VIEW-no-view.cmake new file mode 100644 index 0000000..1dc6659 --- /dev/null +++ b/Tests/RunCMake/find_program/REGISTRY_VIEW-no-view.cmake @@ -0,0 +1,2 @@ + +find_program(result NAMES input.txt REGISTRY_VIEW) diff --git a/Tests/RunCMake/find_program/REGISTRY_VIEW-wrong-view-result.txt b/Tests/RunCMake/find_program/REGISTRY_VIEW-wrong-view-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_program/REGISTRY_VIEW-wrong-view-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_program/REGISTRY_VIEW-wrong-view-stderr.txt b/Tests/RunCMake/find_program/REGISTRY_VIEW-wrong-view-stderr.txt new file mode 100644 index 0000000..de07095 --- /dev/null +++ b/Tests/RunCMake/find_program/REGISTRY_VIEW-wrong-view-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at REGISTRY_VIEW-wrong-view.cmake:[0-9]+ \(find_program\): + find_program given invalid value for "REGISTRY_VIEW": WRONG_VIEW +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/find_program/REGISTRY_VIEW-wrong-view.cmake b/Tests/RunCMake/find_program/REGISTRY_VIEW-wrong-view.cmake new file mode 100644 index 0000000..110fd9a --- /dev/null +++ b/Tests/RunCMake/find_program/REGISTRY_VIEW-wrong-view.cmake @@ -0,0 +1,2 @@ + +find_program(result NAMES input.txt REGISTRY_VIEW WRONG_VIEW) diff --git a/Tests/RunCMake/find_program/Registry-query.cmake b/Tests/RunCMake/find_program/Registry-query.cmake new file mode 100644 index 0000000..0e1f2a5 --- /dev/null +++ b/Tests/RunCMake/find_program/Registry-query.cmake @@ -0,0 +1,236 @@ + +# helper function for test validation +function(CHECK query result expression) + cmake_language(EVAL CODE + "if (NOT (${expression})) + message(SEND_ERROR \"wrong value for query '${query}': '${result}'\") + endif()") +endfunction() + + +cmake_policy(SET CMP0134 NEW) + +# HKCU/Software/Classes/CLSID/CMake-Tests/find_program: Query default value +set(FILE_DIR "[HKCU/Software/Classes/CLSID/CMake-Tests/find_program]") +set(FILE_DIR2 "[HKCU/Software/Classes/CLSID/CMake-Tests/find_program;(default)]") + +unset(result) +find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result}" "result MATCHES \"default.${ARCH}/file.exe$\"") + +# query value using special name should be identical to default value +unset(result) +find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR2}" REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR2}" "${result}" "result MATCHES \"default.${ARCH}/file.exe$\"") + +unset(result) +find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result}" "result MATCHES \"default.${ARCH}/file.exe$\"") +# VIEW TARGET should have same value as VIEW HOST +unset(result2) +find_program(result2 NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result2}" "result2 STREQUAL result") + +if (ARCH STREQUAL "64bit") + + # default view is BOTH so querying any value specific to 32 or 64bit must be found + unset(result) + find_program(result NAMES file64bit.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.64bit/file64bit.exe$\"") + + unset(result) + find_program(result NAMES file32bit.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file32bit.exe$\"") + + unset(result) + find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.64bit/file.exe$\"") + + unset(result) + find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file.exe$\"") + + unset(result) + find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.64bit/file.exe$\"") + unset(result) + + find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file.exe$\"") + + # check the second view is taken into account + unset(result) + find_program(result NAMES file32bit.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file32bit.exe$\"") + + unset(result) + find_program(result NAMES file64bit.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.64bit/file64bit.exe$\"") + + # check the both views are taken into account + unset(result) + find_program(result NAMES file32bit.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file32bit.exe$\"") + + unset(result) + find_program(result NAMES file64bit.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.64bit/file64bit.exe$\"") + +else() # 32bit + + # no 64bit registry: file not found + unset(result) + find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"result-NOTFOUND$\"") + + unset(result) + find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file.exe$\"") + + # views 64_32 and 32_64 give same result + unset(result) + find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file.exe$\"") + + unset(result) + find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file.exe$\"") + + # check the both views are usable on 32bit platforms + unset(result) + find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"default.32bit/file.exe$\"") + +endif() + +# HKCU/Software/Classes/CLSID/CMake-Tests/find_program: Query specific value +set(FILE_DIR "[{|}HKCU/Software/Classes/CLSID/CMake-Tests/find_program|FILE_DIR]") +set(FILE_DIR2 "[HKCU\\Software\\Classes\\CLSID\\CMake-Tests\\find_program;FILE_DIR]") + +unset(result) +find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.exe$\"") + +# query value using special name should be identical to default value +unset(result) +find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR2}" REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR2}" "${result}" "result MATCHES \"/${ARCH}/file.exe$\"") + +unset(result) +find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.exe$\"") +# VIEW TARGET should have same value as VIEW HOST +unset(result2) +find_program(result2 NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH) +check("${FILE_DIR}" "${result2}" "result2 STREQUAL result") + +if (ARCH STREQUAL "64bit") + + # default view is BOTH so querying any value specific to 32 or 64bit must be found + unset(result) + find_program(result NAMES file64bit.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file64bit.exe$\"") + + unset(result) + find_program(result NAMES file32bit.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file32bit.exe$\"") + + unset(result) + find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file.exe$\"") + + unset(result) + find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.exe$\"") + + unset(result) + find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file.exe$\"") + unset(result) + + find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.exe$\"") + + # check the second view is taken into account + unset(result) + find_program(result NAMES file32bit.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file32bit.exe$\"") + + unset(result) + find_program(result NAMES file64bit.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file64bit.exe$\"") + + # check the both views are taken into account + unset(result) + find_program(result NAMES file32bit.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file32bit.exe$\"") + + unset(result) + find_program(result NAMES file64bit.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file64bit.exe$\"") + +else() # 32bit + + # no 64bit registry: file not found + unset(result) + find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64 NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"result-NOTFOUND$\"") + + unset(result) + find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.exe$\"") + + unset(result) + find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 64_32 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.exe$\"") + + unset(result) + find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW 32_64 REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.exe$\"") + + # check the both views are taken into account + unset(result) + find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW BOTH REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.exe$\"") + +endif() + +if (ARCH STREQUAL "64bit") + + # Check influence of variable CMAKE_SIZEOF_VOID_P + set(CMAKE_SIZEOF_VOID_P 8) + unset(result) + find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/64bit/file.exe$\"") + + unset(result) + find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.exe$\"") + + + set(CMAKE_SIZEOF_VOID_P 4) + unset(result) + find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW TARGET REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.exe$\"") + + unset(result) + find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" REGISTRY_VIEW HOST REQUIRED NO_CACHE NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.exe$\"") + + unset(CMAKE_SIZEOF_VOID_P) + + + # Check influence of CMP0134 policy with OLD value + cmake_policy(SET CMP0134 OLD) + # CMAKE_SIZEOF_VOID_P is not set, so search first 32bit registry + unset(result) + find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" NO_CACHE REQUIRED NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/32bit/file.exe$\"") + + cmake_policy(SET CMP0134 NEW) + # CMAKE_SIZEOF_VOID_P is not set, so search first the HOST architecture registry + unset(result) + find_program(result NAMES file.exe PATHS "${CMAKE_CURRENT_SOURCE_DIR}/${FILE_DIR}" NO_CACHE REQUIRED NO_DEFAULT_PATH) + check("${FILE_DIR}" "${result}" "result MATCHES \"/${ARCH}/file.exe$\"") + +endif() diff --git a/Tests/RunCMake/find_program/RunCMakeTest.cmake b/Tests/RunCMake/find_program/RunCMakeTest.cmake index c2c07af..d0ce8fc 100644 --- a/Tests/RunCMake/find_program/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_program/RunCMakeTest.cmake @@ -7,6 +7,8 @@ run_cmake(RelAndAbsPath) run_cmake(Required) run_cmake(NO_CACHE) run_cmake(IgnorePrefixPath) +run_cmake(REGISTRY_VIEW-no-view) +run_cmake(REGISTRY_VIEW-wrong-view) if(CMAKE_SYSTEM_NAME MATCHES "^(Windows|CYGWIN|MSYS)$") run_cmake(WindowsCom) @@ -30,3 +32,29 @@ if(APPLE) endif() run_cmake_with_options(EnvAndHintsDebugVar --debug-find-var=PROG) + +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + # Tests using the Windows registry + find_program(REG NAMES "reg.exe" NO_CACHE) + if (REG) + ## check host architecture + cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "HKCU" SUBKEYS VIEW 64 ERROR_VARIABLE status) + if (status STREQUAL "") + set(ARCH "64bit") + else() + set(ARCH "32bit") + endif() + + # crete some entries in the registry + cmake_path(CONVERT "${RunCMake_SOURCE_DIR}/registry_host${ARCH}.reg" TO_NATIVE_PATH_LIST registry_data) + execute_process(COMMAND "${REG}" import "${registry_data}" OUTPUT_QUIET ERROR_QUIET) + + run_cmake_with_options(Registry-query -DARCH=${ARCH}) + + # clean-up registry + execute_process(COMMAND "${REG}" delete "HKCU\\SOFTWARE\\Classes\\CLSID\\CMake-Tests\\find_program" /f OUTPUT_QUIET ERROR_QUIET) + if (ARCH STREQUAL "64bit") + execute_process(COMMAND "${REG}" delete "HKCU\\SOFTWARE\\Classes\\WOW6432Node\\CLSID\\CMake-Tests\\find_program" /f OUTPUT_QUIET ERROR_QUIET) + endif() + endif() +endif() diff --git a/Tests/RunCMake/find_program/default.32bit/file.exe b/Tests/RunCMake/find_program/default.32bit/file.exe new file mode 100755 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_program/default.32bit/file.exe diff --git a/Tests/RunCMake/find_program/default.32bit/file32bit.exe b/Tests/RunCMake/find_program/default.32bit/file32bit.exe new file mode 100755 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_program/default.32bit/file32bit.exe diff --git a/Tests/RunCMake/find_program/default.64bit/file.exe b/Tests/RunCMake/find_program/default.64bit/file.exe new file mode 100755 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_program/default.64bit/file.exe diff --git a/Tests/RunCMake/find_program/default.64bit/file64bit.exe b/Tests/RunCMake/find_program/default.64bit/file64bit.exe new file mode 100755 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_program/default.64bit/file64bit.exe diff --git a/Tests/RunCMake/find_program/registry_host32bit.reg b/Tests/RunCMake/find_program/registry_host32bit.reg Binary files differnew file mode 100644 index 0000000..4c904c9 --- /dev/null +++ b/Tests/RunCMake/find_program/registry_host32bit.reg diff --git a/Tests/RunCMake/find_program/registry_host64bit.reg b/Tests/RunCMake/find_program/registry_host64bit.reg Binary files differnew file mode 100644 index 0000000..1a8fe54 --- /dev/null +++ b/Tests/RunCMake/find_program/registry_host64bit.reg diff --git a/Tests/RunCMake/install/EXPORT-TargetTwice-check.cmake b/Tests/RunCMake/install/EXPORT-TargetTwice-check.cmake index 97677ca..f1438dd 100644 --- a/Tests/RunCMake/install/EXPORT-TargetTwice-check.cmake +++ b/Tests/RunCMake/install/EXPORT-TargetTwice-check.cmake @@ -1,4 +1,4 @@ -set(pkg1_cmake "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/Export/pkg1/pkg1.cmake") +set(pkg1_cmake "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/Export/59965f5e1aafdb63698f8ae505daf864/pkg1.cmake") file(STRINGS "${pkg1_cmake}" pkg1_includes REGEX INTERFACE_INCLUDE_DIRECTORIES) set(pkg1_expect [[INTERFACE_INCLUDE_DIRECTORIES "\${_IMPORT_PREFIX}/pkg1/inc"]]) if(NOT pkg1_includes MATCHES "${pkg1_expect}") @@ -8,7 +8,7 @@ It does not match: ${pkg1_expect}") endif() -set(pkg2_cmake "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/Export/pkg2/pkg2.cmake") +set(pkg2_cmake "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/Export/72c00a5f9d34b6649110956cfc9f27e6/pkg2.cmake") file(STRINGS "${pkg2_cmake}" pkg2_includes REGEX INTERFACE_INCLUDE_DIRECTORIES) set(pkg2_expect [[INTERFACE_INCLUDE_DIRECTORIES "\${_IMPORT_PREFIX}/pkg2/inc"]]) if(NOT pkg2_includes MATCHES "${pkg2_expect}") diff --git a/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-all-check.cmake b/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-all-check.cmake index 48d8e1a..0b5fb8d 100644 --- a/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-all-check.cmake +++ b/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-all-check.cmake @@ -1 +1 @@ -check_installed([[^empty1.txt;empty2.txt$]]) +check_installed([[^empty1.txt;empty3.txt$]]) diff --git a/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-dev-check.cmake b/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-dev-check.cmake index 48d8e1a..88e57e3 100644 --- a/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-dev-check.cmake +++ b/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-dev-check.cmake @@ -1 +1 @@ -check_installed([[^empty1.txt;empty2.txt$]]) +check_installed([[^empty1.txt;empty2.txt;empty3.txt$]]) diff --git a/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-uns-check.cmake b/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-uns-check.cmake index 48d8e1a..88e57e3 100644 --- a/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-uns-check.cmake +++ b/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-uns-check.cmake @@ -1 +1 @@ -check_installed([[^empty1.txt;empty2.txt$]]) +check_installed([[^empty1.txt;empty2.txt;empty3.txt$]]) diff --git a/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS.cmake b/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS.cmake index aa3f9d1..73c4e35 100644 --- a/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS.cmake +++ b/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS.cmake @@ -1,5 +1,16 @@ + install( SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/install_script.cmake" + ALL_COMPONENTS +) + +install( CODE "write_empty_file(empty2.txt)" ALL_COMPONENTS - ) + EXCLUDE_FROM_ALL +) + +install( + CODE "write_empty_file(empty3.txt)" + ALL_COMPONENTS +) 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/no_install_prefix/RunCMakeTest.cmake b/Tests/RunCMake/no_install_prefix/RunCMakeTest.cmake index 2923449..eb0ff23 100644 --- a/Tests/RunCMake/no_install_prefix/RunCMakeTest.cmake +++ b/Tests/RunCMake/no_install_prefix/RunCMakeTest.cmake @@ -11,5 +11,5 @@ run_cmake(with_install_prefix) file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/prefix") file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/prefix/NoPrefix") file(WRITE "${RunCMake_BINARY_DIR}/prefix/NoPrefix/NoPrefixConfig.cmake" "") -list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_FIND_NO_INSTALL_PREFIX=1") +list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_FIND_NO_INSTALL_PREFIX=1" "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_BINARY_DIR}/prefix") run_cmake(no_install_prefix) diff --git a/Tests/RunCMake/no_install_prefix/do_test.cmake b/Tests/RunCMake/no_install_prefix/do_test.cmake index 340c7dc..ce94b50 100644 --- a/Tests/RunCMake/no_install_prefix/do_test.cmake +++ b/Tests/RunCMake/no_install_prefix/do_test.cmake @@ -1,2 +1,16 @@ +find_package(NoPrefix NO_CMAKE_INSTALL_PREFIX) +if(NoPrefix_FOUND) + message(FATAL_ERROR "Should not find package when NO_CMAKE_INSTALL_PREFIX specified") +endif() + +set(CMAKE_FIND_USE_INSTALL_PREFIX ON) +find_package(NoPrefix) +if(NOT NoPrefix_FOUND) + message(FATAL_ERROR "Should always find package when CMAKE_FIND_USE_INSTALL_PREFIX is enabled") +endif() + +unset(CMAKE_FIND_USE_INSTALL_PREFIX) +unset(NoPrefix_DIR CACHE) + find_package(NoPrefix REQUIRED) diff --git a/Tests/RunCMake/no_install_prefix/no_install_prefix-stderr.txt b/Tests/RunCMake/no_install_prefix/no_install_prefix-stderr.txt index 66c6241..52bd094 100644 --- a/Tests/RunCMake/no_install_prefix/no_install_prefix-stderr.txt +++ b/Tests/RunCMake/no_install_prefix/no_install_prefix-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at do_test.cmake:2 \(find_package\): +CMake Error at do_test.cmake:16 \(find_package\): By not providing "FindNoPrefix.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "NoPrefix", but CMake did not find one. 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/CodeInjection-stdout.txt b/Tests/RunCMake/project/CodeInjection-stdout.txt new file mode 100644 index 0000000..88ac966 --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection-stdout.txt @@ -0,0 +1,10 @@ +(-- )?Included CMAKE_PROJECT_INCLUDE_BEFORE +(-- )?Included CMAKE_TOOLCHAIN_FILE +.*Included CMAKE_PROJECT_TOP_LEVEL_INCLUDES first file +(-- )?Included CMAKE_PROJECT_TOP_LEVEL_INCLUDES second file +(-- )?Included CMAKE_PROJECT_INCLUDE +(-- )?Calling sub-project +(-- )?Included CMAKE_PROJECT_INCLUDE_BEFORE +(-- )?Included CMAKE_PROJECT_SubProj_INCLUDE_BEFORE +(-- )?Included CMAKE_PROJECT_INCLUDE +(-- )?Included CMAKE_PROJECT_SubProj_INCLUDE diff --git a/Tests/RunCMake/project/CodeInjection.cmake b/Tests/RunCMake/project/CodeInjection.cmake new file mode 100644 index 0000000..dcf56a1 --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection.cmake @@ -0,0 +1 @@ +add_subdirectory(CodeInjection) diff --git a/Tests/RunCMake/project/CodeInjection/CMakeLists.txt b/Tests/RunCMake/project/CodeInjection/CMakeLists.txt new file mode 100644 index 0000000..8ee99d0 --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/CMakeLists.txt @@ -0,0 +1,2 @@ +message(STATUS "Calling sub-project") +project(SubProj LANGUAGES NONE) diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_include.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_include.cmake new file mode 100644 index 0000000..f3f0a7e --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/cmake_project_include.cmake @@ -0,0 +1 @@ +message(STATUS "Included CMAKE_PROJECT_INCLUDE") diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_include_before.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_include_before.cmake new file mode 100644 index 0000000..01d53c9 --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/cmake_project_include_before.cmake @@ -0,0 +1 @@ +message(STATUS "Included CMAKE_PROJECT_INCLUDE_BEFORE") diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include.cmake new file mode 100644 index 0000000..d68de6a --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include.cmake @@ -0,0 +1 @@ +message(STATUS "Included CMAKE_PROJECT_SubProj_INCLUDE") diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include_before.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include_before.cmake new file mode 100644 index 0000000..ef3bfc0 --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include_before.cmake @@ -0,0 +1 @@ +message(STATUS "Included CMAKE_PROJECT_SubProj_INCLUDE_BEFORE") diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_top_level_includes_1.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_top_level_includes_1.cmake new file mode 100644 index 0000000..73ad037 --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/cmake_project_top_level_includes_1.cmake @@ -0,0 +1 @@ +message(STATUS "Included CMAKE_PROJECT_TOP_LEVEL_INCLUDES first file") diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_top_level_includes_2.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_top_level_includes_2.cmake new file mode 100644 index 0000000..80f9705 --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/cmake_project_top_level_includes_2.cmake @@ -0,0 +1 @@ +message(STATUS "Included CMAKE_PROJECT_TOP_LEVEL_INCLUDES second file") diff --git a/Tests/RunCMake/project/CodeInjection/initial_cache.cmake b/Tests/RunCMake/project/CodeInjection/initial_cache.cmake new file mode 100644 index 0000000..6c8995b --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/initial_cache.cmake @@ -0,0 +1,10 @@ +set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/passthrough_toolchain_file.cmake" CACHE FILEPATH "") +set(CMAKE_PROJECT_INCLUDE "${CMAKE_CURRENT_LIST_DIR}/cmake_project_include.cmake" CACHE FILEPATH "") +set(CMAKE_PROJECT_INCLUDE_BEFORE "${CMAKE_CURRENT_LIST_DIR}/cmake_project_include_before.cmake" CACHE FILEPATH "") +set(CMAKE_PROJECT_SubProj_INCLUDE "${CMAKE_CURRENT_LIST_DIR}/cmake_project_subproj_include.cmake" CACHE FILEPATH "") +set(CMAKE_PROJECT_SubProj_INCLUDE_BEFORE "${CMAKE_CURRENT_LIST_DIR}/cmake_project_subproj_include_before.cmake" CACHE FILEPATH "") +set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES + "${CMAKE_CURRENT_LIST_DIR}/cmake_project_top_level_includes_1.cmake" + "${CMAKE_CURRENT_LIST_DIR}/cmake_project_top_level_includes_2.cmake" + CACHE STRING "" +) diff --git a/Tests/RunCMake/project/CodeInjection/passthrough_toolchain_file.cmake b/Tests/RunCMake/project/CodeInjection/passthrough_toolchain_file.cmake new file mode 100644 index 0000000..d045712 --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/passthrough_toolchain_file.cmake @@ -0,0 +1 @@ +message(STATUS "Included CMAKE_TOOLCHAIN_FILE") diff --git a/Tests/RunCMake/project/LanguagesUsedButNotEnabled-result.txt b/Tests/RunCMake/project/LanguagesUsedButNotEnabled-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/project/LanguagesUsedButNotEnabled-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/project/LanguagesUsedButNotEnabled-stderr.txt b/Tests/RunCMake/project/LanguagesUsedButNotEnabled-stderr.txt new file mode 100644 index 0000000..bf9157b --- /dev/null +++ b/Tests/RunCMake/project/LanguagesUsedButNotEnabled-stderr.txt @@ -0,0 +1,4 @@ +CMake Error in CMakeLists.txt: + The language CXX was requested for compilation but was not enabled. To + enable a language it needs to be specified in a 'project' or + 'enable_language' command in the root CMakeLists.txt diff --git a/Tests/RunCMake/project/LanguagesUsedButNotEnabled.cmake b/Tests/RunCMake/project/LanguagesUsedButNotEnabled.cmake new file mode 100644 index 0000000..caab687 --- /dev/null +++ b/Tests/RunCMake/project/LanguagesUsedButNotEnabled.cmake @@ -0,0 +1,3 @@ + +add_executable(UsesCXXLang empty.cxx) +set_source_files_properties(empty.cxx PROPERTIES GENERATED TRUE LANGUAGE CXX ) diff --git a/Tests/RunCMake/project/RunCMakeTest.cmake b/Tests/RunCMake/project/RunCMakeTest.cmake index 349e8ac..945d9ed 100644 --- a/Tests/RunCMake/project/RunCMakeTest.cmake +++ b/Tests/RunCMake/project/RunCMakeTest.cmake @@ -1,5 +1,14 @@ include(RunCMake) +# Use an initial cache file to define the project() variables +# to avoid long command lines. Also see the CMakeOnly test case +# which tests some of the individual variables one at a time. +# Here, we are focused on testing that the variables are all injected +# at the expected points in the expected order. +run_cmake_with_options(CodeInjection + -C "${CMAKE_CURRENT_LIST_DIR}/CodeInjection/initial_cache.cmake" +) + if(CMake_TEST_RESOURCES) run_cmake(ExplicitRC) endif() @@ -8,6 +17,9 @@ run_cmake(LanguagesEmpty) run_cmake(LanguagesNONE) run_cmake(LanguagesTwice) run_cmake(LanguagesUnordered) +if(RunCMake_GENERATOR MATCHES "Make|Ninja") + run_cmake(LanguagesUsedButNotEnabled) +endif() run_cmake(ProjectDescription) run_cmake(ProjectDescription2) run_cmake(ProjectDescriptionNoArg) 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/FileSetImport.cmake b/Tests/RunCMake/target_sources/FileSetImport.cmake index 8ef8e7d..db82ca8 100644 --- a/Tests/RunCMake/target_sources/FileSetImport.cmake +++ b/Tests/RunCMake/target_sources/FileSetImport.cmake @@ -17,12 +17,15 @@ include("${export_build_dir}/export.cmake") include("${export_build_dir}/install/lib/cmake/export.cmake") assert_prop_eq(export::lib1 HEADER_SETS "") -assert_prop_eq(export::lib1 INTERFACE_HEADER_SETS "HEADERS;b;c;d;dir3;e;f;g") +assert_prop_eq(export::lib1 INTERFACE_HEADER_SETS "HEADERS;b;c;d;e;f;g;dir3") assert_prop_eq(export::lib1 HEADER_SET "${CMAKE_CURRENT_SOURCE_DIR}/error.c") +assert_prop_eq(export::lib1 HEADER_SET_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/error.c") if (_multi_config) assert_prop_eq(export::lib1 HEADER_DIRS "${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_SOURCE_DIR}") + assert_prop_eq(export::lib1 HEADER_DIRS_HEADERS "${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_SOURCE_DIR}") else () assert_prop_eq(export::lib1 HEADER_DIRS "${CMAKE_CURRENT_SOURCE_DIR}") + assert_prop_eq(export::lib1 HEADER_DIRS_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}") endif () assert_prop_eq(export::lib1 HEADER_SET_b "${CMAKE_CURRENT_SOURCE_DIR}/h2.h") if (_multi_config) @@ -69,9 +72,11 @@ else () endif () assert_prop_eq(install::lib1 HEADER_SETS "") -assert_prop_eq(install::lib1 INTERFACE_HEADER_SETS "HEADERS;b;c;d;dir3;e;f;g") +assert_prop_eq(install::lib1 INTERFACE_HEADER_SETS "HEADERS;b;c;d;e;f;g;dir3") assert_prop_eq(install::lib1 HEADER_SET "${export_build_dir}/install/include/error.c") assert_prop_eq(install::lib1 HEADER_DIRS "${export_build_dir}/install/include") +assert_prop_eq(install::lib1 HEADER_SET_HEADERS "${export_build_dir}/install/include/error.c") +assert_prop_eq(install::lib1 HEADER_DIRS_HEADERS "${export_build_dir}/install/include") assert_prop_eq(install::lib1 HEADER_SET_b "${export_build_dir}/install/include/h2.h") assert_prop_eq(install::lib1 HEADER_DIRS_b "${export_build_dir}/install/include") assert_prop_eq(install::lib1 HEADER_SET_c "${export_build_dir}/install/include/dir/dir.h") diff --git a/Tests/RunCMake/target_sources/FileSetProperties.cmake b/Tests/RunCMake/target_sources/FileSetProperties.cmake index 74487fe..56cce08 100644 --- a/Tests/RunCMake/target_sources/FileSetProperties.cmake +++ b/Tests/RunCMake/target_sources/FileSetProperties.cmake @@ -57,15 +57,19 @@ assert_prop_eq(lib1 INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURC assert_prop_eq(lib1 INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>") target_sources(lib1 PUBLIC FILE_SET HEADERS BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" FILES h1.h) -assert_prop_eq(lib1 INTERFACE_HEADER_SETS "HEADERS;a;c;d") +assert_prop_eq(lib1 INTERFACE_HEADER_SETS "a;c;d;HEADERS") assert_prop_eq(lib1 HEADER_DIRS "${CMAKE_CURRENT_SOURCE_DIR}") assert_prop_eq(lib1 HEADER_SET "${CMAKE_CURRENT_SOURCE_DIR}/h1.h") +assert_prop_eq(lib1 HEADER_DIRS_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}") +assert_prop_eq(lib1 HEADER_SET_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/h1.h") assert_prop_eq(lib1 INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/dir>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>") assert_prop_eq(lib1 INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>") target_sources(lib1 PUBLIC FILE_SET HEADERS FILES h2.h) -assert_prop_eq(lib1 INTERFACE_HEADER_SETS "HEADERS;a;c;d") +assert_prop_eq(lib1 INTERFACE_HEADER_SETS "a;c;d;HEADERS") assert_prop_eq(lib1 HEADER_DIRS "${CMAKE_CURRENT_SOURCE_DIR}") assert_prop_eq(lib1 HEADER_SET "${CMAKE_CURRENT_SOURCE_DIR}/h1.h;${CMAKE_CURRENT_SOURCE_DIR}/h2.h") +assert_prop_eq(lib1 HEADER_DIRS_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}") +assert_prop_eq(lib1 HEADER_SET_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/h1.h;${CMAKE_CURRENT_SOURCE_DIR}/h2.h") assert_prop_eq(lib1 INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/dir>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>") assert_prop_eq(lib1 INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>") diff --git a/Tests/RunCMake/try_compile/CMP0137-Common.cmake b/Tests/RunCMake/try_compile/CMP0137-Common.cmake new file mode 100644 index 0000000..2c1bc0d --- /dev/null +++ b/Tests/RunCMake/try_compile/CMP0137-Common.cmake @@ -0,0 +1,16 @@ +set(CMAKE_ENABLE_EXPORTS 1) +set(FOO 2) +set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES FOO) +try_compile(RESULT_VAR + ${CMAKE_CURRENT_BINARY_DIR}/CMP0137-build + ${CMAKE_CURRENT_SOURCE_DIR}/CMP0137 + TestCMP0137) +include(${CMAKE_CURRENT_BINARY_DIR}/CMP0137-build/info.cmake OPTIONAL) + +message(STATUS "Enabling CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES") +set(CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES 1) +try_compile(RESULT_VAR + ${CMAKE_CURRENT_BINARY_DIR}/CMP0137-build2 + ${CMAKE_CURRENT_SOURCE_DIR}/CMP0137 + TestCMP0137) +include(${CMAKE_CURRENT_BINARY_DIR}/CMP0137-build2/info.cmake OPTIONAL) diff --git a/Tests/RunCMake/try_compile/CMP0137-NEW-stdout.txt b/Tests/RunCMake/try_compile/CMP0137-NEW-stdout.txt new file mode 100644 index 0000000..abc61dc --- /dev/null +++ b/Tests/RunCMake/try_compile/CMP0137-NEW-stdout.txt @@ -0,0 +1,5 @@ +-- CMAKE_ENABLE_EXPORTS='1' +-- FOO='2' +-- Enabling CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES +-- CMAKE_ENABLE_EXPORTS='' +-- FOO='' diff --git a/Tests/RunCMake/try_compile/CMP0137-NEW.cmake b/Tests/RunCMake/try_compile/CMP0137-NEW.cmake new file mode 100644 index 0000000..f7caa50 --- /dev/null +++ b/Tests/RunCMake/try_compile/CMP0137-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0137 NEW) +include(CMP0137-Common.cmake) diff --git a/Tests/RunCMake/try_compile/CMP0137-WARN-stdout.txt b/Tests/RunCMake/try_compile/CMP0137-WARN-stdout.txt new file mode 100644 index 0000000..2e4bebe --- /dev/null +++ b/Tests/RunCMake/try_compile/CMP0137-WARN-stdout.txt @@ -0,0 +1,5 @@ +-- CMAKE_ENABLE_EXPORTS='' +-- FOO='' +-- Enabling CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES +-- CMAKE_ENABLE_EXPORTS='' +-- FOO='' diff --git a/Tests/RunCMake/try_compile/CMP0137-WARN.cmake b/Tests/RunCMake/try_compile/CMP0137-WARN.cmake new file mode 100644 index 0000000..61b5641 --- /dev/null +++ b/Tests/RunCMake/try_compile/CMP0137-WARN.cmake @@ -0,0 +1,2 @@ +# policy CMP0137 not set +include(CMP0137-Common.cmake) diff --git a/Tests/RunCMake/try_compile/CMP0137/CMakeLists.txt b/Tests/RunCMake/try_compile/CMP0137/CMakeLists.txt new file mode 100644 index 0000000..a3b9fda --- /dev/null +++ b/Tests/RunCMake/try_compile/CMP0137/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.23) +project(TestCMP0137 NONE) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/info.cmake" " +message(STATUS \"CMAKE_ENABLE_EXPORTS='${CMAKE_ENABLE_EXPORTS}'\") +message(STATUS \"FOO='${FOO}'\") +") diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index dcd3799..eca7bf4 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -72,6 +72,8 @@ endif() run_cmake(CMP0056) run_cmake(CMP0066) run_cmake(CMP0067) +run_cmake(CMP0137-WARN) +run_cmake(CMP0137-NEW) if(RunCMake_GENERATOR MATCHES "Make|Ninja") # Use a single build tree for a few tests without cleaning. 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) |