summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeParseImplicitLinkInfo.cmake
diff options
context:
space:
mode:
authorChristian Pfeiffer <cpfeiffer@live.de>2017-05-12 17:03:16 (GMT)
committerChristian Pfeiffer <cpfeiffer@live.de>2017-05-20 18:02:43 (GMT)
commitc2c2d366198118a807fe6bf1820a32c13a6648ad (patch)
treecb0fce3a94cebad74cc6c37c3c1b3ccb257bf551 /Modules/CMakeParseImplicitLinkInfo.cmake
parent836cb52e9aec83f88841cb5b45abb1d32bb02214 (diff)
downloadCMake-c2c2d366198118a807fe6bf1820a32c13a6648ad.zip
CMake-c2c2d366198118a807fe6bf1820a32c13a6648ad.tar.gz
CMake-c2c2d366198118a807fe6bf1820a32c13a6648ad.tar.bz2
ImplicitLinkInfo: Add support for PGI on Windows
Since PGI does not write linker directives into objects, the necessary libraries have to be parsed from commandline. PGI does however link the Visual C++ runtime libraries, so they have to be filtered out to ensure no collision with settings of other languages can occur.
Diffstat (limited to 'Modules/CMakeParseImplicitLinkInfo.cmake')
-rw-r--r--Modules/CMakeParseImplicitLinkInfo.cmake17
1 files changed, 13 insertions, 4 deletions
diff --git a/Modules/CMakeParseImplicitLinkInfo.cmake b/Modules/CMakeParseImplicitLinkInfo.cmake
index 1d0030c..3b77278 100644
--- a/Modules/CMakeParseImplicitLinkInfo.cmake
+++ b/Modules/CMakeParseImplicitLinkInfo.cmake
@@ -18,9 +18,13 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
get_filename_component(linker ${CMAKE_LINKER} NAME)
string(REGEX REPLACE "([][+.*?()^$])" "\\\\\\1" linker "${linker}")
endif()
+ set(startfile "CMAKE_LINK_STARTFILE-NOTFOUND")
+ if(CMAKE_LINK_STARTFILE)
+ set(startfile "${CMAKE_LINK_STARTFILE}")
+ endif()
# Construct a regex to match linker lines. It must match both the
# whole line and just the command (argv[0]).
- set(linker_regex "^( *|.*[/\\])(${linker}|([^/\\]+-)?ld|collect2)[^/\\]*( |$)")
+ set(linker_regex "^( *|.*[/\\])(${linker}|${startfile}|([^/\\]+-)?ld|collect2)[^/\\]*( |$)")
set(linker_exclude_regex "collect2 version |^[A-Za-z0-9_]+=|/ldfe ")
string(APPEND log " link line regex: [${linker_regex}]\n")
string(REGEX REPLACE "\r?\n" ";" output_lines "${text}")
@@ -55,9 +59,9 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
string(REGEX REPLACE "^-L" "" dir "${arg}")
list(APPEND implicit_dirs_tmp ${dir})
string(APPEND log " arg [${arg}] ==> dir [${dir}]\n")
- elseif("${arg}" MATCHES "^[-/]LIBPATH:(.+)")
+ elseif("${arg}" MATCHES "^[-/](LIBPATH|libpath):(.+)")
# MSVC search path.
- set(dir "${CMAKE_MATCH_1}")
+ set(dir "${CMAKE_MATCH_2}")
list(APPEND implicit_dirs_tmp ${dir})
string(APPEND log " arg [${arg}] ==> dir [${dir}]\n")
elseif(is_msvc AND "${arg}" STREQUAL "-link")
@@ -79,6 +83,11 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
# Unix library full path.
list(APPEND implicit_libs_tmp ${arg})
string(APPEND log " arg [${arg}] ==> lib [${arg}]\n")
+ elseif("${arg}" MATCHES "^[-/](DEFAULTLIB|defaultlib):(.+)")
+ # Windows library.
+ set(lib "${CMAKE_MATCH_2}")
+ list(APPEND implicit_libs_tmp ${lib})
+ string(APPEND log " arg [${arg}] ==> lib [${lib}]\n")
elseif("${arg}" MATCHES "^(.:)?[/\\].*\\.o$"
AND obj_regex AND "${arg}" MATCHES "${obj_regex}")
# Object file full path.
@@ -133,7 +142,7 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
# We remove items that are not language-specific.
set(implicit_libs "")
foreach(lib IN LISTS implicit_libs_tmp)
- if("x${lib}" MATCHES "^x(crt.*\\.o|System.*|.*libclang_rt.*)$")
+ if("x${lib}" MATCHES "^x(crt.*\\.o|System.*|.*libclang_rt.*|msvcrt.*|libvcruntime.*|libucrt.*|libcmt.*)$")
string(APPEND log " remove lib [${lib}]\n")
elseif(IS_ABSOLUTE "${lib}")
get_filename_component(abs "${lib}" ABSOLUTE)