From cbbf7ddd3dcacc99908218abb45c7d8d5496562e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Fri, 28 Dec 2018 01:35:16 +0100 Subject: Fix detection of libraries when linking against static builds with CMake This patch is a follow-up to eda28621f6c1a68774719f382be53ec109123b18. It adds a translation of the $$[QT_INSTALL_LIBS] variable into a path that CMake understands. Without this, CMake finds the system libraries if there are any instead. It also handles the case where the .prl file contains absolute paths to libraries, as it happens for instance on Debian systems. Task-number: QTBUG-38913 Change-Id: If68373efee22bc00172e8fead3e2c12ea440787f Reviewed-by: Kyle Edwards Reviewed-by: Kevin Funk --- mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in index acd302d4b2..d6773d6e98 100644 --- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in +++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in @@ -52,13 +52,18 @@ endmacro() function(_qt5_$${CMAKE_MODULE_NAME}_process_prl_file prl_file_location Configuration lib_deps link_flags) set(_lib_deps) set(_link_flags) + + get_filename_component(_qt5_install_libs \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/lib\" ABSOLUTE) + if(EXISTS \"${prl_file_location}\") file(STRINGS \"${prl_file_location}\" _prl_strings REGEX \"QMAKE_PRL_LIBS[ \\t]*=\") string(REGEX REPLACE \"QMAKE_PRL_LIBS[ \\t]*=[ \\t]*([^\\n]*)\" \"\\\\1\" _static_depends ${_prl_strings}) string(REGEX REPLACE \"[ \\t]+\" \";\" _static_depends ${_static_depends}) set(_search_paths) + string(REPLACE \"\\$\\$[QT_INSTALL_LIBS]\" \"${_qt5_install_libs}\" _static_depends \"${_static_depends}\") foreach(_flag ${_static_depends}) if(_flag MATCHES \"^-l(.*)$\") + # Handle normal libraries passed as -lfoo set(_lib \"${CMAKE_MATCH_1}\") if(_lib MATCHES \"^pthread$\") find_package(Threads REQUIRED) @@ -77,9 +82,14 @@ function(_qt5_$${CMAKE_MODULE_NAME}_process_prl_file prl_file_location Configura message(FATAL_ERROR \"Library not found: ${_lib}\") endif() endif() + elseif(EXISTS \"${_flag}\") + # The flag is an absolute path to an existing library + list(APPEND _lib_deps \"${_flag}\") elseif(_flag MATCHES \"^-L(.*)$\") + # Handle -Lfoo flags by putting their paths in the search path used by find_library above list(APPEND _search_paths \"${CMAKE_MATCH_1}\") else() + # Handle all remaining flags by simply passing them to the linker list(APPEND _link_flags ${_flag}) endif() endforeach() -- cgit v1.2.3