Merge topic 'cxx-checks-tolerate-unused-arguments'
[kiteware-cmake.git] / Modules / CMakeParseLibraryArchitecture.cmake
blobf7a4b29c3497a858e86e502a7f1c001c138b0ebc
1 # Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
4 cmake_policy(PUSH)
5 cmake_policy(SET CMP0053 NEW)
6 cmake_policy(SET CMP0054 NEW)
8 # Function parse implicit linker options.
9 # This is used internally by CMake and should not be included by user
10 # code.
12 function(cmake_parse_library_architecture lang implicit_dirs implicit_objs output_var)
13   unset(library_arch)
14   # Detect library architecture directory name.
15   if(CMAKE_LIBRARY_ARCHITECTURE_REGEX)
16     foreach(dir IN LISTS implicit_dirs)
17       if("${dir}" MATCHES "/lib/${CMAKE_LIBRARY_ARCHITECTURE_REGEX}$")
18         get_filename_component(arch "${dir}" NAME)
19         set(library_arch "${arch}")
20         break()
21       endif()
22     endforeach()
24     foreach(obj IN LISTS implicit_objs)
25       get_filename_component(dir "${obj}" DIRECTORY)
26       if("${dir}" MATCHES "(/usr)?/lib/${CMAKE_LIBRARY_ARCHITECTURE_REGEX}$")
27         get_filename_component(arch "${dir}" NAME)
28         set(library_arch "${arch}")
29         break()
30       endif()
31     endforeach()
32   endif()
34   if(CMAKE_CXX_COMPILER_ID STREQUAL QCC)
35     foreach(dir ${implicit_dirs})
36       if (dir MATCHES "/lib$")
37         get_filename_component(assumedArchDir "${dir}" DIRECTORY)
38         get_filename_component(archParentDir "${assumedArchDir}" DIRECTORY)
39         if (archParentDir STREQUAL CMAKE_SYSROOT)
40           get_filename_component(archDirName "${assumedArchDir}" NAME)
41           set(library_arch "${archDirName}")
42           break()
43         endif()
44       endif()
45     endforeach()
46   endif()
48   # Return results.
49   if(library_arch)
50     set(${output_var} "${library_arch}" PARENT_SCOPE)
51   endif()
52 endfunction()
54 cmake_policy(POP)