diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeDetermineCompilerABI.cmake | 25 | ||||
-rw-r--r-- | Modules/CMakeParseLibraryArchitecture.cmake | 56 | ||||
-rw-r--r-- | Modules/Platform/Linux.cmake | 1 |
3 files changed, 61 insertions, 21 deletions
diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index 67c42a2a..cf028f1 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -8,6 +8,7 @@ include(${CMAKE_ROOT}/Modules/CMakeParseImplicitIncludeInfo.cmake) include(${CMAKE_ROOT}/Modules/CMakeParseImplicitLinkInfo.cmake) +include(${CMAKE_ROOT}/Modules/CMakeParseLibraryArchitecture.cmake) include(CMakeTestCompilerCommon) function(CMAKE_DETERMINE_COMPILER_ABI lang src) @@ -175,27 +176,9 @@ 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) - # Detect library architecture directory name. - if(CMAKE_LIBRARY_ARCHITECTURE_REGEX) - foreach(dir ${implicit_dirs}) - if("${dir}" MATCHES "/lib/${CMAKE_LIBRARY_ARCHITECTURE_REGEX}$") - get_filename_component(arch "${dir}" NAME) - set(CMAKE_${lang}_LIBRARY_ARCHITECTURE "${arch}" PARENT_SCOPE) - break() - endif() - endforeach() - elseif(CMAKE_CXX_COMPILER_ID STREQUAL QCC) - foreach(dir ${implicit_dirs}) - if (dir MATCHES "/lib$") - get_filename_component(assumedArchDir "${dir}" DIRECTORY) - get_filename_component(archParentDir "${assumedArchDir}" DIRECTORY) - if (archParentDir STREQUAL CMAKE_SYSROOT) - get_filename_component(archDirName "${assumedArchDir}" NAME) - set(CMAKE_${lang}_LIBRARY_ARCHITECTURE "${archDirName}" PARENT_SCOPE) - break() - endif() - endif() - endforeach() + cmake_parse_library_architecture("${implicit_dirs}" architecture_flag) + if(architecture_flag) + set(CMAKE_${lang}_LIBRARY_ARCHITECTURE "${architecture_flag}" PARENT_SCOPE) endif() else() diff --git a/Modules/CMakeParseLibraryArchitecture.cmake b/Modules/CMakeParseLibraryArchitecture.cmake new file mode 100644 index 0000000..aa6fd74 --- /dev/null +++ b/Modules/CMakeParseLibraryArchitecture.cmake @@ -0,0 +1,56 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_policy(PUSH) +cmake_policy(SET CMP0053 NEW) +cmake_policy(SET CMP0054 NEW) + +# Function parse implicit linker options. +# This is used internally by CMake and should not be included by user +# code. + +function(cmake_parse_library_architecture implicit_dirs output_var) + unset(library_arch) + # Detect library architecture directory name. + if(CMAKE_LIBRARY_ARCHITECTURE_REGEX) + foreach(dir ${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) + set(library_arch "${arch}") + break() + endif() + endforeach() + endif() + + if(CMAKE_CXX_COMPILER_ID STREQUAL QCC) + foreach(dir ${implicit_dirs}) + if (dir MATCHES "/lib$") + get_filename_component(assumedArchDir "${dir}" DIRECTORY) + get_filename_component(archParentDir "${assumedArchDir}" DIRECTORY) + if (archParentDir STREQUAL CMAKE_SYSROOT) + get_filename_component(archDirName "${assumedArchDir}" NAME) + set(library_arch "${archDirName}") + break() + endif() + endif() + endforeach() + endif() + + # Return results. + if(library_arch) + set(${output_var} "${library_arch}" PARENT_SCOPE) + endif() +endfunction() + +cmake_policy(POP) diff --git a/Modules/Platform/Linux.cmake b/Modules/Platform/Linux.cmake index b5d5464..23b48bd 100644 --- a/Modules/Platform/Linux.cmake +++ b/Modules/Platform/Linux.cmake @@ -48,6 +48,7 @@ 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) |