summaryrefslogtreecommitdiffstats
path: root/mkspecs
diff options
context:
space:
mode:
authorJean-Michaël Celerier <jeanmichael.celerier@gmail.com>2018-12-28 01:35:16 +0100
committerJean-Michaël Celerier <jean-michael.celerier@kdab.com>2019-02-12 13:09:38 +0000
commitcbbf7ddd3dcacc99908218abb45c7d8d5496562e (patch)
tree07986475504b81686ed5382bc9a98359d4d5b8f8 /mkspecs
parent2c60844badd8fb07dd4844926345c924679f20fb (diff)
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 <kyle.edwards@kitware.com> Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
Diffstat (limited to 'mkspecs')
-rw-r--r--mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in10
1 files changed, 10 insertions, 0 deletions
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()