Skip to content

Commit

Permalink
Make framework names consistent with the module names
Browse files Browse the repository at this point in the history
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 edbe0eb

Task-number: QTBUG-87775
Change-Id: I0592a28d0768724b6e10ca81aa7cefb0a3699a5e
Reviewed-by: Alexandru Croitor <[email protected]>
  • Loading branch information
semlanik committed Jun 3, 2021
1 parent a25027e commit 169a248
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
28 changes: 17 additions & 11 deletions cmake/QtFrameworkHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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()
10 changes: 5 additions & 5 deletions cmake/QtModuleHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}")
Expand Down Expand Up @@ -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}>"
Expand Down
2 changes: 1 addition & 1 deletion cmake/QtPriHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
3 changes: 2 additions & 1 deletion cmake/QtSeparateDebugInfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down

0 comments on commit 169a248

Please sign in to comment.