summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeParseImplicitLinkInfo.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-11-05 17:17:08 (GMT)
committerBrad King <brad.king@kitware.com>2009-11-05 17:17:08 (GMT)
commit56d4619984f0c87597cff4758184bb14f905470d (patch)
tree691fb84c77b940bfbee667f2aef283fe5cfc4dda /Modules/CMakeParseImplicitLinkInfo.cmake
parent9f105a3f6de6036d14e6a7b01a7a8e66d641259c (diff)
downloadCMake-56d4619984f0c87597cff4758184bb14f905470d.zip
CMake-56d4619984f0c87597cff4758184bb14f905470d.tar.gz
CMake-56d4619984f0c87597cff4758184bb14f905470d.tar.bz2
Remove non-language implicit link dependencies
Some compilers use implicit link options of the form -lcrt*.o -lgcc* -lSystem (on Mac) -lSystemStubs (on Mac) that provide system-wide symbols not specific to any language. These need not be listed explicitly for mixed-language linking. We teach CMake to remove the above items from the implicit library list of each language. This change makes it possible to mix GNU compiler versions in some cases.
Diffstat (limited to 'Modules/CMakeParseImplicitLinkInfo.cmake')
-rw-r--r--Modules/CMakeParseImplicitLinkInfo.cmake21
1 files changed, 16 insertions, 5 deletions
diff --git a/Modules/CMakeParseImplicitLinkInfo.cmake b/Modules/CMakeParseImplicitLinkInfo.cmake
index b8a681f..1761d28 100644
--- a/Modules/CMakeParseImplicitLinkInfo.cmake
+++ b/Modules/CMakeParseImplicitLinkInfo.cmake
@@ -17,7 +17,7 @@
# code.
function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var log_var)
- set(implicit_libs "")
+ set(implicit_libs_tmp "")
set(implicit_dirs_tmp)
set(log "")
@@ -53,11 +53,11 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var log_var)
elseif("${arg}" MATCHES "^-l[^:]")
# Unix library.
string(REGEX REPLACE "^-l" "" lib "${arg}")
- list(APPEND implicit_libs ${lib})
+ list(APPEND implicit_libs_tmp ${lib})
set(log "${log} arg [${arg}] ==> lib [${lib}]\n")
elseif("${arg}" MATCHES "^(.:)?[/\\].*\\.a$")
# Unix library full path.
- list(APPEND implicit_libs ${arg})
+ list(APPEND implicit_libs_tmp ${arg})
set(log "${log} arg [${arg}] ==> lib [${arg}]\n")
elseif("${arg}" MATCHES "^-Y(P,)?")
# Sun search path.
@@ -67,11 +67,11 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var log_var)
set(log "${log} arg [${arg}] ==> dirs [${dirs}]\n")
elseif("${arg}" MATCHES "^-l:")
# HP named library.
- list(APPEND implicit_libs ${arg})
+ list(APPEND implicit_libs_tmp ${arg})
set(log "${log} arg [${arg}] ==> lib [${arg}]\n")
elseif("${arg}" MATCHES "^-z(all|default|weak)extract")
# Link editor option.
- list(APPEND implicit_libs ${arg})
+ list(APPEND implicit_libs_tmp ${arg})
set(log "${log} arg [${arg}] ==> opt [${arg}]\n")
else()
set(log "${log} arg [${arg}] ==> ignore\n")
@@ -90,6 +90,17 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var log_var)
endif()
endforeach()
+ # Cleanup list of libraries and flags.
+ # We remove items that are not language-specific.
+ set(implicit_libs "")
+ foreach(lib IN LISTS implicit_libs_tmp)
+ if("${lib}" MATCHES "^(crt.*\\.o|gcc.*|System.*)$")
+ set(log "${log} remove lib [${lib}]\n")
+ else()
+ list(APPEND implicit_libs "${lib}")
+ endif()
+ endforeach()
+
# Cleanup list of directories.
set(implicit_dirs "")
foreach(d IN LISTS implicit_dirs_tmp)