CMake: Add support for pkg-config files on macOS
This enables generation of pkg-config files that work with Qt's libdir-installed macOS frameworks. QtFinishPkgConfigFile.cmake wasn't modified as POSTFIX has no impact on framework name. Change-Id: I2da8f43608e778aa286ad625b70c5be20b447193 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> (cherry picked from commit 7a31e402f24ec29c571f825e06bd569477501dfc) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
3009ca730d
commit
224fc1daaa
@ -9,6 +9,6 @@ $<1: >
|
|||||||
Name: @pkgconfig_name@
|
Name: @pkgconfig_name@
|
||||||
Description: @pkgconfig_description@
|
Description: @pkgconfig_description@
|
||||||
Version: @PROJECT_VERSION@
|
Version: @PROJECT_VERSION@
|
||||||
Libs: $<$<NOT:@is_interface_library@>:-L${libdir} -l@pkgconfig_file@> @link_options@
|
Libs: @link_options@
|
||||||
Cflags: @include_dirs@ @compile_defs@
|
Cflags: @include_dirs@ @compile_defs@
|
||||||
Requires: $<JOIN:$<REMOVE_DUPLICATES:@target_requires@>, >
|
Requires: $<JOIN:$<REMOVE_DUPLICATES:@target_requires@>, >
|
||||||
|
@ -22,8 +22,7 @@ endmacro()
|
|||||||
# Create a Qt6*.pc file intended for pkg-config consumption.
|
# Create a Qt6*.pc file intended for pkg-config consumption.
|
||||||
function(qt_internal_generate_pkg_config_file module)
|
function(qt_internal_generate_pkg_config_file module)
|
||||||
# TODO: PkgConfig is supported under MSVC with pkgconf (github.com/pkgconf/pkgconf)
|
# TODO: PkgConfig is supported under MSVC with pkgconf (github.com/pkgconf/pkgconf)
|
||||||
if((NOT UNIX OR QT_FEATURE_framework)
|
if(NOT UNIX AND NOT MINGW OR CMAKE_VERSION VERSION_LESS "3.20" OR ANDROID)
|
||||||
AND NOT MINGW OR CMAKE_VERSION VERSION_LESS "3.20" OR ANDROID)
|
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
if(NOT BUILD_SHARED_LIBS)
|
if(NOT BUILD_SHARED_LIBS)
|
||||||
@ -34,7 +33,6 @@ function(qt_internal_generate_pkg_config_file module)
|
|||||||
set(pkgconfig_name "${QT_CMAKE_EXPORT_NAMESPACE} ${module}")
|
set(pkgconfig_name "${QT_CMAKE_EXPORT_NAMESPACE} ${module}")
|
||||||
set(pkgconfig_description "Qt ${module} module")
|
set(pkgconfig_description "Qt ${module} module")
|
||||||
set(target "${QT_CMAKE_EXPORT_NAMESPACE}::${module}")
|
set(target "${QT_CMAKE_EXPORT_NAMESPACE}::${module}")
|
||||||
set(is_interface_library "$<STREQUAL:$<TARGET_PROPERTY:${target},TYPE>,INTERFACE_LIBRARY>")
|
|
||||||
# The flags macro expanded this variables so it's better to set them at
|
# The flags macro expanded this variables so it's better to set them at
|
||||||
# their corresponding PkgConfig string.
|
# their corresponding PkgConfig string.
|
||||||
set(includedir "\${includedir}")
|
set(includedir "\${includedir}")
|
||||||
@ -50,6 +48,12 @@ function(qt_internal_generate_pkg_config_file module)
|
|||||||
get_target_property(loose_include_dirs ${target} INTERFACE_INCLUDE_DIRECTORIES)
|
get_target_property(loose_include_dirs ${target} INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
list(TRANSFORM loose_include_dirs REPLACE "${INSTALL_INCLUDEDIR}" "\${includedir}")
|
list(TRANSFORM loose_include_dirs REPLACE "${INSTALL_INCLUDEDIR}" "\${includedir}")
|
||||||
list(TRANSFORM loose_include_dirs REPLACE "${INSTALL_MKSPECSDIR}" "\${mkspecsdir}")
|
list(TRANSFORM loose_include_dirs REPLACE "${INSTALL_MKSPECSDIR}" "\${mkspecsdir}")
|
||||||
|
if(QT_FEATURE_framework)
|
||||||
|
# Update the include path for framework headers which are located in INSTALL_LIBDIR,
|
||||||
|
# e.g. this results in -I${libdir}/Qt*.framework/Headers for Qt6*.pc file.
|
||||||
|
set(libdir "\${libdir}")
|
||||||
|
list(TRANSFORM loose_include_dirs REPLACE "${INSTALL_LIBDIR}" "\${libdir}")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Remove genex wrapping around gc_sections flag because we can't evaluate genexes like
|
# Remove genex wrapping around gc_sections flag because we can't evaluate genexes like
|
||||||
# $<CXX_COMPILER_ID> in file(GENERATE). And given that .pc files don't support dynamic
|
# $<CXX_COMPILER_ID> in file(GENERATE). And given that .pc files don't support dynamic
|
||||||
@ -69,6 +73,17 @@ function(qt_internal_generate_pkg_config_file module)
|
|||||||
set(contains_mkspecs TRUE)
|
set(contains_mkspecs TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
get_target_property(type ${target} TYPE)
|
||||||
|
if(NOT type STREQUAL "INTERFACE_LIBRARY")
|
||||||
|
get_target_property(is_framework ${target} FRAMEWORK)
|
||||||
|
if(is_framework)
|
||||||
|
qt_internal_get_framework_info(fw ${target})
|
||||||
|
string(PREPEND link_options "-F\${libdir} -framework ${fw_name} ")
|
||||||
|
else()
|
||||||
|
string(PREPEND link_options "-L\${libdir} -l${pkgconfig_file} ")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# TODO: Handle macOS framework builds
|
# TODO: Handle macOS framework builds
|
||||||
qt_internal_collect_direct_target_dependencies(${target} loose_target_requires)
|
qt_internal_collect_direct_target_dependencies(${target} loose_target_requires)
|
||||||
foreach(dep IN LISTS loose_target_requires)
|
foreach(dep IN LISTS loose_target_requires)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user