From 4333bfd9d8395705bae900ba0b5ab6b44bacb9a4 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Wed, 26 May 2021 20:48:58 +0200 Subject: [PATCH] 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 --- cmake/QtFrameworkHelpers.cmake | 52 +++++++++++++++++++++++++++------- cmake/QtModuleHelpers.cmake | 21 ++++++++------ cmake/QtPriHelpers.cmake | 10 ++++--- cmake/QtRpathHelpers.cmake | 5 ++-- 4 files changed, 62 insertions(+), 26 deletions(-) diff --git a/cmake/QtFrameworkHelpers.cmake b/cmake/QtFrameworkHelpers.cmake index 59555522e42..0c6486d3629 100644 --- a/cmake/QtFrameworkHelpers.cmake +++ b/cmake/QtFrameworkHelpers.cmake @@ -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: +# _name framework base name, e.g. 'QtCore'. +# _dir framework base directory, e.g. 'QtCore.framework'. +# _version framework version, e.g. 'A', 'B' etc. +# _bundle_version framework bundle version, same as the PROJECT_VERSION, e.g. '6.0.0'. +# _header_dir top-level header directory, e.g. 'QtCore.framework/Headers'. +# _versioned_header_dir header directory for specific framework version, +# e.g. 'QtCore.framework/Versions/A/Headers' +# _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() diff --git a/cmake/QtModuleHelpers.cmake b/cmake/QtModuleHelpers.cmake index 6beb281f82a..8193c51b4e9 100644 --- a/cmake/QtModuleHelpers.cmake +++ b/cmake/QtModuleHelpers.cmake @@ -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. - "$" + "$" # 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. - "$" - "$" - ) + "$" + "$" + ) 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})") "$") 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 - "$" - "$") + "$" + "$") else() list(APPEND interface_includes "$" diff --git a/cmake/QtPriHelpers.cmake b/cmake/QtPriHelpers.cmake index a44d3e8a081..9c5a9552597 100644 --- a/cmake/QtPriHelpers.cmake +++ b/cmake/QtPriHelpers.cmake @@ -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}") diff --git a/cmake/QtRpathHelpers.cmake b/cmake/QtRpathHelpers.cmake index bae222d813a..6e3414b50fa 100644 --- a/cmake/QtRpathHelpers.cmake +++ b/cmake/QtRpathHelpers.cmake @@ -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()