From 40608d0a37fdecc0464c982639884b1b7abc6e79 Mon Sep 17 00:00:00 2001 From: Peter Kling Date: Tue, 24 Dec 2024 14:14:42 +0100 Subject: [PATCH] CMake: fix absolute paths w/o suffix in pri/prl files In the update from 6.7.2 to 6.7.3, commit `ea0f00d5d` changed how linker flags like `ws2_32` are treated when generating pri/prl files. Specifically, before the commit a flag like `ws2_32` was left untouched. The above commit changed it such that such flags are converted to `-lws2_32` (seemingly in order to better support FFmpeg, according to the commit message). However, this change also affects absolute paths if the file has no extension. That is, after the above mentioned commit, an absolute path linker flag to, say, a dylib on macOS without a suffix will result in prepending the `-l` flag. This will result in errors during link time. An example where this caused problems can be found in the nixpkgs PR draft #367206 (https://github.com/NixOS/nixpkgs/pull/367206). This adds a small check to ensure that `-l` is not prepended if the linker flag is an absolute path without a suffix. Change-Id: I2c7ce3aac6624e1a27c59af233e3da2c1ae7ba60 Reviewed-by: Alexey Edelev (cherry picked from commit 714ae22b84553271a2809c393dd1a5a90089cc19) --- cmake/QtGenerateLibHelpers.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/QtGenerateLibHelpers.cmake b/cmake/QtGenerateLibHelpers.cmake index 96675267d23..be998d0e6bd 100644 --- a/cmake/QtGenerateLibHelpers.cmake +++ b/cmake/QtGenerateLibHelpers.cmake @@ -10,7 +10,8 @@ function(qt_get_library_name_without_prefix_and_suffix out_var file_path) if(NOT file_path MATCHES "^-") # not a linker flag get_filename_component(basename "${file_path}" NAME_WE) get_filename_component(ext "${file_path}" EXT) - if(NOT ext) # seems like a library name without prefix and suffix + if(NOT ext AND NOT IS_ABSOLUTE "${file_path}") + # seems like a library name without prefix and suffix set(${out_var} "${file_path}" PARENT_SCOPE) return() endif()