2009-07-23 14:07:25 +00:00
|
|
|
|
2009-09-28 15:46:51 +00:00
|
|
|
#=============================================================================
|
|
|
|
# Copyright 2009 Kitware, Inc.
|
|
|
|
#
|
|
|
|
# Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
# see accompanying file Copyright.txt for details.
|
|
|
|
#
|
|
|
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
# See the License for more information.
|
|
|
|
#=============================================================================
|
|
|
|
# (To distributed this file outside of CMake, substitute the full
|
|
|
|
# License text for the above reference.)
|
|
|
|
|
2009-07-23 14:07:25 +00:00
|
|
|
# Function parse implicit linker options.
|
|
|
|
# This is used internally by CMake and should not be included by user
|
|
|
|
# code.
|
|
|
|
|
2009-10-06 19:16:12 +00:00
|
|
|
function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var log_var)
|
2009-07-23 14:07:25 +00:00
|
|
|
set(implicit_libs "")
|
|
|
|
set(implicit_dirs_tmp)
|
2009-10-06 19:16:12 +00:00
|
|
|
set(log "")
|
2009-07-23 14:07:25 +00:00
|
|
|
|
|
|
|
# Parse implicit linker arguments.
|
|
|
|
set(linker "CMAKE_LINKER-NOTFOUND")
|
|
|
|
if(CMAKE_LINKER)
|
|
|
|
get_filename_component(linker ${CMAKE_LINKER} NAME)
|
|
|
|
endif()
|
2009-07-29 20:07:19 +00:00
|
|
|
set(linker_regex "^( *|.*/)(${linker}|ld|collect2)")
|
2009-07-23 14:07:25 +00:00
|
|
|
string(REGEX REPLACE "\r?\n" ";" output_lines "${text}")
|
|
|
|
foreach(line IN LISTS output_lines)
|
|
|
|
set(cmd)
|
|
|
|
if("${line}" MATCHES "${linker_regex}")
|
|
|
|
if(UNIX)
|
|
|
|
separate_arguments(args UNIX_COMMAND "${line}")
|
|
|
|
else()
|
|
|
|
separate_arguments(args WINDOWS_COMMAND "${line}")
|
|
|
|
endif()
|
|
|
|
list(GET args 0 cmd)
|
|
|
|
endif()
|
|
|
|
if("${cmd}" MATCHES "${linker_regex}")
|
2009-10-06 19:16:12 +00:00
|
|
|
set(log "${log} link line: [${line}]\n")
|
2009-07-28 12:36:11 +00:00
|
|
|
string(REGEX REPLACE ";-([LYz]);" ";-\\1" args "${args}")
|
2009-07-23 14:07:25 +00:00
|
|
|
foreach(arg IN LISTS args)
|
|
|
|
if("${arg}" MATCHES "^-L(.:)?[/\\]")
|
|
|
|
# Unix search path.
|
|
|
|
string(REGEX REPLACE "^-L" "" dir "${arg}")
|
|
|
|
list(APPEND implicit_dirs_tmp ${dir})
|
2009-10-06 19:16:12 +00:00
|
|
|
set(log "${log} arg [${arg}] ==> dir [${dir}]\n")
|
2009-07-23 14:07:25 +00:00
|
|
|
elseif("${arg}" MATCHES "^-l[^:]")
|
|
|
|
# Unix library.
|
|
|
|
string(REGEX REPLACE "^-l" "" lib "${arg}")
|
|
|
|
list(APPEND implicit_libs ${lib})
|
2009-10-06 19:16:12 +00:00
|
|
|
set(log "${log} arg [${arg}] ==> lib [${lib}]\n")
|
2009-07-23 14:07:25 +00:00
|
|
|
elseif("${arg}" MATCHES "^(.:)?[/\\].*\\.a$")
|
|
|
|
# Unix library full path.
|
|
|
|
list(APPEND implicit_libs ${arg})
|
2009-10-06 19:16:12 +00:00
|
|
|
set(log "${log} arg [${arg}] ==> lib [${arg}]\n")
|
2009-07-23 14:07:25 +00:00
|
|
|
elseif("${arg}" MATCHES "^-Y(P,)?")
|
|
|
|
# Sun search path.
|
|
|
|
string(REGEX REPLACE "^-Y(P,)?" "" dirs "${arg}")
|
|
|
|
string(REPLACE ":" ";" dirs "${dirs}")
|
|
|
|
list(APPEND implicit_dirs_tmp ${dirs})
|
2009-10-06 19:16:12 +00:00
|
|
|
set(log "${log} arg [${arg}] ==> dirs [${dirs}]\n")
|
2009-07-23 14:07:25 +00:00
|
|
|
elseif("${arg}" MATCHES "^-l:")
|
|
|
|
# HP named library.
|
|
|
|
list(APPEND implicit_libs ${arg})
|
2009-10-06 19:16:12 +00:00
|
|
|
set(log "${log} arg [${arg}] ==> lib [${arg}]\n")
|
2009-07-28 12:36:11 +00:00
|
|
|
elseif("${arg}" MATCHES "^-z(all|default|weak)extract")
|
|
|
|
# Link editor option.
|
|
|
|
list(APPEND implicit_libs ${arg})
|
2009-10-06 19:16:12 +00:00
|
|
|
set(log "${log} arg [${arg}] ==> opt [${arg}]\n")
|
|
|
|
else()
|
|
|
|
set(log "${log} arg [${arg}] ==> ignore\n")
|
2009-07-23 14:07:25 +00:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
break()
|
|
|
|
elseif("${line}" MATCHES "LPATH(=| is:? )")
|
2009-10-06 19:16:12 +00:00
|
|
|
set(log "${log} LPATH line: [${line}]\n")
|
2009-07-23 14:07:25 +00:00
|
|
|
# HP search path.
|
|
|
|
string(REGEX REPLACE ".*LPATH(=| is:? *)" "" paths "${line}")
|
|
|
|
string(REPLACE ":" ";" paths "${paths}")
|
|
|
|
list(APPEND implicit_dirs_tmp ${paths})
|
2009-10-06 19:16:12 +00:00
|
|
|
set(log "${log} dirs [${paths}]\n")
|
|
|
|
else()
|
|
|
|
set(log "${log} ignore line: [${line}]\n")
|
2009-07-23 14:07:25 +00:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
# Cleanup list of directories.
|
|
|
|
set(implicit_dirs "")
|
|
|
|
foreach(d IN LISTS implicit_dirs_tmp)
|
|
|
|
get_filename_component(dir "${d}" ABSOLUTE)
|
|
|
|
list(APPEND implicit_dirs "${dir}")
|
2009-10-06 19:16:12 +00:00
|
|
|
set(log "${log} collapse dir [${d}] ==> [${dir}]\n")
|
2009-07-23 14:07:25 +00:00
|
|
|
endforeach()
|
|
|
|
list(REMOVE_DUPLICATES implicit_dirs)
|
|
|
|
|
2009-10-06 19:16:12 +00:00
|
|
|
# Log results.
|
|
|
|
set(log "${log} implicit libs: [${implicit_libs}]\n")
|
|
|
|
set(log "${log} implicit dirs: [${implicit_dirs}]\n")
|
|
|
|
|
2009-07-23 14:07:25 +00:00
|
|
|
# Return results.
|
|
|
|
set(${lib_var} "${implicit_libs}" PARENT_SCOPE)
|
|
|
|
set(${dir_var} "${implicit_dirs}" PARENT_SCOPE)
|
2009-10-06 19:16:12 +00:00
|
|
|
set(${log_var} "${log}" PARENT_SCOPE)
|
2009-07-23 14:07:25 +00:00
|
|
|
endfunction()
|