Move the framework related information to the common function

Since the information about framework is performed in multiple places
it's quite hard to control its consistency. This moves the obtaining
of framework related information to the common function and adjusts
the use of the information across the repo.

Change-Id: I1f488d41dcea75a1e8c361926792a6b7c45e5a3f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2021-05-26 20:48:58 +02:00
parent a1fd4f51ad
commit 4333bfd9d8
4 changed files with 62 additions and 26 deletions

View File

@ -64,12 +64,6 @@ function(qt_copy_framework_headers target)
set(multiValueArgs)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
get_target_property(fw_version ${target} FRAMEWORK_VERSION)
get_target_property(fw_bundle_version ${target} MACOSX_FRAMEWORK_BUNDLE_VERSION)
get_target_property(fw_dir ${target} LIBRARY_OUTPUT_DIRECTORY)
get_target_property(fw_name ${target} OUTPUT_NAME)
set(fw_headers_dir ${fw_dir}/${fw_name}.framework/Versions/${fw_version}/Headers/)
# 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)
@ -77,22 +71,28 @@ function(qt_copy_framework_headers target)
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)
string(APPEND fw_headers_dir "${fw_bundle_version}/${module}/private/")
set(fw_output_header_dir "${fw_private_header_dir}/${module}/private")
elseif(ARG_QPA)
string(APPEND fw_headers_dir "${fw_bundle_version}/${module}/qpa/")
set(fw_output_header_dir "${fw_private_header_dir}/${module}/qpa")
endif()
get_target_property(output_dir ${target} LIBRARY_OUTPUT_DIRECTORY)
set(fw_output_header_dir "${output_dir}/${fw_output_header_dir}")
set(out_files)
foreach(hdr IN LISTS ARG_UNPARSED_ARGUMENTS)
get_filename_component(in_file_path ${hdr} ABSOLUTE)
get_filename_component(in_file_name ${hdr} NAME)
set(out_file_path ${fw_headers_dir}${in_file_name})
set(out_file_path "${fw_output_header_dir}/${in_file_name}")
add_custom_command(
OUTPUT ${out_file_path}
DEPENDS ${in_file_path}
COMMAND ${CMAKE_COMMAND} -E make_directory "${fw_headers_dir}"
COMMAND ${CMAKE_COMMAND} -E copy "${in_file_path}" "${fw_headers_dir}")
COMMAND ${CMAKE_COMMAND} -E make_directory "${fw_output_header_dir}"
COMMAND ${CMAKE_COMMAND} -E copy "${in_file_path}" "${fw_output_header_dir}")
list(APPEND out_files ${out_file_path})
endforeach()
@ -132,3 +132,33 @@ function(qt_finalize_framework_headers_copy target)
add_dependencies(${target} ${target}_framework_headers)
endif()
endfunction()
# Collects the framework related information and paths from the target properties.
# Output variables:
# <out_var>_name framework base name, e.g. 'QtCore'.
# <out_var>_dir framework base directory, e.g. 'QtCore.framework'.
# <out_var>_version framework version, e.g. 'A', 'B' etc.
# <out_var>_bundle_version framework bundle version, same as the PROJECT_VERSION, e.g. '6.0.0'.
# <out_var>_header_dir top-level header directory, e.g. 'QtCore.framework/Headers'.
# <out_var>_versioned_header_dir header directory for specific framework version,
# 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'
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}")
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}_name "${${out_var}_name}" PARENT_SCOPE)
set(${out_var}_dir "${${out_var}_dir}" PARENT_SCOPE)
set(${out_var}_header_dir "${${out_var}_header_dir}" PARENT_SCOPE)
set(${out_var}_version "${${out_var}_version}" PARENT_SCOPE)
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)
endfunction()

View File

@ -387,19 +387,22 @@ function(qt_internal_add_module target)
endif()
if(is_framework)
set(fw_bundle_subdir "${INSTALL_LIBDIR}/Qt${target}.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}")
list(APPEND public_includes
# Add the lib/Foo.framework dir as include path to let CMake generate
# the -F compiler flag for framework-style includes to work.
"$<INSTALL_INTERFACE:${fw_bundle_subdir}>"
"$<INSTALL_INTERFACE:${fw_install_dir}>"
# Add the framework Headers subdir, so that non-framework-style includes work. The
# BUILD_INTERFACE Headers symlink was previously claimed not to exist at the relevant
# time, and a fully specified Header path was used instead. This doesn't seem to be a
# problem anymore.
"$<BUILD_INTERFACE:${QT_BUILD_DIR}/${fw_bundle_subdir}/Headers>"
"$<INSTALL_INTERFACE:${fw_bundle_subdir}/Headers>"
)
"$<BUILD_INTERFACE:${fw_output_header_dir}>"
"$<INSTALL_INTERFACE:${fw_install_header_dir}>"
)
endif()
if(NOT arg_NO_MODULE_HEADERS AND NOT arg_NO_SYNC_QT)
@ -696,11 +699,11 @@ set(QT_CMAKE_EXPORT_NAMESPACE ${QT_CMAKE_EXPORT_NAMESPACE})")
"$<BUILD_INTERFACE:${module_include_dir}/${PROJECT_VERSION}/${module}>")
if(is_framework)
set(fw_headers_dir
"${INSTALL_LIBDIR}/Qt${target}.framework/Headers/")
qt_internal_get_framework_info(fw ${target})
set(fw_install_private_header_dir "${INSTALL_LIBDIR}/${fw_private_header_dir}")
list(APPEND interface_includes
"$<INSTALL_INTERFACE:${fw_headers_dir}${PROJECT_VERSION}>"
"$<INSTALL_INTERFACE:${fw_headers_dir}${PROJECT_VERSION}/${module}>")
"$<INSTALL_INTERFACE:${fw_install_private_header_dir}>"
"$<INSTALL_INTERFACE:${fw_install_private_header_dir}/${module}>")
else()
list(APPEND interface_includes
"$<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}/${module}/${PROJECT_VERSION}>"

View File

@ -213,10 +213,12 @@ function(qt_generate_module_pri_file target)
endif()
if(is_fw)
set(framework_base_path "$$QT_MODULE_LIB_BASE/${module}.framework/Headers")
set(public_module_includes "${framework_base_path}")
set(public_module_frameworks "$$QT_MODULE_LIB_BASE")
set(private_module_includes "${framework_base_path}/${PROJECT_VERSION} ${framework_base_path}/${PROJECT_VERSION}/${module}")
qt_internal_get_framework_info(fw ${target})
set(framework_base_path "$$QT_MODULE_LIB_BASE")
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}")
set(module_name_in_pri "${module}")
else()
set(public_module_includes "$$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/${module}")

View File

@ -86,12 +86,13 @@ function(qt_apply_rpaths)
# Modify the install path to contain the nested structure of a framework.
get_target_property(is_framework "${target}" FRAMEWORK)
if(is_framework)
qt_internal_get_framework_info(fw ${target})
if(UIKIT)
# Shallow framework
string(APPEND arg_INSTALL_PATH "/Qt${target}.framework")
string(APPEND arg_INSTALL_PATH "/${fw_dir}")
else()
# Full framework
string(APPEND arg_INSTALL_PATH "/Qt${target}.framework/Versions/Current")
string(APPEND arg_INSTALL_PATH "/${fw_dir}/Versions/Current")
endif()
endif()