CMake: Fix usage requirements for static builds of Qt on macOS

When scanning the prl files to set up usage requirements for the Qt libraries
we omitted "-framework Foo" flags. Those were passed as linker flags, but not
as interface libraries. Consequently, the frameworks that are used by Qt
libraries were missing on the link line when building against a statically
built Qt.

Fix this issue by scanning the dependencies for "-framework Foo" just like we
do with "-lfoo" flags.

Fixes: QTBUG-80855
Change-Id: Ie7804304141c86207d143a6e1005e78bdc099113
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Kyle Edwards <kyle.edwards@kitware.com>
This commit is contained in:
Joerg Bornemann 2020-01-03 13:51:39 +01:00
parent 6b835d5e51
commit cca279338c

View File

@ -72,18 +72,28 @@ 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(_framework_flag)
string(REPLACE \"\\$\\$[QT_INSTALL_LIBS]\" \"${_qt5_install_libs}\" _static_depends \"${_static_depends}\")
foreach(_flag ${_static_depends})
string(REPLACE \"\\\"\" \"\" _flag ${_flag})
if(_flag MATCHES \"^-l(.*)$\")
# Handle normal libraries passed as -lfoo
set(_lib \"${CMAKE_MATCH_1}\")
foreach(_standard_library ${_standard_libraries})
if(_standard_library MATCHES \"^${_lib}(\\\\.lib)?$\")
set(_lib_is_default_linked TRUE)
break()
endif()
endforeach()
if(_flag MATCHES \"^-framework$\")
# Handle the next flag as framework name
set(_framework_flag 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
set(_lib \"${CMAKE_MATCH_1}\")
foreach(_standard_library ${_standard_libraries})
if(_standard_library MATCHES \"^${_lib}(\\\\.lib)?$\")
set(_lib_is_default_linked TRUE)
break()
endif()
endforeach()
endif()
if (_lib_is_default_linked)
unset(_lib_is_default_linked)
elseif(_lib MATCHES \"^pthread$\")