summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-04-06 12:32:27 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-04-06 12:32:34 (GMT)
commite061a201b63df75c15eb714f68e5097839222bda (patch)
tree69423676ae819be8e78bb38204f8794663c7a3a7 /Modules
parent2d6a3fd626ad154d92d9345aa3fcb218d188d7ca (diff)
parent764606e25616e9f47eceb3227a3b38fcef544820 (diff)
downloadCMake-e061a201b63df75c15eb714f68e5097839222bda.zip
CMake-e061a201b63df75c15eb714f68e5097839222bda.tar.gz
CMake-e061a201b63df75c15eb714f68e5097839222bda.tar.bz2
Merge topic 'nvhpc-lib-arch' into release-3.20
764606e256 CMakeDetermineCompilerABI: Extract lib arch from implicit object file paths 5d44d73bbe CMakeDetermineCompilerABI: Revert "Parse library arch from versioned paths" Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5984
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakeDetermineCompilerABI.cmake6
-rw-r--r--Modules/CMakeParseImplicitLinkInfo.cmake49
-rw-r--r--Modules/CMakeParseLibraryArchitecture.cmake14
-rw-r--r--Modules/Platform/Linux.cmake1
4 files changed, 52 insertions, 18 deletions
diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake
index cf028f1..8191d81 100644
--- a/Modules/CMakeDetermineCompilerABI.cmake
+++ b/Modules/CMakeDetermineCompilerABI.cmake
@@ -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()
diff --git a/Modules/CMakeParseImplicitLinkInfo.cmake b/Modules/CMakeParseImplicitLinkInfo.cmake
index 0465515..e848b55 100644
--- a/Modules/CMakeParseImplicitLinkInfo.cmake
+++ b/Modules/CMakeParseImplicitLinkInfo.cmake
@@ -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)
diff --git a/Modules/CMakeParseLibraryArchitecture.cmake b/Modules/CMakeParseLibraryArchitecture.cmake
index aa6fd74..6fb9c6b 100644
--- a/Modules/CMakeParseLibraryArchitecture.cmake
+++ b/Modules/CMakeParseLibraryArchitecture.cmake
@@ -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()
diff --git a/Modules/Platform/Linux.cmake b/Modules/Platform/Linux.cmake
index 23b48bd..b5d5464 100644
--- a/Modules/Platform/Linux.cmake
+++ b/Modules/Platform/Linux.cmake
@@ -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)