From 459d1cc095f216170b9e3e0f28b58e58954607ad Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 13 Dec 2023 10:38:01 -0500 Subject: Tests: Verify that linker tool is detected and identified where expected --- Tests/RunCMake/ParseImplicitLinkInfo/Inspect.cmake | 9 ++++++- .../ParseImplicitLinkInfo/RunCMakeTest.cmake | 29 +++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/Inspect.cmake b/Tests/RunCMake/ParseImplicitLinkInfo/Inspect.cmake index 42e1c67..fd93baf 100644 --- a/Tests/RunCMake/ParseImplicitLinkInfo/Inspect.cmake +++ b/Tests/RunCMake/ParseImplicitLinkInfo/Inspect.cmake @@ -2,10 +2,17 @@ enable_language(C) set(info "") foreach(var + CMAKE_SYSTEM_NAME + CMAKE_C_COMPILER + CMAKE_C_COMPILER_ID + CMAKE_C_COMPILER_VERSION + CMAKE_C_COMPILER_LINKER + CMAKE_C_COMPILER_LINKER_ID + CMAKE_C_COMPILER_LINKER_VERSION CMAKE_C_IMPLICIT_LINK_DIRECTORIES ) if(DEFINED ${var}) - string(APPEND info "set(INFO_${var} \"${${var}}\")\n") + string(APPEND info "set(${var} \"${${var}}\")\n") endif() endforeach() diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/RunCMakeTest.cmake b/Tests/RunCMake/ParseImplicitLinkInfo/RunCMakeTest.cmake index f740617..9514c97 100644 --- a/Tests/RunCMake/ParseImplicitLinkInfo/RunCMakeTest.cmake +++ b/Tests/RunCMake/ParseImplicitLinkInfo/RunCMakeTest.cmake @@ -2,6 +2,15 @@ include(RunCMake) run_cmake(ParseImplicitLinkInfo) +# Detect information from the toolchain: +# - CMAKE_SYSTEM_NAME +# - CMAKE_C_COMPILER +# - CMAKE_C_COMPILER_ID +# - CMAKE_C_COMPILER_VERSION +# - CMAKE_C_COMPILER_LINKER +# - CMAKE_C_COMPILER_LINKER_ID +# - CMAKE_C_COMPILER_LINKER_VERSION +# - CMAKE_C_IMPLICIT_LINK_DIRECTORIES run_cmake(Inspect) set(info "${RunCMake_BINARY_DIR}/Inspect-build/info.cmake") include("${info}") @@ -10,6 +19,24 @@ if(CMAKE_HOST_UNIX) run_cmake_script(DetermineLinkerId) endif() -if(INFO_CMAKE_C_IMPLICIT_LINK_DIRECTORIES MATCHES ";") +if(CMAKE_C_IMPLICIT_LINK_DIRECTORIES MATCHES ";") run_cmake_with_options(ExcludeDirs "-Dinfo=${RunCMake_BINARY_DIR}/Inspect-build/info.cmake") endif() + +if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|Darwin|Windows|AIX|SunOS)$|BSD" + AND NOT CMAKE_C_COMPILER_ID MATCHES "^(Borland|Embarcadero|OpenWatcom|OrangeC|Watcom)$" + AND NOT (CMAKE_C_COMPILER_ID MATCHES "^(Intel|IntelLLVM)$" AND CMAKE_SYSTEM_NAME STREQUAL "Windows") + AND NOT CMAKE_C_COMPILER_LINKER MATCHES "Visual Studio 9\\.0" + AND NOT RunCMake_GENERATOR MATCHES "Visual Studio 9 " + ) + if(NOT CMAKE_C_COMPILER_LINKER OR NOT CMAKE_C_COMPILER_LINKER_ID OR NOT CMAKE_C_COMPILER_LINKER_VERSION) + message(SEND_ERROR "C compiler's linker not identified:\n" + " CMAKE_C_COMPILER='${CMAKE_C_COMPILER}'\n" + " CMAKE_C_COMPILER_ID='${CMAKE_C_COMPILER_ID}'\n" + " CMAKE_C_COMPILER_VERSION='${CMAKE_C_COMPILER_VERSION}'\n" + " CMAKE_C_COMPILER_LINKER='${CMAKE_C_COMPILER_LINKER}'\n" + " CMAKE_C_COMPILER_LINKER_ID='${CMAKE_C_COMPILER_LINKER_ID}'\n" + " CMAKE_C_COMPILER_LINKER_VERSION='${CMAKE_C_COMPILER_LINKER_VERSION}'\n" + ) + endif() +endif() -- cgit v0.12