diff options
author | Brad King <brad.king@kitware.com> | 2023-12-12 14:52:34 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-01-03 21:20:24 (GMT) |
commit | bd31a35899bec834e941fb145bf700d43751ff5d (patch) | |
tree | 3271576cbd73bfd9e334f282ab4af4978cfccd02 /Tests/RunCMake/ParseImplicitLinkInfo | |
parent | edb10c53256a4c308548af298eafc9ddf90b3bda (diff) | |
download | CMake-bd31a35899bec834e941fb145bf700d43751ff5d.zip CMake-bd31a35899bec834e941fb145bf700d43751ff5d.tar.gz CMake-bd31a35899bec834e941fb145bf700d43751ff5d.tar.bz2 |
Tests: Add unit tests for internal cmake_determine_linker_id helper
Diffstat (limited to 'Tests/RunCMake/ParseImplicitLinkInfo')
27 files changed, 106 insertions, 0 deletions
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/DetermineLinkerId.cmake b/Tests/RunCMake/ParseImplicitLinkInfo/DetermineLinkerId.cmake new file mode 100644 index 0000000..b6caf6c --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/DetermineLinkerId.cmake @@ -0,0 +1,36 @@ +include(${CMAKE_ROOT}/Modules/Internal/CMakeDetermineLinkerId.cmake) + +set(tools + aix7.3-ld + debian12-ld.bfd + debian12-ld.gold + debian12-ld.lld + debian12-ld.mold + fedora39-ld.gold + fedora39-ld.lld + fedora39-ld.mold + msvc14.36-link + sunos5.11-ld + xcode15.1-ld + ) + +foreach(tool IN LISTS tools) + block() + include(${CMAKE_CURRENT_LIST_DIR}/ld-v/${tool}.cmake OPTIONAL) + cmake_determine_linker_id(C ${CMAKE_CURRENT_LIST_DIR}/ld-v/${tool}.bash) + file(STRINGS ${CMAKE_CURRENT_LIST_DIR}/ld-v/${tool}.txt results) + foreach(result IN LISTS results) + if(result MATCHES "^([A-Z_]+)='([^']*)'") + set(expect_var "${CMAKE_MATCH_1}") + set(expect_val "${CMAKE_MATCH_2}") + if(NOT "x${${expect_var}}" STREQUAL "x${expect_val}") + message(SEND_ERROR "${tool} result\n" + " ${expect_var}='${${expect_var}}'\n" + "is not expected\n" + " ${expect_var}='${expect_val}'\n" + ) + endif() + endif() + endforeach() + endblock() +endforeach() diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/RunCMakeTest.cmake b/Tests/RunCMake/ParseImplicitLinkInfo/RunCMakeTest.cmake index c7655d2..f740617 100644 --- a/Tests/RunCMake/ParseImplicitLinkInfo/RunCMakeTest.cmake +++ b/Tests/RunCMake/ParseImplicitLinkInfo/RunCMakeTest.cmake @@ -6,6 +6,10 @@ run_cmake(Inspect) set(info "${RunCMake_BINARY_DIR}/Inspect-build/info.cmake") include("${info}") +if(CMAKE_HOST_UNIX) + run_cmake_script(DetermineLinkerId) +endif() + if(INFO_CMAKE_C_IMPLICIT_LINK_DIRECTORIES MATCHES ";") run_cmake_with_options(ExcludeDirs "-Dinfo=${RunCMake_BINARY_DIR}/Inspect-build/info.cmake") endif() diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/aix7.3-ld.bash b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/aix7.3-ld.bash new file mode 100755 index 0000000..b996b53 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/aix7.3-ld.bash @@ -0,0 +1,2 @@ +#!/bin/sh +echo 'ld: LD 7.3.1(6/9/22)' diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/aix7.3-ld.cmake b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/aix7.3-ld.cmake new file mode 100644 index 0000000..e01e467 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/aix7.3-ld.cmake @@ -0,0 +1 @@ +set(CMAKE_SYSTEM_NAME "AIX") diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/aix7.3-ld.txt b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/aix7.3-ld.txt new file mode 100644 index 0000000..a708bd2 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/aix7.3-ld.txt @@ -0,0 +1,2 @@ +CMAKE_C_COMPILER_LINKER_ID='AIX' +CMAKE_C_COMPILER_LINKER_VERSION='7.3.1' diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/debian12-ld.bfd.bash b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/debian12-ld.bfd.bash new file mode 100755 index 0000000..d63fd30 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/debian12-ld.bfd.bash @@ -0,0 +1,2 @@ +#!/bin/sh +echo 'GNU ld (GNU Binutils for Debian) 2.40' diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/debian12-ld.bfd.txt b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/debian12-ld.bfd.txt new file mode 100644 index 0000000..802becd --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/debian12-ld.bfd.txt @@ -0,0 +1,3 @@ +CMAKE_C_COMPILER_LINKER_ID='GNU' +CMAKE_C_COMPILER_LINKER_VERSION='2.40' +CMAKE_C_COMPILER_LINKER_FRONTEND_VARIANT='GNU' diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/debian12-ld.gold.bash b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/debian12-ld.gold.bash new file mode 100755 index 0000000..894219c --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/debian12-ld.gold.bash @@ -0,0 +1,2 @@ +#!/bin/sh +echo 'GNU gold (GNU Binutils for Debian 2.40) 1.16' diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/debian12-ld.gold.txt b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/debian12-ld.gold.txt new file mode 100644 index 0000000..0b4e7c2 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/debian12-ld.gold.txt @@ -0,0 +1,3 @@ +CMAKE_C_COMPILER_LINKER_ID='GNUgold' +CMAKE_C_COMPILER_LINKER_VERSION='1.16' +CMAKE_C_COMPILER_LINKER_FRONTEND_VARIANT='GNU' diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/debian12-ld.lld.bash b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/debian12-ld.lld.bash new file mode 100755 index 0000000..8b3099e --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/debian12-ld.lld.bash @@ -0,0 +1,2 @@ +#!/bin/sh +echo 'Debian LLD 14.0.6 (compatible with GNU linkers)' diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/debian12-ld.lld.txt b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/debian12-ld.lld.txt new file mode 100644 index 0000000..e689c2c --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/debian12-ld.lld.txt @@ -0,0 +1,3 @@ +CMAKE_C_COMPILER_LINKER_ID='LLD' +CMAKE_C_COMPILER_LINKER_VERSION='14.0.6' +CMAKE_C_COMPILER_LINKER_FRONTEND_VARIANT='GNU' diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/debian12-ld.mold.bash b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/debian12-ld.mold.bash new file mode 100755 index 0000000..99bf1a3 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/debian12-ld.mold.bash @@ -0,0 +1,2 @@ +#!/bin/sh +echo 'mold 1.10.1 (compatible with GNU ld)' diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/debian12-ld.mold.txt b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/debian12-ld.mold.txt new file mode 100644 index 0000000..0f4d63e --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/debian12-ld.mold.txt @@ -0,0 +1,3 @@ +CMAKE_C_COMPILER_LINKER_ID='MOLD' +CMAKE_C_COMPILER_LINKER_VERSION='1.10.1' +CMAKE_C_COMPILER_LINKER_FRONTEND_VARIANT='GNU' diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/fedora39-ld.gold.bash b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/fedora39-ld.gold.bash new file mode 100755 index 0000000..c79bc24 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/fedora39-ld.gold.bash @@ -0,0 +1,2 @@ +#!/bin/sh +echo 'GNU gold (version 2.40-13.fc39) 1.16' diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/fedora39-ld.gold.txt b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/fedora39-ld.gold.txt new file mode 100644 index 0000000..0b4e7c2 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/fedora39-ld.gold.txt @@ -0,0 +1,3 @@ +CMAKE_C_COMPILER_LINKER_ID='GNUgold' +CMAKE_C_COMPILER_LINKER_VERSION='1.16' +CMAKE_C_COMPILER_LINKER_FRONTEND_VARIANT='GNU' diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/fedora39-ld.lld.bash b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/fedora39-ld.lld.bash new file mode 100755 index 0000000..fef53f9 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/fedora39-ld.lld.bash @@ -0,0 +1,2 @@ +#!/bin/sh +echo 'LLD 17.0.4 (compatible with GNU linkers)' diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/fedora39-ld.lld.txt b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/fedora39-ld.lld.txt new file mode 100644 index 0000000..e9d0d36 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/fedora39-ld.lld.txt @@ -0,0 +1,3 @@ +CMAKE_C_COMPILER_LINKER_ID='LLD' +CMAKE_C_COMPILER_LINKER_VERSION='17.0.4' +CMAKE_C_COMPILER_LINKER_FRONTEND_VARIANT='GNU' diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/fedora39-ld.mold.bash b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/fedora39-ld.mold.bash new file mode 100755 index 0000000..c20639c --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/fedora39-ld.mold.bash @@ -0,0 +1,2 @@ +#!/bin/sh +echo 'mold 2.4.0 (compatible with GNU ld)' diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/fedora39-ld.mold.txt b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/fedora39-ld.mold.txt new file mode 100644 index 0000000..708c5dc --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/fedora39-ld.mold.txt @@ -0,0 +1,3 @@ +CMAKE_C_COMPILER_LINKER_ID='MOLD' +CMAKE_C_COMPILER_LINKER_VERSION='2.4.0' +CMAKE_C_COMPILER_LINKER_FRONTEND_VARIANT='GNU' diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/msvc14.36-link.bash b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/msvc14.36-link.bash new file mode 100755 index 0000000..3599216 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/msvc14.36-link.bash @@ -0,0 +1,5 @@ +#!/bin/sh +echo 'Microsoft (R) Incremental Linker Version 14.36.32543.0 +Copyright (C) Microsoft Corporation. All rights reserved. + + usage: LINK [options] [files] [@commandfile]' diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/msvc14.36-link.txt b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/msvc14.36-link.txt new file mode 100644 index 0000000..b15aaf0 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/msvc14.36-link.txt @@ -0,0 +1,3 @@ +CMAKE_C_COMPILER_LINKER_ID='MSVC' +CMAKE_C_COMPILER_LINKER_VERSION='14.36.32543.0' +CMAKE_C_COMPILER_LINKER_FRONTEND_VARIANT='MSVC' diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/sunos5.11-ld.bash b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/sunos5.11-ld.bash new file mode 100755 index 0000000..b296462 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/sunos5.11-ld.bash @@ -0,0 +1,2 @@ +#!/bin/sh +echo 'ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.2458' diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/sunos5.11-ld.cmake b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/sunos5.11-ld.cmake new file mode 100644 index 0000000..323087d --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/sunos5.11-ld.cmake @@ -0,0 +1 @@ +set(CMAKE_SYSTEM_NAME "SunOS") diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/sunos5.11-ld.txt b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/sunos5.11-ld.txt new file mode 100644 index 0000000..6c645a6 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/sunos5.11-ld.txt @@ -0,0 +1,2 @@ +CMAKE_C_COMPILER_LINKER_ID='Solaris' +CMAKE_C_COMPILER_LINKER_VERSION='5.11-1.2458' diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/xcode15.1-ld.bash b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/xcode15.1-ld.bash new file mode 100755 index 0000000..8dd9267 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/xcode15.1-ld.bash @@ -0,0 +1,9 @@ +#!/bin/sh +echo '@(#)PROGRAM:ld PROJECT:dyld-1022.1 +BUILD 13:21:42 Nov 10 2023 +configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h +will use ld-classic for: armv6 armv7 armv7s arm64_32 i386 armv6m armv7k armv7m armv7em +LTO support using: LLVM version 15.0.0 (static support for 29, runtime is 29) +TAPI support using: Apple TAPI version 15.0.0 (tapi-1500.0.12.8) +Library search paths: +Framework search paths:' diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/xcode15.1-ld.cmake b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/xcode15.1-ld.cmake new file mode 100644 index 0000000..ca62f43 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/xcode15.1-ld.cmake @@ -0,0 +1 @@ +set(CMAKE_SYSTEM_NAME "Darwin") diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/xcode15.1-ld.txt b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/xcode15.1-ld.txt new file mode 100644 index 0000000..f2eb083 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ld-v/xcode15.1-ld.txt @@ -0,0 +1,3 @@ +CMAKE_C_COMPILER_LINKER_ID='AppleClang' +CMAKE_C_COMPILER_LINKER_VERSION='1022.1' +CMAKE_C_COMPILER_LINKER_FRONTEND_VARIANT='GNU' |