Make framework names consistent with the module names

For Apple's frameworks it's possible to include header files using the
following assumption:
If the framework name is "MyFramework" then
'#include <MyFramework/frameworkheader.h>' will work without specifying
the include path explicitly. This is broken for internal modules since
they use the framework name with the 'Private' suffix.

This uses the module name instead of the target name as a framework
name.

Amends edbe0eb335ca4c0fde23f57eae5acdf80937c9e3

Task-number: QTBUG-87775
Change-Id: I0592a28d0768724b6e10ca81aa7cefb0a3699a5e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2021-06-01 11:25:41 +02:00
parent a25027eecb
commit 169a248fdf
4 changed files with 25 additions and 18 deletions

View File

@ -64,20 +64,12 @@ function(qt_copy_framework_headers target)
set(multiValueArgs)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
# The module name might be different of the actual target name.
get_target_property(module_interface_name ${target} _qt_module_interface_name)
if(module_interface_name)
set(module "Qt${module_interface_name}")
else()
set(module "Qt${target}")
endif()
qt_internal_get_framework_info(fw ${target})
set(fw_output_header_dir "${fw_versioned_header_dir}")
if(ARG_PRIVATE)
set(fw_output_header_dir "${fw_private_header_dir}/${module}/private")
set(fw_output_header_dir "${fw_private_module_header_dir}/private")
elseif(ARG_QPA)
set(fw_output_header_dir "${fw_private_header_dir}/${module}/qpa")
set(fw_output_header_dir "${fw_private_module_header_dir}/qpa")
endif()
get_target_property(output_dir ${target} LIBRARY_OUTPUT_DIRECTORY)
@ -144,15 +136,28 @@ endfunction()
# e.g. 'QtCore.framework/Versions/A/Headers'
# <out_var>_private_header_dir header directory for the specific framework version and
# framework bundle version e.g. 'QtCore.framework/Versions/A/Headers/6.0.0'
# <out_var>_private_module_header_dir private header directory for the specific framework
# version, framework bundle version and tailing module name, e.g.
# 'QtCore.framework/Versions/A/Headers/6.0.0/Core'
function(qt_internal_get_framework_info out_var target)
get_target_property(${out_var}_version ${target} FRAMEWORK_VERSION)
get_target_property(${out_var}_bundle_version ${target} MACOSX_FRAMEWORK_BUNDLE_VERSION)
set(${out_var}_name "Qt${target}")
# The module name might be different of the actual target name
# and we want to use the Qt'fied module name as a framework identifier.
get_target_property(module_interface_name ${target} _qt_module_interface_name)
if(module_interface_name)
qt_internal_qtfy_target(module ${module_interface_name})
else()
qt_internal_qtfy_target(module ${target})
endif()
set(${out_var}_name "${module}")
set(${out_var}_dir "${${out_var}_name}.framework")
set(${out_var}_header_dir "${${out_var}_dir}/Headers")
set(${out_var}_versioned_header_dir "${${out_var}_dir}/Versions/${${out_var}_version}/Headers")
set(${out_var}_private_header_dir "${${out_var}_header_dir}/${${out_var}_bundle_version}")
set(${out_var}_private_module_header_dir "${${out_var}_private_header_dir}/${module}")
set(${out_var}_name "${${out_var}_name}" PARENT_SCOPE)
set(${out_var}_dir "${${out_var}_dir}" PARENT_SCOPE)
@ -161,4 +166,5 @@ function(qt_internal_get_framework_info out_var target)
set(${out_var}_bundle_version "${${out_var}_bundle_version}" PARENT_SCOPE)
set(${out_var}_versioned_header_dir "${${out_var}_versioned_header_dir}" PARENT_SCOPE)
set(${out_var}_private_header_dir "${${out_var}_private_header_dir}" PARENT_SCOPE)
set(${out_var}_private_module_header_dir "${${out_var}_private_module_header_dir}" PARENT_SCOPE)
endfunction()

View File

@ -153,10 +153,11 @@ function(qt_internal_add_module target)
set_target_properties(${target} PROPERTIES
FRAMEWORK TRUE
FRAMEWORK_VERSION "A" # Not based on Qt major version
MACOSX_FRAMEWORK_IDENTIFIER org.qt-project.Qt${target}
MACOSX_FRAMEWORK_IDENTIFIER org.qt-project.${module}
MACOSX_FRAMEWORK_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
)
qt_internal_get_framework_info(fw ${target})
endif()
if(QT_FEATURE_reduce_relocations AND UNIX AND NOT is_interface_lib)
@ -246,7 +247,7 @@ function(qt_internal_add_module target)
endif()
if(is_framework)
set_target_properties(${target} PROPERTIES
OUTPUT_NAME Qt${target}
OUTPUT_NAME ${fw_name}
)
else()
set_target_properties(${target} PROPERTIES
@ -387,7 +388,6 @@ function(qt_internal_add_module target)
endif()
if(is_framework)
qt_internal_get_framework_info(fw ${target})
set(fw_install_dir "${INSTALL_LIBDIR}/${fw_dir}")
set(fw_install_header_dir "${INSTALL_LIBDIR}/${fw_header_dir}")
set(fw_output_header_dir "${QT_BUILD_DIR}/${fw_install_header_dir}")
@ -699,11 +699,11 @@ set(QT_CMAKE_EXPORT_NAMESPACE ${QT_CMAKE_EXPORT_NAMESPACE})")
"$<BUILD_INTERFACE:${module_include_dir}/${PROJECT_VERSION}/${module}>")
if(is_framework)
qt_internal_get_framework_info(fw ${target})
set(fw_install_private_header_dir "${INSTALL_LIBDIR}/${fw_private_header_dir}")
set(fw_install_private_module_header_dir "${INSTALL_LIBDIR}/${fw_private_module_header_dir}")
list(APPEND interface_includes
"$<INSTALL_INTERFACE:${fw_install_private_header_dir}>"
"$<INSTALL_INTERFACE:${fw_install_private_header_dir}/${module}>")
"$<INSTALL_INTERFACE:${fw_install_private_module_header_dir}>")
else()
list(APPEND interface_includes
"$<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}/${module}/${PROJECT_VERSION}>"

View File

@ -220,7 +220,7 @@ function(qt_generate_module_pri_file target)
set(public_module_includes "${framework_base_path}/${fw_header_dir}")
set(public_module_frameworks "${framework_base_path}")
set(private_module_includes "${framework_base_path}/${fw_private_header_dir} \
${framework_base_path}/${fw_private_header_dir}/${module}")
${framework_base_path}/${fw_private_module_header_dir}")
set(module_name_in_pri "${module}")
else()
set(public_module_includes "$$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/${module}")

View File

@ -48,8 +48,9 @@ function(qt_enable_separate_debug_info target installDestination)
if(APPLE)
get_target_property(is_framework ${target} FRAMEWORK)
if(is_framework)
qt_internal_get_framework_info(fw ${target})
set(debug_info_bundle_dir "$<TARGET_BUNDLE_DIR:${target}>.${debug_info_suffix}")
set(BUNDLE_ID Qt${target})
set(BUNDLE_ID ${fw_name})
else()
set(debug_info_bundle_dir "$<TARGET_FILE:${target}>.${debug_info_suffix}")
set(BUNDLE_ID ${target})