From d4ba945c48a3af674bdd95157d18d6236f7c2472 Mon Sep 17 00:00:00 2001 From: Raphael Gozzo Date: Mon, 6 Dec 2021 15:03:10 -0300 Subject: CMakeParseLibraryArchitecture: Fix parsing /lib/ implicit object path The current regular expression is able to match `/usr/lib/`, `/usr/usr/lib/`, `/usr/usr/usr/lib/`, ... but not `/lib/`. This behavior ends up causing the detected architecture to be x86_64-pc-linux-gnu when the Clang compiler is installed on a "non-system" location (like /opt/llvm-13) which, in turn, makes almost every 'find_library()' fail because the correct architecture is x86_64-linux-gnu. This is due to a typo in commit 764606e256 (CMakeDetermineCompilerABI: Extract lib arch from implicit object file paths, 2021-04-05, v3.20.1~10^2), which used `+` instead of `?`. --- Modules/CMakeParseLibraryArchitecture.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Modules/CMakeParseLibraryArchitecture.cmake') diff --git a/Modules/CMakeParseLibraryArchitecture.cmake b/Modules/CMakeParseLibraryArchitecture.cmake index 6fb9c6bfce..f7a4b29c34 100644 --- a/Modules/CMakeParseLibraryArchitecture.cmake +++ b/Modules/CMakeParseLibraryArchitecture.cmake @@ -23,7 +23,7 @@ function(cmake_parse_library_architecture lang implicit_dirs implicit_objs outpu foreach(obj IN LISTS implicit_objs) get_filename_component(dir "${obj}" DIRECTORY) - if("${dir}" MATCHES "(/usr)+/lib/${CMAKE_LIBRARY_ARCHITECTURE_REGEX}$") + if("${dir}" MATCHES "(/usr)?/lib/${CMAKE_LIBRARY_ARCHITECTURE_REGEX}$") get_filename_component(arch "${dir}" NAME) set(library_arch "${arch}") break() -- cgit v1.2.1