[CMake] Fix handling Qt frameworks link flags in static lib deps

QMAKE_PRL_LIBS_FOR_CMAKE can contain "-F/foo/bar" entries which
are search paths for where frameworks should be found.

These should be passed as HINTS to find_library when searching for
frameworks.

Fixes: QTBUG-81369
Change-Id: I4f699800bd49a1f368b6132823e23d08d1fae604
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Alexandru Croitor 2020-01-14 16:55:26 +01:00
parent 12df6c63a0
commit d5c9d88885

View File

@ -72,6 +72,7 @@ function(_qt5_$${CMAKE_MODULE_NAME}_process_prl_file prl_file_location Configura
string(REGEX REPLACE \"QMAKE_PRL_LIBS_FOR_CMAKE[ \\t]*=[ \\t]*([^\\n]*)\" \"\\\\1\" _static_depends \"${_prl_strings}\")
string(REGEX REPLACE \"[ \\t]+\" \";\" _standard_libraries \"${CMAKE_CXX_STANDARD_LIBRARIES}\")
set(_search_paths)
set(_fw_search_paths)
set(_framework_flag)
string(REPLACE \"\\$\\$[QT_INSTALL_LIBS]\" \"${_qt5_install_libs}\" _static_depends \"${_static_depends}\")
foreach(_flag ${_static_depends})
@ -79,10 +80,13 @@ function(_qt5_$${CMAKE_MODULE_NAME}_process_prl_file prl_file_location Configura
if(_flag MATCHES \"^-framework$\")
# Handle the next flag as framework name
set(_framework_flag 1)
elseif(_flag MATCHES \"^-F(.*)$\")
# Handle -F/foo/bar flags by recording the framework search paths to be used
# by find_library.
list(APPEND _fw_search_paths \"${CMAKE_MATCH_1}\")
elseif(_framework_flag OR _flag MATCHES \"^-l(.*)$\")
if(_framework_flag)
# Handle Darwin framework bundles passed as -framework Foo
unset(_framework_flag)
set(_lib ${_flag})
else()
# Handle normal libraries passed as -lfoo
@ -100,8 +104,12 @@ function(_qt5_$${CMAKE_MODULE_NAME}_process_prl_file prl_file_location Configura
find_package(Threads REQUIRED)
list(APPEND _lib_deps Threads::Threads)
else()
if(_search_paths)
find_library(_Qt5$${CMAKE_MODULE_NAME}_${Configuration}_${_lib}_PATH ${_lib} HINTS ${_search_paths} NO_DEFAULT_PATH)
set(current_search_paths \"${_search_paths}\")
if(_framework_flag)
set(current_search_paths \"${_fw_search_paths}\")
endif()
if(current_search_paths)
find_library(_Qt5$${CMAKE_MODULE_NAME}_${Configuration}_${_lib}_PATH ${_lib} HINTS ${current_search_paths} NO_DEFAULT_PATH)
endif()
find_library(_Qt5$${CMAKE_MODULE_NAME}_${Configuration}_${_lib}_PATH ${_lib})
mark_as_advanced(_Qt5$${CMAKE_MODULE_NAME}_${Configuration}_${_lib}_PATH)
@ -112,6 +120,7 @@ function(_qt5_$${CMAKE_MODULE_NAME}_process_prl_file prl_file_location Configura
else()
message(FATAL_ERROR \"Library not found: ${_lib}\")
endif()
unset(_framework_flag)
endif()
elseif(EXISTS \"${_flag}\")
# The flag is an absolute path to an existing library