CMakeParseImplicitLinkInfo: Detect link lines using link.exe and lld-link

These are printed by LLVM-based compiler drivers targeting the MSVC ABI.
In our use case for this, `CMAKE_LINKER` may not yet be known, so do
not include it in the test data.
This commit is contained in:
Brad King
2023-09-28 18:51:46 -04:00
parent 92adbb5d8c
commit 12733d0d8d
14 changed files with 144 additions and 6 deletions
+10 -6
View File
@@ -26,12 +26,22 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
set(multiValueArgs )
cmake_parse_arguments(EXTRA_PARSE "${keywordArgs}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(is_msvc 0)
if(EXTRA_PARSE_LANGUAGE AND
("x${CMAKE_${EXTRA_PARSE_LANGUAGE}_ID}" STREQUAL "xMSVC" OR
"x${CMAKE_${EXTRA_PARSE_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC"))
set(is_msvc 1)
endif()
# Parse implicit linker arguments.
set(linker "CMAKE_LINKER-NOTFOUND")
if(CMAKE_LINKER)
get_filename_component(linker ${CMAKE_LINKER} NAME)
string(REGEX REPLACE "([][+.*?()^$])" "\\\\\\1" linker "${linker}")
endif()
if(is_msvc)
string(APPEND linker "|link\\.exe|lld-link")
endif()
set(startfile "CMAKE_LINK_STARTFILE-NOTFOUND")
if(CMAKE_LINK_STARTFILE)
set(startfile "${CMAKE_LINK_STARTFILE}")
@@ -75,12 +85,6 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
endif()
endif()
endif()
set(is_msvc 0)
if(EXTRA_PARSE_LANGUAGE AND
("x${CMAKE_${EXTRA_PARSE_LANGUAGE}_ID}" STREQUAL "xMSVC" OR
"x${CMAKE_${EXTRA_PARSE_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC"))
set(is_msvc 1)
endif()
set(search_static 0)
if("${cmd}" MATCHES "${linker_regex}")
string(APPEND log " link line: [${line}]\n")