mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-23 22:58:37 -05:00
Merge topic 'nvhpc-lib-arch'
764606e256CMakeDetermineCompilerABI: Extract lib arch from implicit object file paths5d44d73bbeCMakeDetermineCompilerABI: Revert "Parse library arch from versioned paths" Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5984
This commit is contained in:
@@ -135,11 +135,13 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src)
|
||||
|
||||
# Parse implicit linker information for this language, if available.
|
||||
set(implicit_dirs "")
|
||||
set(implicit_objs "")
|
||||
set(implicit_libs "")
|
||||
set(implicit_fwks "")
|
||||
if(CMAKE_${lang}_VERBOSE_FLAG)
|
||||
CMAKE_PARSE_IMPLICIT_LINK_INFO("${OUTPUT}" implicit_libs implicit_dirs implicit_fwks log
|
||||
"${CMAKE_${lang}_IMPLICIT_OBJECT_REGEX}")
|
||||
"${CMAKE_${lang}_IMPLICIT_OBJECT_REGEX}"
|
||||
COMPUTE_IMPLICIT_OBJECTS implicit_objs)
|
||||
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||
"Parsed ${lang} implicit link information from above output:\n${log}\n\n")
|
||||
endif()
|
||||
@@ -176,7 +178,7 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src)
|
||||
set(CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES "${implicit_dirs}" PARENT_SCOPE)
|
||||
set(CMAKE_${lang}_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "${implicit_fwks}" PARENT_SCOPE)
|
||||
|
||||
cmake_parse_library_architecture("${implicit_dirs}" architecture_flag)
|
||||
cmake_parse_library_architecture(${lang} "${implicit_dirs}" "${implicit_objs}" architecture_flag)
|
||||
if(architecture_flag)
|
||||
set(CMAKE_${lang}_LIBRARY_ARCHITECTURE "${architecture_flag}" PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
@@ -5,16 +5,27 @@ cmake_policy(PUSH)
|
||||
cmake_policy(SET CMP0053 NEW)
|
||||
cmake_policy(SET CMP0054 NEW)
|
||||
|
||||
# Function parse implicit linker options.
|
||||
# Function to parse implicit linker options.
|
||||
#
|
||||
# This is used internally by CMake and should not be included by user
|
||||
# code.
|
||||
|
||||
#
|
||||
# Note: this function is leaked/exposed by FindOpenMP and therefore needs
|
||||
# to have a stable API so projects that copied `FindOpenMP` for backwards
|
||||
# compatibility don't break.
|
||||
#
|
||||
function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj_regex)
|
||||
set(implicit_libs_tmp "")
|
||||
set(implicit_objs_tmp "")
|
||||
set(implicit_dirs_tmp)
|
||||
set(implicit_fwks_tmp)
|
||||
set(log "")
|
||||
|
||||
set(keywordArgs)
|
||||
set(oneValueArgs COMPUTE_IMPLICIT_OBJECTS)
|
||||
set(multiValueArgs )
|
||||
cmake_parse_arguments(EXTRA_PARSE "${keywordArgs}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
# Parse implicit linker arguments.
|
||||
set(linker "CMAKE_LINKER-NOTFOUND")
|
||||
if(CMAKE_LINKER)
|
||||
@@ -103,11 +114,15 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
|
||||
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.
|
||||
list(APPEND implicit_libs_tmp ${arg})
|
||||
string(APPEND log " arg [${arg}] ==> obj [${arg}]\n")
|
||||
elseif("${arg}" MATCHES "^(.:)?[/\\].*\\.o$")
|
||||
if(EXTRA_PARSE_COMPUTE_IMPLICIT_OBJECTS)
|
||||
list(APPEND implicit_objs_tmp ${arg})
|
||||
string(APPEND log " arg [${arg}] ==> obj [${arg}]\n")
|
||||
endif()
|
||||
if(obj_regex AND "${arg}" MATCHES "${obj_regex}")
|
||||
# Object file full path.
|
||||
list(APPEND implicit_libs_tmp ${arg})
|
||||
endif()
|
||||
elseif("${arg}" MATCHES "^-Y(P,)?[^0-9]")
|
||||
# Sun search path ([^0-9] avoids conflict with Mac -Y<num>).
|
||||
string(REGEX REPLACE "^-Y(P,)?" "" dirs "${arg}")
|
||||
@@ -170,6 +185,21 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(EXTRA_PARSE_COMPUTE_IMPLICIT_OBJECTS)
|
||||
set(implicit_objs "")
|
||||
foreach(obj IN LISTS implicit_objs_tmp)
|
||||
if(IS_ABSOLUTE "${obj}")
|
||||
get_filename_component(abs "${obj}" ABSOLUTE)
|
||||
if(NOT "x${obj}" STREQUAL "x${abs}")
|
||||
string(APPEND log " collapse obj [${obj}] ==> [${abs}]\n")
|
||||
endif()
|
||||
list(APPEND implicit_objs "${abs}")
|
||||
else()
|
||||
list(APPEND implicit_objs "${obj}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Cleanup list of library and framework directories.
|
||||
set(desc_dirs "library")
|
||||
set(desc_fwks "framework")
|
||||
@@ -191,6 +221,7 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
|
||||
|
||||
# Log results.
|
||||
string(APPEND log " implicit libs: [${implicit_libs}]\n")
|
||||
string(APPEND log " implicit objs: [${implicit_objs}]\n")
|
||||
string(APPEND log " implicit dirs: [${implicit_dirs}]\n")
|
||||
string(APPEND log " implicit fwks: [${implicit_fwks}]\n")
|
||||
|
||||
@@ -199,6 +230,10 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
|
||||
set(${dir_var} "${implicit_dirs}" PARENT_SCOPE)
|
||||
set(${fwk_var} "${implicit_fwks}" PARENT_SCOPE)
|
||||
set(${log_var} "${log}" PARENT_SCOPE)
|
||||
|
||||
if(EXTRA_PARSE_COMPUTE_IMPLICIT_OBJECTS)
|
||||
set(${EXTRA_PARSE_COMPUTE_IMPLICIT_OBJECTS} "${implicit_objs}" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
cmake_policy(POP)
|
||||
|
||||
@@ -9,24 +9,22 @@ cmake_policy(SET CMP0054 NEW)
|
||||
# This is used internally by CMake and should not be included by user
|
||||
# code.
|
||||
|
||||
function(cmake_parse_library_architecture implicit_dirs output_var)
|
||||
function(cmake_parse_library_architecture lang implicit_dirs implicit_objs output_var)
|
||||
unset(library_arch)
|
||||
# Detect library architecture directory name.
|
||||
if(CMAKE_LIBRARY_ARCHITECTURE_REGEX)
|
||||
foreach(dir ${implicit_dirs})
|
||||
foreach(dir IN LISTS implicit_dirs)
|
||||
if("${dir}" MATCHES "/lib/${CMAKE_LIBRARY_ARCHITECTURE_REGEX}$")
|
||||
get_filename_component(arch "${dir}" NAME)
|
||||
set(library_arch "${arch}")
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(CMAKE_LIBRARY_ARCHITECTURE_REGEX_VERSIONED AND NOT library_arch)
|
||||
foreach(dir ${implicit_dirs})
|
||||
if("${dir}" MATCHES "/${CMAKE_LIBRARY_ARCHITECTURE_REGEX_VERSIONED}$")
|
||||
get_filename_component(arch "${dir}" DIRECTORY)
|
||||
get_filename_component(arch "${arch}" NAME)
|
||||
foreach(obj IN LISTS implicit_objs)
|
||||
get_filename_component(dir "${obj}" DIRECTORY)
|
||||
if("${dir}" MATCHES "(/usr)+/lib/${CMAKE_LIBRARY_ARCHITECTURE_REGEX}$")
|
||||
get_filename_component(arch "${dir}" NAME)
|
||||
set(library_arch "${arch}")
|
||||
break()
|
||||
endif()
|
||||
|
||||
@@ -48,7 +48,6 @@ endif()
|
||||
|
||||
# Match multiarch library directory names.
|
||||
set(CMAKE_LIBRARY_ARCHITECTURE_REGEX "[a-z0-9_]+(-[a-z0-9_]+)?-linux-gnu[a-z0-9_]*")
|
||||
set(CMAKE_LIBRARY_ARCHITECTURE_REGEX_VERSIONED "gcc/[a-z0-9_]+(-[a-z0-9_]+)?-linux(-gnu)?/[0-9]+(\\.[0-9]+\\.[0-9]+)*")
|
||||
|
||||
include(Platform/UnixPaths)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user