summaryrefslogtreecommitdiffstats
path: root/src/corelib/Qt6CoreMacros.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/Qt6CoreMacros.cmake')
-rw-r--r--src/corelib/Qt6CoreMacros.cmake2073
1 files changed, 1313 insertions, 760 deletions
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake
index 1612d23b10..f55e32a7cf 100644
--- a/src/corelib/Qt6CoreMacros.cmake
+++ b/src/corelib/Qt6CoreMacros.cmake
@@ -1,6 +1,6 @@
# Copyright 2005-2011 Kitware, Inc.
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: (LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0) AND BSD-3-Clause
+# SPDX-License-Identifier: BSD-3-Clause
######################################
#
@@ -8,8 +8,6 @@
#
######################################
-include(CMakeParseArguments)
-
set(__qt_core_macros_module_base_dir "${CMAKE_CURRENT_LIST_DIR}")
# macro used to create the names of output files preserving relative dirs
@@ -95,24 +93,43 @@ function(_qt_internal_create_moc_command infile outfile moc_flags moc_options
set(extra_output_files "${outfile}.json")
set(${out_json_file} "${extra_output_files}" PARENT_SCOPE)
endif()
- string (REPLACE ";" "\n" _moc_parameters "${_moc_parameters}")
if(moc_target)
- set(_moc_parameters_file ${_moc_parameters_file}$<$<BOOL:$<CONFIGURATION>>:_$<CONFIGURATION>>)
+ set(_moc_parameters_file ${_moc_parameters_file}$<$<BOOL:$<CONFIG>>:_$<CONFIG>>)
set(targetincludes "$<TARGET_PROPERTY:${moc_target},INCLUDE_DIRECTORIES>")
set(targetdefines "$<TARGET_PROPERTY:${moc_target},COMPILE_DEFINITIONS>")
- set(targetincludes "$<$<BOOL:${targetincludes}>:-I$<JOIN:$<REMOVE_DUPLICATES:${targetincludes}>,\n-I>\n>")
- set(targetdefines "$<$<BOOL:${targetdefines}>:-D$<JOIN:$<REMOVE_DUPLICATES:${targetdefines}>,\n-D>\n>")
+ set(targetincludes "$<$<BOOL:${targetincludes}>:-I$<JOIN:${targetincludes},;-I>>")
+ set(targetdefines "$<$<BOOL:${targetdefines}>:-D$<JOIN:${targetdefines},;-D>>")
+ set(_moc_parameters_list_without_genex)
+ set(_moc_parameters_list_with_genex)
+ foreach(_moc_parameter ${_moc_parameters})
+ if(_moc_parameter MATCHES "\\\$<")
+ list(APPEND _moc_parameters_list_with_genex ${_moc_parameter})
+ else()
+ list(APPEND _moc_parameters_list_without_genex ${_moc_parameter})
+ endif()
+ endforeach()
+
+ string(REPLACE ">" "$<ANGLE-R>" _moc_escaped_parameters "${_moc_parameters_list_without_genex}")
+ string(REPLACE "," "$<COMMA>" _moc_escaped_parameters "${_moc_escaped_parameters}")
+ string(REPLACE ";" "$<SEMICOLON>" _moc_escaped_parameters "${_moc_escaped_parameters}")
+ set(concatenated "$<$<BOOL:${targetincludes}>:${targetincludes};>$<$<BOOL:${targetdefines}>:${targetdefines};>$<$<BOOL:${_moc_escaped_parameters}>:${_moc_escaped_parameters};>")
+
+ list(APPEND concatenated ${_moc_parameters_list_with_genex})
+ set(concatenated "$<FILTER:$<REMOVE_DUPLICATES:${concatenated}>,EXCLUDE,^-[DI]$>")
+ set(concatenated "$<JOIN:${concatenated},\n>")
file (GENERATE
OUTPUT ${_moc_parameters_file}
- CONTENT "${targetdefines}${targetincludes}${_moc_parameters}\n"
+ CONTENT "${concatenated}"
)
+ set(concatenated)
set(targetincludes)
set(targetdefines)
else()
+ string (REPLACE ";" "\n" _moc_parameters "${_moc_parameters}")
file(WRITE ${_moc_parameters_file} "${_moc_parameters}\n")
endif()
@@ -123,8 +140,12 @@ function(_qt_internal_create_moc_command infile outfile moc_flags moc_options
${_moc_working_dir}
VERBATIM)
set_source_files_properties(${infile} PROPERTIES SKIP_AUTOMOC ON)
- set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC ON)
- set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOUIC ON)
+ set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC ON
+ SKIP_AUTOUIC ON
+ )
+ if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.27")
+ set_source_files_properties(${outfile} PROPERTIES SKIP_LINTING ON)
+ endif()
endfunction()
function(qt6_generate_moc infile outfile )
@@ -179,7 +200,49 @@ function(qt6_wrap_cpp outfiles )
foreach(it ${moc_files})
get_filename_component(it ${it} ABSOLUTE)
- _qt_internal_make_output_file(${it} moc_ cpp outfile)
+ get_filename_component(it_ext ${it} EXT)
+ # remove the dot
+ string(SUBSTRING ${it_ext} 1 -1 it_ext)
+ set(HEADER_REGEX "(h|hh|h\\+\\+|hm|hpp|hxx|in|txx|inl)$")
+
+ if(it_ext MATCHES "${HEADER_REGEX}")
+ _qt_internal_make_output_file("${it}" moc_ cpp outfile)
+ set(is_header_file TRUE)
+ else()
+ set(found_source_extension FALSE)
+ foreach(LANG C CXX OBJC OBJCXX CUDA)
+ list(FIND CMAKE_${LANG}_SOURCE_FILE_EXTENSIONS "${it_ext}"
+ index)
+ if(${index} GREATER -1)
+ set(found_extension TRUE)
+ break()
+ endif()
+ endforeach()
+ if(found_extension)
+ if(TARGET ${moc_target})
+ _qt_internal_make_output_file(${it} "" moc outfile)
+ target_sources(${moc_target} PRIVATE "${outfile}")
+ target_include_directories("${moc_target}" PRIVATE
+ "${CMAKE_CURRENT_BINARY_DIR}")
+ else()
+ if("${moc_target}" STREQUAL "")
+ string(JOIN "" err_msg
+ "qt6_wrap_cpp: TARGET parameter is empty. "
+ "Since the file ${it} is a source file, "
+ "the TARGET option must be specified.")
+ else()
+ string(JOIN "" err_msg
+ "qt6_wrap_cpp: TARGET \"${moc_target}\" "
+ "not found.")
+ endif()
+ message(FATAL_ERROR "${err_msg}")
+ endif()
+ else()
+ string(JOIN "" err_msg "qt6_wrap_cpp: Unknown file extension: "
+ "\"\.${it_ext}\".")
+ message(FATAL_ERROR "${err_msg}")
+ endif()
+ endif()
set(out_json_file_var "")
if(_WRAP_CPP___QT_INTERNAL_OUTPUT_MOC_JSON_FILES)
@@ -194,7 +257,10 @@ function(qt6_wrap_cpp outfiles )
list(APPEND metatypes_json_list "${${out_json_file_var}}")
endif()
endforeach()
- set(${outfiles} ${${outfiles}} PARENT_SCOPE)
+
+ if(is_header_file)
+ set(${outfiles} "${${outfiles}}" PARENT_SCOPE)
+ endif()
if(metatypes_json_list)
set(${_WRAP_CPP___QT_INTERNAL_OUTPUT_MOC_JSON_FILES}
@@ -436,6 +502,9 @@ function(qt6_add_big_resources outfiles )
_qt6_parse_qrc_file(${infile} _out_depends _rc_depends)
set_source_files_properties(${infile} PROPERTIES SKIP_AUTOGEN ON)
+ if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.27")
+ set_source_files_properties(${tmpoutfile} PROPERTIES SKIP_LINTING ON)
+ endif()
add_custom_command(OUTPUT ${tmpoutfile}
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::rcc ${rcc_options} --name ${outfilename} --pass 1 --output ${tmpoutfile} ${infile}
DEPENDS ${infile} ${_rc_depends} "${out_depends}" ${QT_CMAKE_EXPORT_NAMESPACE}::rcc
@@ -541,9 +610,6 @@ endfunction()
set(_Qt6_COMPONENT_PATH "${CMAKE_CURRENT_LIST_DIR}/..")
-# This function is currently in Technical Preview.
-# It's signature and behavior might change.
-#
# Wrapper function that adds an executable with some Qt specific behavior.
# Some scenarios require steps to be deferred to the end of the current
# directory scope so that the caller has an opportunity to modify certain
@@ -551,8 +617,11 @@ set(_Qt6_COMPONENT_PATH "${CMAKE_CURRENT_LIST_DIR}/..")
function(qt6_add_executable target)
cmake_parse_arguments(PARSE_ARGV 1 arg "MANUAL_FINALIZATION" "" "")
+ _qt_internal_warn_about_example_add_subdirectory()
+
_qt_internal_create_executable("${target}" ${arg_UNPARSED_ARGUMENTS})
target_link_libraries("${target}" PRIVATE Qt6::Core)
+ set_property(TARGET ${target} PROPERTY _qt_expects_finalization TRUE)
if(arg_MANUAL_FINALIZATION)
# Caller says they will call qt6_finalize_target() themselves later
@@ -572,6 +641,21 @@ function(qt6_add_executable target)
endif()
endfunction()
+# Just like for qt_add_resources, we should disable zstd compression when cross-compiling to a
+# target that doesn't support zstd decompression, even if the host tool supports it.
+# Allow an opt out via a QT_NO_AUTORCC_ZSTD variable.
+function(_qt_internal_disable_autorcc_zstd_when_not_supported target)
+ if(TARGET "${target}"
+ AND DEFINED QT_FEATURE_zstd
+ AND NOT QT_FEATURE_zstd
+ AND NOT QT_NO_AUTORCC_ZSTD)
+ get_target_property(target_type ${target} TYPE)
+ if(NOT target_type STREQUAL "INTERFACE_LIBRARY")
+ set_property(TARGET "${target}" APPEND PROPERTY AUTORCC_OPTIONS "--no-zstd")
+ endif()
+ endif()
+endfunction()
+
function(_qt_internal_create_executable target)
if(ANDROID)
list(REMOVE_ITEM ARGN "WIN32" "MACOSX_BUNDLE")
@@ -584,24 +668,19 @@ function(_qt_internal_create_executable target)
set_property(TARGET "${target}" PROPERTY CXX_VISIBILITY_PRESET default)
set_property(TARGET "${target}" PROPERTY OBJC_VISIBILITY_PRESET default)
set_property(TARGET "${target}" PROPERTY OBJCXX_VISIBILITY_PRESET default)
+ set_property(TARGET "${target}"
+ PROPERTY _qt_android_apply_arch_suffix_called_from_qt_impl TRUE)
qt6_android_apply_arch_suffix("${target}")
set_property(TARGET "${target}" PROPERTY _qt_is_android_executable TRUE)
else()
add_executable("${target}" ${ARGN})
endif()
+ _qt_internal_disable_autorcc_zstd_when_not_supported("${target}")
_qt_internal_set_up_static_runtime_library("${target}")
endfunction()
function(_qt_internal_finalize_executable target)
- get_target_property(is_finalized "${target}" _qt_executable_is_finalized)
- if(is_finalized)
- message(AUTHOR_WARNING
- "Tried to call qt6_finalize_target twice on executable: '${target}'. \
- Did you forget to specify MANUAL_FINALIZATION to qt6_add_executable?")
- return()
- endif()
-
# We can't evaluate generator expressions at configure time, so we can't
# ask for any transitive properties or even the full library dependency
# chain.
@@ -650,6 +729,8 @@ function(_qt_internal_finalize_executable target)
if(EMSCRIPTEN)
_qt_internal_wasm_add_target_helpers("${target}")
+ _qt_internal_add_wasm_extra_exported_methods("${target}")
+ _qt_internal_set_wasm_export_name("${target}")
endif()
if(IOS)
_qt_internal_finalize_ios_app("${target}")
@@ -667,8 +748,26 @@ function(_qt_internal_finalize_executable target)
__qt_internal_apply_plugin_imports_finalizer_mode("${target}")
__qt_internal_process_dependency_object_libraries("${target}")
endif()
+endfunction()
+
+function(_cat IN_FILE OUT_FILE)
+ file(READ ${IN_FILE} CONTENTS)
+ file(APPEND ${OUT_FILE} "${CONTENTS}\n")
+endfunction()
+
+function(_qt_internal_finalize_batch name)
+ find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Core)
- set_target_properties(${target} PROPERTIES _qt_executable_is_finalized TRUE)
+ set(generated_blacklist_file "${CMAKE_CURRENT_BINARY_DIR}/BLACKLIST")
+ get_target_property(blacklist_files "${name}" _qt_blacklist_files)
+ file(WRITE "${generated_blacklist_file}" "")
+ foreach(blacklist_file ${blacklist_files})
+ _cat("${blacklist_file}" "${generated_blacklist_file}")
+ endforeach()
+ qt_internal_add_resource(${name} "batch_blacklist"
+ PREFIX "/"
+ FILES "${CMAKE_CURRENT_BINARY_DIR}/BLACKLIST"
+ BASE ${CMAKE_CURRENT_BINARY_DIR})
endfunction()
# If a task needs to run before any targets are finalized in the current directory
@@ -678,6 +777,7 @@ function(_qt_internal_delay_finalization_until_after defer_id)
endfunction()
function(qt6_finalize_target target)
+ set_property(TARGET ${target} PROPERTY _qt_expects_finalization FALSE)
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.19")
cmake_language(DEFER GET_CALL_IDS ids_queued)
get_directory_property(wait_for_ids qt_internal_finalizers_wait_for_ids)
@@ -703,620 +803,112 @@ function(qt6_finalize_target target)
message(FATAL_ERROR "No target '${target}' found in current scope.")
endif()
+ get_target_property(is_finalized "${target}" _qt_is_finalized)
+ if(is_finalized)
+ message(AUTHOR_WARNING
+ "Tried to call qt6_finalize_target twice on target '${target}'. "
+ "Did you forget to specify MANUAL_FINALIZATION to qt6_add_executable, "
+ "qt6_add_library or qt6_add_plugin?")
+ return()
+ endif()
+
+ _qt_internal_expose_deferred_files_to_ide(${target})
+ _qt_internal_finalize_source_groups(${target})
get_target_property(target_type ${target} TYPE)
get_target_property(is_android_executable "${target}" _qt_is_android_executable)
if(target_type STREQUAL "EXECUTABLE" OR is_android_executable)
_qt_internal_finalize_executable(${ARGV})
endif()
-endfunction()
-
-function(_qt_internal_handle_ios_launch_screen target)
- # Check if user provided a launch screen path via a variable.
- set(launch_screen "")
-
- # Check if the project provided a launch screen path via a variable.
- # This variable is currently in Technical Preview.
- if(QT_IOS_LAUNCH_SCREEN)
- set(launch_screen "${QT_IOS_LAUNCH_SCREEN}")
- endif()
-
- # Check if the project provided a launch screen path via a target property, it takes precedence
- # over the variable.
- # This property is currently in Technical Preview.
- get_target_property(launch_screen_from_prop "${target}" QT_IOS_LAUNCH_SCREEN)
- if(launch_screen_from_prop)
- set(launch_screen "${launch_screen_from_prop}")
- endif()
-
- # If the project hasn't provided a launch screen file path, use a copy of the template
- # that qmake uses.
- # It needs to be a copy because configure_file can't handle all the escaped double quotes
- # present in the qmake template file.
- set(is_default_launch_screen FALSE)
- if(NOT launch_screen AND NOT QT_NO_SET_DEFAULT_IOS_LAUNCH_SCREEN)
- set(is_default_launch_screen TRUE)
- set(launch_screen
- "${__qt_internal_cmake_ios_support_files_path}/LaunchScreen.storyboard")
- endif()
-
- # Check that the launch screen exists.
- if(launch_screen)
- if(NOT IS_ABSOLUTE "${launch_screen}")
- message(FATAL_ERROR
- "Provided launch screen value should be an absolute path: '${launch_screen}'")
- endif()
- if(NOT EXISTS "${launch_screen}")
- message(FATAL_ERROR
- "Provided launch screen file does not exist: '${launch_screen}'")
+ if(APPLE)
+ # Tell CMake to generate run-scheme for the executable when generating
+ # Xcode projects. This avoids Xcode auto-generating default schemes for
+ # all targets, which includes internal and build-only targets.
+ get_target_property(generate_scheme "${target}" XCODE_GENERATE_SCHEME)
+ if(generate_scheme MATCHES "-NOTFOUND" AND (
+ target_type STREQUAL "EXECUTABLE" OR
+ target_type STREQUAL "SHARED_LIBRARY" OR
+ target_type STREQUAL "STATIC_LIBRARY" OR
+ target_type STREQUAL "MODULE_LIBRARY"))
+ set_property(TARGET "${target}" PROPERTY XCODE_GENERATE_SCHEME TRUE)
endif()
endif()
- if(launch_screen AND NOT QT_NO_ADD_IOS_LAUNCH_SCREEN_TO_BUNDLE)
- get_filename_component(launch_screen_name "${launch_screen}" NAME)
-
- # Make a copy of the default launch screen template for this target and replace the
- # label inside the template with the target name.
- if(is_default_launch_screen)
- # Configure our default template and place it in the build dir.
- set(launch_screen_in_path "${launch_screen}")
-
- string(MAKE_C_IDENTIFIER "${target}" target_identifier)
- set(launch_screen_out_dir
- "${CMAKE_CURRENT_BINARY_DIR}/.qt/launch_screen_storyboards/${target_identifier}")
-
- set(launch_screen_out_path
- "${launch_screen_out_dir}/${launch_screen_name}")
-
- file(MAKE_DIRECTORY "${launch_screen_out_dir}")
-
- # Replaces the value in the default template.
- set(QT_IOS_LAUNCH_SCREEN_TEXT "${target}")
- configure_file(
- "${launch_screen_in_path}"
- "${launch_screen_out_path}"
- @ONLY
- )
-
- set(final_launch_screen_path "${launch_screen_out_path}")
- else()
- set(final_launch_screen_path "${launch_screen}")
- endif()
-
- # Add the launch screen storyboard file as a source file, otherwise CMake doesn't consider
- # it as a resource file and MACOSX_PACKAGE_LOCATION processing will be skipped.
- target_sources("${target}" PRIVATE "${final_launch_screen_path}")
-
- # Ensure Xcode compiles the storyboard file and installs the compiled storyboard .nib files
- # into the app bundle.
- # We use target_sources and the MACOSX_PACKAGE_LOCATION source file property for that
- # instead of the RESOURCE target property, becaues the latter could potentially end up
- # needlessly installing the source storyboard file.
- #
- # We can't rely on policy CMP0118 since user project controls it.
- set(scope_args)
- if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
- set(scope_args TARGET_DIRECTORY ${target})
- endif()
- set_source_files_properties("${final_launch_screen_path}" ${scope_args}
- PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
-
- # Save the launch screen name, so its value is added as an UILaunchStoryboardName entry
- # in the Qt generated Info.plist file.
- set_target_properties("${target}" PROPERTIES
- _qt_ios_launch_screen_name "${launch_screen_name}"
- _qt_ios_launch_screen_path "${final_launch_screen_path}")
- endif()
+ set_target_properties(${target} PROPERTIES _qt_is_finalized TRUE)
endfunction()
-function(_qt_internal_find_ios_development_team_id out_var)
- get_property(team_id GLOBAL PROPERTY _qt_internal_ios_development_team_id)
- get_property(team_id_computed GLOBAL PROPERTY _qt_internal_ios_development_team_id_computed)
- if(team_id_computed)
- # Just in case if the value is non-empty but still booly FALSE.
- if(NOT team_id)
- set(team_id "")
- endif()
- set("${out_var}" "${team_id}" PARENT_SCOPE)
+function(_qt_internal_finalize_source_groups target)
+ if(NOT ("${CMAKE_GENERATOR}" STREQUAL "Xcode"
+ OR "${CMAKE_GENERATOR}" MATCHES "^Visual Studio"))
return()
endif()
- set_property(GLOBAL PROPERTY _qt_internal_ios_development_team_id_computed "TRUE")
-
- set(home_dir "$ENV{HOME}")
- set(xcode_preferences_path "${home_dir}/Library/Preferences/com.apple.dt.Xcode.plist")
-
- # Extract the first account name (email) from the user's Xcode preferences
- message(DEBUG "Trying to extract an Xcode development team id from '${xcode_preferences_path}'")
- execute_process(COMMAND "/usr/libexec/PlistBuddy"
- -x -c "print IDEProvisioningTeams" "${xcode_preferences_path}"
- OUTPUT_VARIABLE teams_xml
- ERROR_VARIABLE plist_error)
-
- # Parsing state.
- set(is_free "")
- set(current_team_id "")
- set(parsing_is_free FALSE)
- set(parsing_team_id FALSE)
- set(first_team_id "")
-
- # Parse the xml output and return the first encountered non-free team id. If no non-free team id
- # is found, return the first encountered free team id.
- # If no team is found, return an empty string.
- #
- # Example input:
- #<plist version="1.0">
- #<dict>
- # <key>marty@planet.local</key>
- # <array>
- # <dict>
- # <key>isFreeProvisioningTeam</key>
- # <false/>
- # <key>teamID</key>
- # <string>AAA</string>
- # ...
- # </dict>
- # <dict>
- # <key>isFreeProvisioningTeam</key>
- # <true/>
- # <key>teamID</key>
- # <string>BBB</string>
- # ...
- # </dict>
- # </array>
- #</dict>
- #</plist>
- if(teams_xml AND NOT plist_error)
- string(REPLACE "\n" ";" teams_xml_lines "${teams_xml}")
-
- foreach(xml_line ${teams_xml_lines})
- string(STRIP "${xml_line}" xml_line)
- if(xml_line STREQUAL "<dict>")
- # Clean any previously found values when a new team dict is matched.
- set(is_free "")
- set(current_team_id "")
-
- elseif(xml_line STREQUAL "<key>isFreeProvisioningTeam</key>")
- set(parsing_is_free TRUE)
-
- elseif(parsing_is_free)
- set(parsing_is_free FALSE)
-
- if(xml_line MATCHES "true")
- set(is_free TRUE)
- else()
- set(is_free FALSE)
- endif()
-
- elseif(xml_line STREQUAL "<key>teamID</key>")
- set(parsing_team_id TRUE)
-
- elseif(parsing_team_id)
- set(parsing_team_id FALSE)
- if(xml_line MATCHES "<string>([^<]+)</string>")
- set(current_team_id "${CMAKE_MATCH_1}")
- else()
- continue()
- endif()
-
- string(STRIP "${current_team_id}" current_team_id)
-
- # If this is the first team id we found so far, remember that, regardless if's free
- # or not.
- if(NOT first_team_id AND current_team_id)
- set(first_team_id "${current_team_id}")
- endif()
-
- # Break early if we found a non-free team id and use it, because we prefer
- # a non-free team for signing, just like qmake.
- if(NOT is_free AND current_team_id)
- set(first_team_id "${current_team_id}")
- break()
- endif()
- endif()
- endforeach()
- endif()
-
- if(NOT first_team_id)
- message(DEBUG "Failed to extract an Xcode development team id.")
- set("${out_var}" "" PARENT_SCOPE)
- else()
- message(DEBUG "Successfully extracted the first encountered Xcode development team id.")
- set_property(GLOBAL PROPERTY _qt_internal_ios_development_team_id "${first_team_id}")
- set("${out_var}" "${first_team_id}" PARENT_SCOPE)
- endif()
-endfunction()
-
-function(_qt_internal_get_ios_bundle_identifier_prefix out_var)
- get_property(prefix GLOBAL PROPERTY _qt_internal_ios_bundle_identifier_prefix)
- get_property(prefix_computed GLOBAL PROPERTY
- _qt_internal_ios_bundle_identifier_prefix_computed)
- if(prefix_computed)
- # Just in case if the value is non-empty but still booly FALSE.
- if(NOT prefix)
- set(prefix "")
- endif()
- set("${out_var}" "${prefix}" PARENT_SCOPE)
+ get_target_property(sources ${target} SOURCES)
+ if(NOT sources)
return()
endif()
- set_property(GLOBAL PROPERTY _qt_internal_ios_bundle_identifier_prefix_computed "TRUE")
-
- set(home_dir "$ENV{HOME}")
- set(xcode_preferences_path "${home_dir}/Library/Preferences/com.apple.dt.Xcode.plist")
+ get_target_property(source_dir ${target} SOURCE_DIR)
+ get_target_property(binary_dir ${target} BINARY_DIR)
- message(DEBUG "Trying to extract the default bundle identifier prefix from Xcode preferences.")
- execute_process(COMMAND "/usr/libexec/PlistBuddy"
- -c "print IDETemplateOptions:bundleIdentifierPrefix"
- "${xcode_preferences_path}"
- OUTPUT_VARIABLE prefix
- ERROR_VARIABLE prefix_error)
- if(prefix AND NOT prefix_error)
- message(DEBUG "Successfully extracted the default bundle identifier prefix.")
- string(STRIP "${prefix}" prefix)
- else()
- message(DEBUG "Failed to extract the default bundle identifier prefix.")
+ get_property(generated_source_group GLOBAL PROPERTY AUTOGEN_SOURCE_GROUP)
+ if(NOT generated_source_group)
+ set(generated_source_group "Source Files/Generated")
endif()
- if(prefix AND NOT prefix_error)
- set_property(GLOBAL PROPERTY _qt_internal_ios_bundle_identifier_prefix "${prefix}")
- set("${out_var}" "${prefix}" PARENT_SCOPE)
- else()
- set("${out_var}" "" PARENT_SCOPE)
- endif()
-endfunction()
-
-function(_qt_internal_escape_rfc_1034_identifier value out_var)
- # According to https://datatracker.ietf.org/doc/html/rfc1034#section-3.5
- # we can only use letters, digits, dot (.) and hyphens (-).
- # Underscores are not allowed.
- string(REGEX REPLACE "[^A-Za-z0-9.]" "-" value "${value}")
+ foreach(source IN LISTS sources)
+ string(GENEX_STRIP "${source}" source)
- set("${out_var}" "${value}" PARENT_SCOPE)
-endfunction()
-
-function(_qt_internal_get_default_ios_bundle_identifier out_var)
- _qt_internal_get_ios_bundle_identifier_prefix(prefix)
- if(NOT prefix)
- set(prefix "com.yourcompany")
-
- # For a better out-of-the-box experience, try to create a unique prefix by appending
- # the sha1 of the team id, if one is found.
- _qt_internal_find_ios_development_team_id(team_id)
- if(team_id)
- string(SHA1 hash "${team_id}")
- string(SUBSTRING "${hash}" 0 8 infix)
- string(APPEND prefix ".${infix}")
+ if(IS_ABSOLUTE ${source})
+ set(source_file_path "${source}")
else()
- message(WARNING
- "No organization bundle identifier prefix could be retrieved from Xcode "
- "preferences. This can lead to code signing issues due to a non-unique bundle "
- "identifier. Please set up an organization prefix by creating a new project within "
- "Xcode, or consider providing a custom bundle identifier by specifying the "
- "XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER property."
- )
- endif()
- endif()
-
- # Escape the prefix according to rfc 1034, it's important for code-signing. If an invalid
- # identifier is used, calling xcodebuild on the command line says that no provisioning profile
- # could be found, with no additional error message. If one opens the generated project with
- # Xcode and clicks on 'Try again' to get a new profile, it shows a semi-useful error message
- # that the identifier is invalid.
- _qt_internal_escape_rfc_1034_identifier("${prefix}" prefix)
-
- set(identifier "${prefix}.\${PRODUCT_NAME:rfc1034identifier}")
- set("${out_var}" "${identifier}" PARENT_SCOPE)
-endfunction()
-
-function(_qt_internal_set_placeholder_apple_bundle_version target)
- # If user hasn't provided neither a bundle version nor a bundle short version string for the
- # app, set a placeholder value for both which will add them to the generated Info.plist file.
- # This is required so that the app launches in the simulator (but apparently not for running
- # on-device).
- get_target_property(bundle_version "${target}" MACOSX_BUNDLE_BUNDLE_VERSION)
- get_target_property(bundle_short_version "${target}" MACOSX_BUNDLE_SHORT_VERSION_STRING)
-
- if(NOT MACOSX_BUNDLE_BUNDLE_VERSION AND
- NOT MACOSX_BUNDLE_SHORT_VERSION_STRING AND
- NOT bundle_version AND
- NOT bundle_short_version AND
- NOT QT_NO_SET_XCODE_BUNDLE_VERSION
- )
- get_target_property(version "${target}" VERSION)
- if(NOT version)
- set(version "${PROJECT_VERSION}")
- if(NOT version)
- set(version "1.0.0")
+ # Resolve absolute path. Can't use LOCATION, as that
+ # will error out if the file doesn't exist :(
+ get_filename_component(source_file_path "${source}"
+ ABSOLUTE BASE_DIR "${source_dir}")
+ if(NOT EXISTS ${source_file_path})
+ # Likely generated file, will end up in build dir
+ get_filename_component(source_file_path "${source}"
+ ABSOLUTE BASE_DIR "${binary_dir}")
endif()
endif()
- # Use x.y for short version and x.y.z for full version
- # Any versions longer than this will fail App Store
- # submission.
- string(REPLACE "." ";" version_list ${version})
- list(LENGTH version_list version_list_length)
- list(GET version_list 0 version_major)
- set(bundle_short_version "${version_major}")
- if(version_list_length GREATER 1)
- list(GET version_list 1 version_minor)
- string(APPEND bundle_short_version ".${version_minor}")
- endif()
- set(bundle_version "${bundle_short_version}")
- if(version_list_length GREATER 2)
- list(GET version_list 2 version_patch)
- string(APPEND bundle_version ".${version_patch}")
- endif()
-
-
- if(NOT CMAKE_XCODE_ATTRIBUTE_MARKETING_VERSION
- AND NOT QT_NO_SET_XCODE_ATTRIBUTE_MARKETING_VERSION
- AND NOT CMAKE_XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION
- AND NOT QT_NO_SET_XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION)
- get_target_property(marketing_version "${target}"
- XCODE_ATTRIBUTE_MARKETING_VERSION)
- get_target_property(current_project_version "${target}"
- XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION)
- if(NOT marketing_version AND NOT current_project_version)
- set_target_properties("${target}"
- PROPERTIES
- XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION "${bundle_version}"
- XCODE_ATTRIBUTE_MARKETING_VERSION "${bundle_short_version}"
- )
- set(bundle_version "$(CURRENT_PROJECT_VERSION)")
- set(bundle_short_version "$(MARKETING_VERSION)")
- endif()
- endif()
-
- set_target_properties("${target}"
- PROPERTIES
- MACOSX_BUNDLE_BUNDLE_VERSION "${bundle_version}"
- MACOSX_BUNDLE_SHORT_VERSION_STRING "${bundle_short_version}"
- )
- endif()
-endfunction()
-
-function(_qt_internal_set_xcode_development_team_id target)
- # If user hasn't provided a development team id, try to find the first one specified
- # in the Xcode preferences.
- if(NOT CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM AND NOT QT_NO_SET_XCODE_DEVELOPMENT_TEAM_ID)
- get_target_property(existing_team_id "${target}" XCODE_ATTRIBUTE_DEVELOPMENT_TEAM)
- if(NOT existing_team_id)
- _qt_internal_find_ios_development_team_id(team_id)
- set_target_properties("${target}"
- PROPERTIES XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "${team_id}")
- endif()
- endif()
-endfunction()
-
-function(_qt_internal_set_xcode_bundle_identifier target)
- # Skip all logic if requested.
- if(QT_NO_SET_XCODE_BUNDLE_IDENTIFIER)
- return()
- endif()
-
- # There are two fields to consider: the CFBundleIdentifier key (CFBI) to be written to
- # Info.plist
- # and the PRODUCT_BUNDLE_IDENTIFIER (PBI) property to set in the Xcode project.
- # The following logic enables the best out-of-the-box experience combined with maximum
- # customization.
- # 1) If values for both fields are not provided, assign ${PRODUCT_BUNDLE_IDENTIFIER} to CFBI
- # (which is expanded by xcodebuild at build time and will use the value of PBI) and
- # auto-compute a default PBI from Xcode's ${PRODUCT_NAME}.
- # 2) If CFBI is set and PBI isn't, use given CFBI and keep PBI empty.
- # 3) If PBI is set and CFBI isn't, assign ${PRODUCT_BUNDLE_IDENTIFIER} to CFBI and use
- # the given PBI.
- # 4) If both are set, use both given values.
- # TLDR:
- # cfbi pbi -> result_cfbi result_pbi
- # unset unset computed computed
- # set unset given_val unset
- # unset set computed given_val
- # set set given_val given_val
-
- get_target_property(existing_cfbi "${target}" MACOSX_BUNDLE_GUI_IDENTIFIER)
- if(NOT MACOSX_BUNDLE_GUI_IDENTIFIER AND NOT existing_cfbi)
- set(is_cfbi_given FALSE)
- else()
- set(is_cfbi_given TRUE)
- endif()
-
- if(NOT is_cfbi_given)
- set_target_properties("${target}"
- PROPERTIES
- MACOSX_BUNDLE_GUI_IDENTIFIER "\${PRODUCT_BUNDLE_IDENTIFIER}")
- endif()
-
- get_target_property(existing_pbi "${target}" XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER)
- if(NOT CMAKE_XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER AND NOT existing_pbi)
- set(is_pbi_given FALSE)
- else()
- set(is_pbi_given TRUE)
- endif()
-
- if(NOT is_pbi_given AND NOT is_cfbi_given)
- _qt_internal_get_default_ios_bundle_identifier(bundle_id)
- set_target_properties("${target}"
- PROPERTIES
- XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${bundle_id}")
- endif()
-endfunction()
-
-function(_qt_internal_set_xcode_targeted_device_family target)
- if(NOT CMAKE_XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY
- AND NOT QT_NO_SET_XCODE_TARGETED_DEVICE_FAMILY)
- get_target_property(existing_device_family
- "${target}" XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY)
- if(NOT existing_device_family)
- set(device_family_iphone_and_ipad "1,2")
- set_target_properties("${target}"
- PROPERTIES
- XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY
- "${device_family_iphone_and_ipad}")
+ # Include qml files in "Source Files". Can not be done via regex,
+ # due to https://gitlab.kitware.com/cmake/cmake/-/issues/25597
+ if(${source_file_path} MATCHES "\\.qml$")
+ source_group("Source Files" FILES ${source_file_path})
endif()
- endif()
-endfunction()
-
-function(_qt_internal_set_xcode_code_sign_style target)
- if(NOT CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_STYLE
- AND NOT QT_NO_SET_XCODE_CODE_SIGN_STYLE)
- get_target_property(existing_code_style
- "${target}" XCODE_ATTRIBUTE_CODE_SIGN_STYLE)
- if(NOT existing_code_style)
- set(existing_code_style "Automatic")
- set_target_properties("${target}"
- PROPERTIES
- XCODE_ATTRIBUTE_CODE_SIGN_STYLE
- "${existing_code_style}")
- endif()
- endif()
-endfunction()
-# Workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/15183
-function(_qt_internal_set_xcode_install_path target)
- if(NOT CMAKE_XCODE_ATTRIBUTE_INSTALL_PATH
- AND NOT QT_NO_SET_XCODE_INSTALL_PATH)
- get_target_property(existing_install_path
- "${target}" XCODE_ATTRIBUTE_INSTALL_PATH)
- if(NOT existing_install_path)
- set_target_properties("${target}"
- PROPERTIES
- XCODE_ATTRIBUTE_INSTALL_PATH
- "$(inherited)")
+ get_source_file_property(is_generated "${source_file_path}" GENERATED)
+ if(${is_generated})
+ source_group(${generated_source_group} FILES ${source_file_path})
endif()
- endif()
-endfunction()
-
-function(_qt_internal_set_xcode_bundle_display_name target)
- # We want the value of CFBundleDisplayName to be ${PRODUCT_NAME}, but we can't put that
- # into the Info.plist.in template file directly, because the implicit configure_file(Info.plist)
- # done by CMake is not using the @ONLY option, so CMake would treat the assignment as
- # variable expansion. Escaping using backslashes does not help.
- # Work around it by assigning the dollar char to a separate cache var, and expand it, so that
- # the final value in the file will be ${PRODUCT_NAME}, to be evaluated at build time by Xcode.
- set(QT_INTERNAL_DOLLAR_VAR "$" CACHE STRING "")
-endfunction()
-
-function(_qt_internal_set_xcode_bitcode_enablement target)
- if(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE
- OR QT_NO_SET_XCODE_ENABLE_BITCODE)
- return()
- endif()
-
- get_target_property(existing_bitcode_enablement
- "${target}" XCODE_ATTRIBUTE_ENABLE_BITCODE)
- if(NOT existing_bitcode_enablement MATCHES "-NOTFOUND")
- return()
- endif()
-
- # Disable bitcode to match Xcode 14's new default
- set_target_properties("${target}"
- PROPERTIES
- XCODE_ATTRIBUTE_ENABLE_BITCODE
- "NO")
-endfunction()
-
-function(_qt_internal_generate_ios_info_plist target)
- # If the project already specifies a custom file, we don't override it.
- get_target_property(existing_plist "${target}" MACOSX_BUNDLE_INFO_PLIST)
- if(existing_plist)
- return()
- endif()
-
- set(info_plist_in "${__qt_internal_cmake_ios_support_files_path}/Info.plist.app.in")
-
- string(MAKE_C_IDENTIFIER "${target}" target_identifier)
- set(info_plist_out_dir
- "${CMAKE_CURRENT_BINARY_DIR}/.qt/info_plist/${target_identifier}")
- set(info_plist_out "${info_plist_out_dir}/Info.plist")
-
- # Check if we need to specify a custom launch screen storyboard entry.
- get_target_property(launch_screen_name "${target}" _qt_ios_launch_screen_name)
- if(launch_screen_name)
- set(qt_ios_launch_screen_plist_entry "${launch_screen_name}")
- endif()
-
- # Call configure_file to substitute Qt-specific @FOO@ values, not ${FOO} values.
- #
- # The output file will be another template file to be fed to CMake via the
- # MACOSX_BUNDLE_INFO_PLIST property. CMake will then call configure_file on it to provide
- # content for regular entries like CFBundleName, etc.
- #
- # We require this extra configure_file call so we can create unique Info.plist files for each
- # target in a project, while also providing a way to add Qt specific entries that CMake
- # does not support out of the box (e.g. a launch screen name).
- configure_file(
- "${info_plist_in}"
- "${info_plist_out}"
- @ONLY
- )
-
- set_target_properties("${target}" PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${info_plist_out}")
-endfunction()
-
-function(_qt_internal_set_ios_simulator_arch target)
- if(CMAKE_XCODE_ATTRIBUTE_ARCHS
- OR QT_NO_SET_XCODE_ARCHS)
- return()
- endif()
-
- get_target_property(existing_archs
- "${target}" XCODE_ATTRIBUTE_ARCHS)
- if(NOT existing_archs MATCHES "-NOTFOUND")
- return()
- endif()
-
- if(NOT x86_64 IN_LIST QT_OSX_ARCHITECTURES)
- return()
- endif()
-
- if(CMAKE_OSX_ARCHITECTURES AND NOT x86_64 IN_LIST CMAKE_OSX_ARCHITECTURES)
- return()
- endif()
-
- set_target_properties("${target}"
- PROPERTIES
- "XCODE_ATTRIBUTE_ARCHS[sdk=iphonesimulator*]"
- "x86_64")
-endfunction()
-
-function(_qt_internal_finalize_apple_app target)
- # Shared between macOS and iOS apps
- _qt_internal_set_xcode_development_team_id("${target}")
- _qt_internal_set_xcode_bundle_identifier("${target}")
- _qt_internal_set_xcode_code_sign_style("${target}")
- _qt_internal_set_xcode_bundle_display_name("${target}")
- _qt_internal_set_xcode_install_path("${target}")
- _qt_internal_set_placeholder_apple_bundle_version("${target}")
-endfunction()
-
-function(_qt_internal_finalize_ios_app target)
- _qt_internal_finalize_apple_app("${target}")
-
- _qt_internal_set_xcode_targeted_device_family("${target}")
- _qt_internal_set_xcode_bitcode_enablement("${target}")
- _qt_internal_handle_ios_launch_screen("${target}")
- _qt_internal_generate_ios_info_plist("${target}")
- _qt_internal_set_ios_simulator_arch("${target}")
+ endforeach()
endfunction()
-function(_qt_internal_finalize_macos_app target)
- get_target_property(is_bundle ${target} MACOSX_BUNDLE)
- if(NOT is_bundle)
+function(_qt_internal_darwin_permission_finalizer target)
+ get_target_property(plist_file "${target}" MACOSX_BUNDLE_INFO_PLIST)
+ if(NOT plist_file)
return()
endif()
-
- _qt_internal_finalize_apple_app("${target}")
-
- # Make sure the install rpath has at least the minimum needed if the app
- # has any non-static frameworks. We can't rigorously know if the app will
- # have any, even with a static Qt, so always add this. If there are no
- # frameworks, it won't do any harm.
- get_property(install_rpath TARGET ${target} PROPERTY INSTALL_RPATH)
- list(APPEND install_rpath "@executable_path/../Frameworks")
- list(REMOVE_DUPLICATES install_rpath)
- set_property(TARGET ${target} PROPERTY INSTALL_RPATH "${install_rpath}")
+ foreach(plugin_target IN LISTS QT_ALL_PLUGINS_FOUND_BY_FIND_PACKAGE_permissions)
+ set(versioned_plugin_target "${QT_CMAKE_EXPORT_NAMESPACE}::${plugin_target}")
+ get_target_property(usage_descriptions
+ ${versioned_plugin_target}
+ _qt_info_plist_usage_descriptions)
+ foreach(usage_description_key IN LISTS usage_descriptions)
+ execute_process(COMMAND "/usr/libexec/PlistBuddy"
+ -c "print ${usage_description_key}" "${plist_file}"
+ OUTPUT_VARIABLE usage_description
+ ERROR_VARIABLE plist_error)
+ if(usage_description AND NOT plist_error)
+ set_target_properties("${target}"
+ PROPERTIES "_qt_has_${plugin_target}_usage_description" TRUE)
+ qt6_import_plugins(${target} INCLUDE ${versioned_plugin_target})
+ endif()
+ endforeach()
+ endforeach()
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
@@ -1459,6 +1051,167 @@ if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
endfunction()
endif()
+function(_qt_internal_assign_to_internal_targets_folder target)
+ get_property(folder_name GLOBAL PROPERTY QT_TARGETS_FOLDER)
+ if(NOT "${folder_name}" STREQUAL "")
+ set_property(TARGET ${target} PROPERTY FOLDER "${folder_name}")
+ endif()
+endfunction()
+
+function(_qt_internal_get_target_autogen_build_dir target out_var)
+ get_property(target_autogen_build_dir TARGET ${target} PROPERTY AUTOGEN_BUILD_DIR)
+ if(target_autogen_build_dir)
+ set(${out_var} "${target_autogen_build_dir}" PARENT_SCOPE)
+ else()
+ get_property(target_binary_dir TARGET ${target} PROPERTY BINARY_DIR)
+ set(${out_var} "${target_binary_dir}/${target}_autogen" PARENT_SCOPE)
+ endif()
+endfunction()
+
+function(_qt_internal_should_install_metatypes target)
+ set(args_option
+ INTERNAL_INSTALL
+ )
+ set(args_single
+ OUT_VAR
+ )
+ set(args_multi
+ )
+
+ cmake_parse_arguments(arg
+ "${args_option}"
+ "${args_single}"
+ "${args_multi}" ${ARGN})
+
+ # Check whether the generated json file needs to be installed.
+ # Executable metatypes.json files should not be installed. Qt non-prefix builds should also
+ # not install the files.
+ set(should_install FALSE)
+
+ get_target_property(target_type ${target} TYPE)
+ if(NOT target_type STREQUAL "EXECUTABLE" AND arg_INTERNAL_INSTALL)
+ set(should_install TRUE)
+ endif()
+ set(${arg_OUT_VAR} "${should_install}" PARENT_SCOPE)
+endfunction()
+
+function(_qt_internal_get_metatypes_install_dir internal_install_dir arch_data_dir out_var)
+ # Automatically fill default install args when not specified.
+ if(NOT internal_install_dir)
+ # INSTALL_ARCHDATADIR is not set when QtBuildInternals is not loaded
+ # (when not doing a Qt build). Default to a hardcoded location for user
+ # projects (will likely be wrong).
+ if(arch_data_dir)
+ set(install_dir "${arch_data_dir}/metatypes")
+ else()
+ set(install_dir "lib/metatypes")
+ endif()
+ else()
+ set(install_dir "${internal_install_dir}")
+ endif()
+ set(${out_var} "${install_dir}" PARENT_SCOPE)
+endfunction()
+
+# Propagates the build time metatypes file via INTERFACE_SOURCES (using $<BUILD_INTERFACE>)
+# and saves the path and file name in properties, so that they can be queryied in the qml api
+# implementation for the purpose of duplicating a qml module backing library's metatypes in its
+# associated plugin. This is required for qmltyperegistrar to get the full set of foreign types
+# when projects link to the plugin and not the backing library.
+function(_qt_internal_assign_build_metatypes_files_and_properties target)
+ get_target_property(existing_meta_types_file ${target} INTERFACE_QT_META_TYPES_BUILD_FILE)
+ if (existing_meta_types_file)
+ return()
+ endif()
+
+ set(args_option
+ )
+ set(args_single
+ METATYPES_FILE_NAME
+ METATYPES_FILE_PATH
+ )
+ set(args_multi
+ )
+
+ cmake_parse_arguments(arg
+ "${args_option}"
+ "${args_single}"
+ "${args_multi}" ${ARGN})
+
+ if(NOT arg_METATYPES_FILE_NAME)
+ message(FATAL_ERROR "METATYPES_FILE_NAME must be specified")
+ endif()
+
+ if(NOT arg_METATYPES_FILE_PATH)
+ message(FATAL_ERROR "METATYPES_FILE_PATH must be specified")
+ endif()
+
+ set(metatypes_file_name "${arg_METATYPES_FILE_NAME}")
+ set(metatypes_file_path "${arg_METATYPES_FILE_PATH}")
+
+ # Set up consumption of files via INTERFACE_SOURCES.
+ set(consumes_metatypes "$<BOOL:$<TARGET_PROPERTY:QT_CONSUMES_METATYPES>>")
+ set(metatypes_file_genex_build
+ "$<BUILD_INTERFACE:$<${consumes_metatypes}:${metatypes_file_path}>>"
+ )
+ target_sources(${target} INTERFACE ${metatypes_file_genex_build})
+
+ set_target_properties(${target} PROPERTIES
+ INTERFACE_QT_MODULE_HAS_META_TYPES YES
+ # The property name is a bit misleading, it's not wrapped in a genex.
+ INTERFACE_QT_META_TYPES_BUILD_FILE "${metatypes_file_path}"
+ INTERFACE_QT_META_TYPES_FILE_NAME "${metatypes_file_name}"
+ )
+endfunction()
+
+# Same as above, but with $<INSTALL_INTERFACE>.
+function(_qt_internal_assign_install_metatypes_files_and_properties target)
+ get_target_property(existing_meta_types_file ${target} INTERFACE_QT_META_TYPES_INSTALL_FILE)
+ if (existing_meta_types_file)
+ return()
+ endif()
+
+ set(args_option
+ )
+ set(args_single
+ INSTALL_DIR
+ )
+ set(args_multi
+ )
+
+ cmake_parse_arguments(arg
+ "${args_option}"
+ "${args_single}"
+ "${args_multi}" ${ARGN})
+
+
+ get_target_property(metatypes_file_name "${target}" INTERFACE_QT_META_TYPES_FILE_NAME)
+
+ if(NOT metatypes_file_name)
+ message(FATAL_ERROR "INTERFACE_QT_META_TYPES_FILE_NAME of target ${target} is empty")
+ endif()
+
+ if(NOT arg_INSTALL_DIR)
+ message(FATAL_ERROR "INSTALL_DIR must be specified")
+ endif()
+
+ # Set up consumption of files via INTERFACE_SOURCES.
+ set(consumes_metatypes "$<BOOL:$<TARGET_PROPERTY:QT_CONSUMES_METATYPES>>")
+
+ set(install_dir "${arg_INSTALL_DIR}")
+
+ set(metatypes_file_install_path "${install_dir}/${metatypes_file_name}")
+ set(metatypes_file_install_path_genex "$<INSTALL_PREFIX>/${metatypes_file_install_path}")
+ set(metatypes_file_genex_install
+ "$<INSTALL_INTERFACE:$<${consumes_metatypes}:${metatypes_file_install_path_genex}>>"
+ )
+ target_sources(${target} INTERFACE ${metatypes_file_genex_install})
+
+ set_target_properties(${target} PROPERTIES
+ INTERFACE_QT_META_TYPES_INSTALL_FILE "${metatypes_file_install_path}"
+ )
+endfunction()
+
+
function(qt6_extract_metatypes target)
get_target_property(existing_meta_types_file ${target} INTERFACE_QT_META_TYPES_BUILD_FILE)
@@ -1476,7 +1229,7 @@ function(qt6_extract_metatypes target)
# TODO: Move this into a separate internal function, so it doesn't pollute the public one.
# Location where to install the metatypes file. Only used if
# __QT_INTERNAL_INSTALL is given. It defaults to the
- # ${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}/metatypes directory.
+ # ${CMAKE_INSTALL_PREFIX}/${INSTALL_ARCHDATADIR}/metatypes directory.
# Executable metatypes files are never installed.
__QT_INTERNAL_INSTALL_DIR
@@ -1506,6 +1259,9 @@ function(qt6_extract_metatypes target)
set(type_list_file "${target_binary_dir}/meta_types/${target}_json_file_list.txt")
set(type_list_file_manual "${target_binary_dir}/meta_types/${target}_json_file_list_manual.txt")
+ set(target_autogen_build_dir "")
+ _qt_internal_get_target_autogen_build_dir(${target} target_autogen_build_dir)
+
get_target_property(uses_automoc ${target} AUTOMOC)
set(automoc_args)
set(automoc_dependencies)
@@ -1521,13 +1277,13 @@ function(qt6_extract_metatypes target)
set(cmake_autogen_cache_file
"${target_binary_dir}/CMakeFiles/${target}_autogen.dir/ParseCache.txt")
set(multi_config_args
- --cmake-autogen-include-dir-path "${target_binary_dir}/${target}_autogen/include"
+ --cmake-autogen-include-dir-path "${target_autogen_build_dir}/include"
)
else()
set(cmake_autogen_cache_file
"${target_binary_dir}/CMakeFiles/${target}_autogen.dir/ParseCache_$<CONFIG>.txt")
set(multi_config_args
- --cmake-autogen-include-dir-path "${target_binary_dir}/${target}_autogen/include_$<CONFIG>"
+ --cmake-autogen-include-dir-path "${target_autogen_build_dir}/include_$<CONFIG>"
"--cmake-multi-config")
endif()
@@ -1536,8 +1292,15 @@ function(qt6_extract_metatypes target)
set (use_dep_files FALSE)
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.17") # Requires automoc changes present only in 3.17
- if(CMAKE_GENERATOR STREQUAL "Ninja" OR CMAKE_GENERATOR STREQUAL "Ninja Multi-Config")
- set(use_dep_files TRUE)
+ if(CMAKE_GENERATOR STREQUAL "Ninja" OR
+ CMAKE_GENERATOR STREQUAL "Ninja Multi-Config" OR
+ (CMAKE_GENERATOR MATCHES "Makefiles" AND
+ CMAKE_VERSION VERSION_GREATER_EQUAL "3.28"))
+ if(DEFINED QT_USE_CMAKE_DEPFILES)
+ set(use_dep_files ${QT_USE_CMAKE_DEPFILES})
+ else()
+ set(use_dep_files TRUE)
+ endif()
endif()
endif()
@@ -1586,10 +1349,20 @@ function(qt6_extract_metatypes target)
COMMAND_EXPAND_LISTS
)
add_dependencies(${target}_automoc_json_extraction ${target}_autogen)
+ _qt_internal_assign_to_internal_targets_folder(${target}_automoc_json_extraction)
else()
- set(cmake_autogen_timestamp_file
- "${target_binary_dir}/${target}_autogen/timestamp"
- )
+ set(timestamp_file "${target_autogen_build_dir}/timestamp")
+ set(timestamp_file_with_config "${timestamp_file}_$<CONFIG>")
+ if (is_multi_config AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.29"
+ AND NOT QT_INTERNAL_USE_OLD_AUTOGEN_GRAPH_MULTI_CONFIG_METATYPES)
+ string(JOIN "" timestamp_genex
+ "$<IF:$<BOOL:$<TARGET_PROPERTY:${target},"
+ "AUTOGEN_BETTER_GRAPH_MULTI_CONFIG>>,"
+ "${timestamp_file_with_config},${timestamp_file}>")
+ set(cmake_autogen_timestamp_file "${timestamp_genex}")
+ else()
+ set(cmake_autogen_timestamp_file ${timestamp_file})
+ endif()
add_custom_command(OUTPUT ${type_list_file}
DEPENDS ${QT_CMAKE_EXPORT_NAMESPACE}::cmake_automoc_parser
@@ -1657,6 +1430,7 @@ function(qt6_extract_metatypes target)
add_custom_command(
OUTPUT
${metatypes_file_gen}
+ BYPRODUCTS
${metatypes_file}
DEPENDS ${QT_CMAKE_EXPORT_NAMESPACE}::moc ${automoc_dependencies} ${manual_dependencies}
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::moc
@@ -1669,6 +1443,17 @@ function(qt6_extract_metatypes target)
VERBATIM
)
+ if(CMAKE_GENERATOR MATCHES " Makefiles" OR CMAKE_GENERATOR MATCHES "^Visual Studio")
+ # Work around https://gitlab.kitware.com/cmake/cmake/-/issues/19005 to trigger the command
+ # that generates ${metatypes_file}.
+ add_custom_command(
+ OUTPUT ${metatypes_file}
+ DEPENDS ${metatypes_file_gen}
+ COMMAND ${CMAKE_COMMAND} -E true
+ VERBATIM
+ )
+ endif()
+
# We can't rely on policy CMP0118 since user project controls it
set(scope_args)
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
@@ -1688,51 +1473,42 @@ function(qt6_extract_metatypes target)
PROPERTIES HEADER_FILE_ONLY TRUE
)
- set_target_properties(${target} PROPERTIES
- INTERFACE_QT_MODULE_HAS_META_TYPES YES
- INTERFACE_QT_META_TYPES_BUILD_FILE "${metatypes_file}"
- )
-
- # Set up consumption of files via INTERFACE_SOURCES.
- set(consumes_metatypes "$<BOOL:$<TARGET_PROPERTY:QT_CONSUMES_METATYPES>>")
- set(metatypes_file_genex_build
- "$<BUILD_INTERFACE:$<${consumes_metatypes}:${metatypes_file}>>"
- )
- target_sources(${target} INTERFACE ${metatypes_file_genex_build})
-
if(arg_OUTPUT_FILES)
set(${arg_OUTPUT_FILES} "${metatypes_file}" PARENT_SCOPE)
endif()
- # Check whether the generated json file needs to be installed.
- # Executable metatypes.json files should not be installed. Qt non-prefix builds should also
- # not install the files.
- set(should_install FALSE)
-
- if(NOT target_type STREQUAL "EXECUTABLE" AND arg___QT_INTERNAL_INSTALL)
- set(should_install TRUE)
- endif()
+ # Propagate the build time metatypes file.
+ _qt_internal_assign_build_metatypes_files_and_properties(
+ "${target}"
+ METATYPES_FILE_NAME "${metatypes_file_name}"
+ METATYPES_FILE_PATH "${metatypes_file}"
+ )
- # Automatically fill default install args when not specified.
- if(NOT arg___QT_INTERNAL_INSTALL_DIR)
- # INSTALL_LIBDIR is not set when QtBuildInternals is not loaded (when not doing a Qt build).
- # Default to a hardcoded location for user projects.
- if(INSTALL_LIBDIR)
- set(install_dir "${INSTALL_LIBDIR}/metatypes")
- else()
- set(install_dir "lib/metatypes")
- endif()
+ if(arg___QT_INTERNAL_INSTALL)
+ set(internal_install_option "INTERNAL_INSTALL")
else()
- set(install_dir "${arg___QT_INTERNAL_INSTALL_DIR}")
+ set(internal_install_option "")
endif()
+ # TODO: Clean up Qt-specific installation not to happen in the public api.
+ # Check whether the metatype files should be installed.
+ _qt_internal_should_install_metatypes("${target}"
+ ${internal_install_option}
+ OUT_VAR should_install
+ )
+
if(should_install)
- set(metatypes_file_install_path "${install_dir}/${metatypes_file_name}")
- set(metatypes_file_install_path_genex "$<INSTALL_PREFIX>/${metatypes_file_install_path}")
- set(metatypes_file_genex_install
- "$<INSTALL_INTERFACE:$<${consumes_metatypes}:${metatypes_file_install_path_genex}>>"
+ _qt_internal_get_metatypes_install_dir(
+ "${arg___QT_INTERNAL_INSTALL_DIR}"
+ "${INSTALL_ARCHDATADIR}"
+ install_dir
+ )
+
+ # Propagate the install time metatypes file.
+ _qt_internal_assign_install_metatypes_files_and_properties(
+ "${target}"
+ INSTALL_DIR "${install_dir}"
)
- target_sources(${target} INTERFACE ${metatypes_file_genex_install})
install(FILES "${metatypes_file}" DESTINATION "${install_dir}")
endif()
endfunction()
@@ -1781,7 +1557,7 @@ function(_qt_internal_generate_win32_rc_file target)
endif()
if(MSVC)
- set(extra_rc_flags "/nologo")
+ set(extra_rc_flags "-c65001 -DWIN32 -nologo")
else()
set(extra_rc_flags)
endif()
@@ -1987,10 +1763,60 @@ END
endif()
endfunction()
+# Generate Win32 longPathAware RC and Manifest files for a target.
+# MSVC needs the manifest file as part of target_sources. MinGW the RC file.
+#
+function(_qt_internal_generate_longpath_win32_rc_file_and_manifest target)
+ set(prohibited_target_types INTERFACE_LIBRARY STATIC_LIBRARY OBJECT_LIBRARY)
+ get_target_property(target_type ${target} TYPE)
+ if(target_type IN_LIST prohibited_target_types)
+ return()
+ endif()
+
+ get_target_property(target_binary_dir ${target} BINARY_DIR)
+
+ # Generate manifest
+ set(target_mn_filename "${target}_longpath.manifest")
+ set(mn_file_output "${target_binary_dir}/${target_mn_filename}")
+
+ set(mn_contents [=[<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+<application xmlns="urn:schemas-microsoft-com:asm.v3">
+ <windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
+ <ws2:longPathAware>true</ws2:longPathAware>
+ </windowsSettings>
+</application>
+</assembly>]=])
+ file(GENERATE OUTPUT "${mn_file_output}" CONTENT "${mn_contents}")
+
+ # Generate RC File
+ set(rc_file_output "${target_binary_dir}/${target}_longpath.rc")
+ set(rc_contents "1 /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ 24 /* RT_MANIFEST */ ${target_mn_filename}")
+ file(GENERATE OUTPUT "${rc_file_output}" CONTENT "${rc_contents}")
+
+ if (MINGW)
+ set(outputs "${rc_file_output}")
+ endif()
+ list(APPEND outputs "${mn_file_output}")
+
+ foreach(output IN LISTS outputs)
+ # Needed for CMake versions < 3.19
+ set_source_files_properties(${output} PROPERTIES GENERATED TRUE)
+ target_sources(${target} PRIVATE "${output}")
+ endforeach()
+endfunction()
+
function(__qt_get_relative_resource_path_for_file output_alias file)
get_property(alias SOURCE ${file} PROPERTY QT_RESOURCE_ALIAS)
if (NOT alias)
set(alias "${file}")
+ if(IS_ABSOLUTE "${file}")
+ message(FATAL_ERROR
+ "The source file '${file}' was specified with an absolute path and is used in a Qt "
+ "resource. Please set the QT_RESOURCE_ALIAS property on that source file to a "
+ "relative path to make the file properly accessible via the resource system."
+ )
+ endif()
endif()
set(${output_alias} ${alias} PARENT_SCOPE)
endfunction()
@@ -2174,11 +2000,29 @@ function(__qt_propagate_generated_resource target resource_name generated_source
math(EXPR resource_count "${resource_count} + 1")
set_target_properties(${target} PROPERTIES _qt_generated_resource_target_count ${resource_count})
+ __qt_internal_generate_init_resource_source_file(
+ resource_init_file ${target} ${resource_name})
+
set(resource_target "${target}_resources_${resource_count}")
- add_library("${resource_target}" OBJECT "${generated_source_code}")
+ add_library("${resource_target}" OBJECT "${resource_init_file}")
+ set_target_properties(${resource_target} PROPERTIES
+ AUTOMOC FALSE
+ AUTOUIC FALSE
+ AUTORCC FALSE
+ )
+ # Needed so that qtsymbolmacros.h and its dependent headers are already created / syncqt'ed.
+ if(TARGET Core_sync_headers)
+ set(headers_available_target "Core_sync_headers")
+ else()
+ set(headers_available_target "${QT_CMAKE_EXPORT_NAMESPACE}::Core")
+ endif()
+ add_dependencies(${resource_target} ${headers_available_target})
target_compile_definitions("${resource_target}" PRIVATE
"$<TARGET_PROPERTY:${QT_CMAKE_EXPORT_NAMESPACE}::Core,INTERFACE_COMPILE_DEFINITIONS>"
)
+ target_include_directories("${resource_target}" PRIVATE
+ "$<TARGET_PROPERTY:${QT_CMAKE_EXPORT_NAMESPACE}::Core,INTERFACE_INCLUDE_DIRECTORIES>"
+ )
_qt_internal_set_up_static_runtime_library("${resource_target}")
# Special handling is required for the Core library resources. The linking of the Core
@@ -2197,7 +2041,7 @@ function(__qt_propagate_generated_resource target resource_name generated_source
# .rcc/qrc_qprintdialog.cpp
file(RELATIVE_PATH generated_cpp_file_relative_path
"${CMAKE_CURRENT_BINARY_DIR}"
- "${generated_source_code}")
+ "${resource_init_file}")
set_property(TARGET ${resource_target} APPEND PROPERTY
_qt_resource_generated_cpp_relative_path "${generated_cpp_file_relative_path}")
@@ -2211,14 +2055,52 @@ function(__qt_propagate_generated_resource target resource_name generated_source
set(${output_generated_target} "${resource_target}" PARENT_SCOPE)
else()
set(${output_generated_target} "" PARENT_SCOPE)
- target_sources(${target} PRIVATE ${generated_source_code})
endif()
+
+ target_sources(${target} PRIVATE ${generated_source_code})
+endfunction()
+
+function(__qt_internal_sanitize_resource_name out_var name)
+ # The sanitized output should match RCCResourceLibrary::writeInitializer()'s
+ # isAsciiLetterOrNumber-based substituion.
+ # MAKE_C_IDENTIFIER matches that, it replaces non-alphanumeric chars with underscores.
+ string(MAKE_C_IDENTIFIER "${name}" sanitized_resource_name)
+ set(${out_var} "${sanitized_resource_name}" PARENT_SCOPE)
+endfunction()
+
+function(__qt_internal_generate_init_resource_source_file out_var target resource_name)
+ set(template_file "${__qt_core_macros_module_base_dir}/Qt6CoreResourceInit.in.cpp")
+
+ # Gets replaced in the template
+ __qt_internal_sanitize_resource_name(RESOURCE_NAME "${resource_name}")
+ set(resource_init_path "${CMAKE_CURRENT_BINARY_DIR}/.qt/rcc/qrc_${resource_name}_init.cpp")
+
+ configure_file("${template_file}" "${resource_init_path}" @ONLY)
+
+ set(scope_args "")
+ if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
+ set(scope_args TARGET_DIRECTORY ${target})
+ endif()
+ set_source_files_properties(${resource_init_path} ${scope_args} PROPERTIES
+ SKIP_AUTOGEN TRUE
+ SKIP_UNITY_BUILD_INCLUSION TRUE
+ SKIP_PRECOMPILE_HEADERS TRUE
+ )
+
+ set(${out_var} "${resource_init_path}" PARENT_SCOPE)
endfunction()
-# Creates fake targets and adds resource files to IDE's tree
-# FIXME: We shouldn't need to create a separate target for this, the files
-# should be added to the actual target instead.
+# Make file visible in IDEs.
+# Targets that are finalized add the file as HEADER_FILE_ONLY in the finalizer.
+# Targets that are not finalized add the file under a ${target}_other_files target.
function(_qt_internal_expose_source_file_to_ide target file)
+ get_target_property(target_expects_finalization ${target} _qt_expects_finalization)
+ if(target_expects_finalization AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.19")
+ set_property(TARGET ${target} APPEND PROPERTY _qt_deferred_files ${file})
+ return()
+ endif()
+
+ # Fallback for targets that are not finalized: Create fake target under which the file is added.
set(ide_target ${target}_other_files)
if(NOT TARGET ${ide_target})
add_custom_target(${ide_target} SOURCES "${file}")
@@ -2248,6 +2130,55 @@ function(_qt_internal_expose_source_file_to_ide target file)
endif()
endfunction()
+# Called by the target finalizer.
+# Adds the files that were added to _qt_deferred_files to SOURCES.
+# Sets HEADER_FILES_ONLY if they did not exist yet in SOURCES.
+function(_qt_internal_expose_deferred_files_to_ide target)
+ get_target_property(new_sources ${target} _qt_deferred_files)
+ if(NOT new_sources)
+ return()
+ endif()
+ set(new_sources_real "")
+ foreach(f IN LISTS new_sources)
+ get_filename_component(realf "${f}" REALPATH)
+ list(APPEND new_sources_real ${realf})
+ endforeach()
+
+ set(filtered_new_sources "")
+ get_target_property(target_source_dir ${target} SOURCE_DIR)
+ get_filename_component(target_source_dir "${target_source_dir}" REALPATH)
+ get_target_property(existing_sources ${target} SOURCES)
+ if(existing_sources)
+ set(existing_sources_real "")
+ set(realf "")
+ foreach(f IN LISTS existing_sources)
+ get_filename_component(realf "${f}" REALPATH BASE_DIR ${target_source_dir})
+ list(APPEND existing_sources_real ${realf})
+ endforeach()
+
+ list(LENGTH new_sources max_i)
+ math(EXPR max_i "${max_i} - 1")
+ foreach(i RANGE 0 ${max_i})
+ list(GET new_sources_real ${i} realf)
+ if(NOT realf IN_LIST existing_sources_real)
+ list(GET new_sources ${i} f)
+ list(APPEND filtered_new_sources ${f})
+ endif()
+ endforeach()
+ endif()
+ if("${filtered_new_sources}" STREQUAL "")
+ return()
+ endif()
+
+ target_sources(${target} PRIVATE ${filtered_new_sources})
+ set(scope_args)
+ if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
+ set(scope_args TARGET_DIRECTORY "${target}")
+ endif()
+ set_source_files_properties(${filtered_new_sources}
+ ${scope_args} PROPERTIES HEADER_FILE_ONLY ON)
+endfunction()
+
#
# Process resources via file path instead of QRC files. Behind the
# scenes, it will generate a qrc file.
@@ -2267,22 +2198,22 @@ function(_qt_internal_process_resource target resourceName)
if("${rcc_OPTIONS}" MATCHES "-binary")
set(isBinary TRUE)
- if(arg_BIG_RESOURCES)
+ if(rcc_BIG_RESOURCES)
message(FATAL_ERROR "BIG_RESOURCES cannot be used together with the -binary option.")
endif()
endif()
- if(arg_BIG_RESOURCES AND CMAKE_GENERATOR STREQUAL "Xcode" AND IOS)
+ if(rcc_BIG_RESOURCES AND CMAKE_GENERATOR STREQUAL "Xcode" AND IOS)
message(WARNING
"Due to CMake limitations, the BIG_RESOURCES option can't be used when building "
"for iOS. "
"See https://bugreports.qt.io/browse/QTBUG-103497 for details. "
"Falling back to using regular resources. "
)
- set(arg_BIG_RESOURCES OFF)
+ set(rcc_BIG_RESOURCES OFF)
endif()
- if(arg_BIG_RESOURCES AND CMAKE_VERSION VERSION_LESS "3.17")
+ if(rcc_BIG_RESOURCES AND CMAKE_VERSION VERSION_LESS "3.17")
message(WARNING
"The BIG_RESOURCES option does not work reliably with CMake < 3.17. "
"Consider upgrading to a more recent CMake version or disable the BIG_RESOURCES "
@@ -2326,7 +2257,7 @@ function(_qt_internal_process_resource target resourceName)
if(NOT rcc_PREFIX)
get_target_property(rcc_PREFIX ${target} QT_RESOURCE_PREFIX)
if (NOT rcc_PREFIX)
- message(FATAL_ERROR "_qt_internal_process_resource() was called without a PREFIX and the target does not provide QT_RESOURCE_PREFIX. Please either add a PREFIX or make the target ${target} provide a default.")
+ set(rcc_PREFIX "/")
endif()
endif()
@@ -2336,15 +2267,16 @@ function(_qt_internal_process_resource target resourceName)
endif()
return()
endif()
- set(generatedResourceFile "${CMAKE_CURRENT_BINARY_DIR}/.rcc/${resourceName}.qrc")
+ set(generatedResourceFile "${CMAKE_CURRENT_BINARY_DIR}/.qt/rcc/${resourceName}.qrc")
+ _qt_internal_expose_source_file_to_ide(${target} ${generatedResourceFile})
+ set_source_files_properties(${generatedResourceFile} PROPERTIES GENERATED TRUE)
# Generate .qrc file:
# <RCC><qresource ...>
set(qrcContents "<RCC>\n <qresource")
- if (rcc_PREFIX)
- string(APPEND qrcContents " prefix=\"${rcc_PREFIX}\"")
- endif()
+ string(APPEND qrcContents " prefix=\"${rcc_PREFIX}\"")
+
if (rcc_LANG)
string(APPEND qrcContents " lang=\"${rcc_LANG}\"")
endif()
@@ -2358,10 +2290,15 @@ function(_qt_internal_process_resource target resourceName)
set(file "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
endif()
+ get_property(is_empty SOURCE ${file} PROPERTY QT_DISCARD_FILE_CONTENTS)
+
### FIXME: escape file paths to be XML conform
# <file ...>...</file>
- string(APPEND qrcContents " <file alias=\"${file_resource_path}\">")
- string(APPEND qrcContents "${file}</file>\n")
+ string(APPEND qrcContents " <file alias=\"${file_resource_path}\"")
+ if(is_empty)
+ string(APPEND qrcContents " empty=\"true\"")
+ endif()
+ string(APPEND qrcContents ">${file}</file>\n")
list(APPEND files "${file}")
set(scope_args)
@@ -2370,13 +2307,20 @@ function(_qt_internal_process_resource target resourceName)
endif()
get_source_file_property(
target_dependency ${file} ${scope_args} _qt_resource_target_dependency)
- if (NOT target_dependency)
- list(APPEND resource_dependencies ${file})
- else()
- if (NOT TARGET ${target_dependency})
- message(FATAL_ERROR "Target dependency on resource file ${file} is not a cmake target.")
+
+ # The target dependency code path does not take care of rebuilds when ${file}
+ # is touched. Limit its usage to the Xcode generator to avoid the Xcode common
+ # dependency issue.
+ # TODO: Figure out how to avoid the issue on Xcode, while also enabling proper
+ # dependency tracking when ${file} is touched.
+ if(target_dependency AND CMAKE_GENERATOR STREQUAL "Xcode")
+ if(NOT TARGET ${target_dependency})
+ message(FATAL_ERROR
+ "Target dependency on resource file ${file} is not a cmake target.")
endif()
list(APPEND resource_dependencies ${target_dependency})
+ else()
+ list(APPEND resource_dependencies ${file})
endif()
_qt_internal_expose_source_file_to_ide(${target} "${file}")
endforeach()
@@ -2420,9 +2364,9 @@ function(_qt_internal_process_resource target resourceName)
endif()
endif()
elseif(rcc_BIG_RESOURCES)
- set(generatedOutfile "${CMAKE_CURRENT_BINARY_DIR}/.rcc/qrc_${resourceName}_tmp.cpp")
+ set(generatedOutfile "${CMAKE_CURRENT_BINARY_DIR}/.qt/rcc/qrc_${resourceName}_tmp.cpp")
else()
- set(generatedOutfile "${CMAKE_CURRENT_BINARY_DIR}/.rcc/qrc_${resourceName}.cpp")
+ set(generatedOutfile "${CMAKE_CURRENT_BINARY_DIR}/.qt/rcc/qrc_${resourceName}.cpp")
endif()
set(pass_msg)
@@ -2461,6 +2405,9 @@ function(_qt_internal_process_resource target resourceName)
SKIP_UNITY_BUILD_INCLUSION TRUE
SKIP_PRECOMPILE_HEADERS TRUE
)
+ if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.27")
+ set_source_files_properties(${generatedOutfile} ${scope_args} PROPERTIES SKIP_LINTING ON)
+ endif()
get_target_property(target_source_dir ${target} SOURCE_DIR)
if(NOT target_source_dir STREQUAL CMAKE_CURRENT_SOURCE_DIR)
@@ -2474,7 +2421,7 @@ function(_qt_internal_process_resource target resourceName)
if(rcc_BIG_RESOURCES)
set(pass1OutputFile ${generatedOutfile})
set(generatedOutfile
- "${CMAKE_CURRENT_BINARY_DIR}/.rcc/qrc_${resourceName}${CMAKE_CXX_OUTPUT_EXTENSION}")
+ "${CMAKE_CURRENT_BINARY_DIR}/.qt/rcc/qrc_${resourceName}${CMAKE_CXX_OUTPUT_EXTENSION}")
_qt_internal_add_rcc_pass2(
RESOURCE_NAME ${resourceName}
RCC_OPTIONS ${rccArgsAllPasses}
@@ -2515,10 +2462,6 @@ macro(_qt_internal_get_add_plugin_keywords option_args single_args multi_args)
__QT_INTERNAL_NO_PROPAGATE_PLUGIN_INITIALIZER
)
set(${single_args}
- # TODO: For backward compatibility / transitional use only, remove once all repos no longer
- # use it
- TYPE
-
PLUGIN_TYPE # Internal use only, may be changed or removed
CLASS_NAME
OUTPUT_NAME # Internal use only, may be changed or removed
@@ -2529,23 +2472,10 @@ endmacro()
function(qt6_add_plugin target)
_qt_internal_get_add_plugin_keywords(opt_args single_args multi_args)
+ list(APPEND opt_args MANUAL_FINALIZATION)
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
- # Handle the inconsistent TYPE/PLUGIN_TYPE keyword naming between commands
- if(arg_TYPE)
- if(arg_PLUGIN_TYPE AND NOT arg_TYPE STREQUAL arg_PLUGIN_TYPE)
- message(FATAL_ERROR
- "Both TYPE and PLUGIN_TYPE were given and were different. "
- "Only one of the two should be used."
- )
- endif()
- message(AUTHOR_WARNING
- "The TYPE keyword is deprecated and will be removed soon. Please use PLUGIN_TYPE instead.")
- set(arg_PLUGIN_TYPE "${arg_TYPE}")
- unset(arg_TYPE)
- endif()
-
if(arg_STATIC AND arg_SHARED)
message(FATAL_ERROR
"Both STATIC and SHARED options were given. Only one of the two should be used."
@@ -2575,6 +2505,7 @@ function(qt6_add_plugin target)
endif()
_qt_internal_add_library(${target} ${type_to_create} ${arg_UNPARSED_ARGUMENTS})
+ set_property(TARGET ${target} PROPERTY _qt_expects_finalization TRUE)
get_target_property(target_type "${target}" TYPE)
if (target_type STREQUAL "STATIC_LIBRARY")
@@ -2648,9 +2579,27 @@ function(qt6_add_plugin target)
if(target_type STREQUAL "MODULE_LIBRARY")
if(NOT TARGET qt_internal_plugins)
add_custom_target(qt_internal_plugins)
+ _qt_internal_assign_to_internal_targets_folder(qt_internal_plugins)
endif()
add_dependencies(qt_internal_plugins ${target})
endif()
+
+ if(arg_MANUAL_FINALIZATION)
+ # Caller says they will call qt6_finalize_target() themselves later
+ return()
+ endif()
+
+ # Defer the finalization if we can. When the caller's project requires
+ # CMake 3.19 or later, this makes the calls to this function concise while
+ # still allowing target property modification before finalization.
+ if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.19)
+ # Need to wrap in an EVAL CODE or else ${target} won't be evaluated
+ # due to special behavior of cmake_language() argument handling
+ cmake_language(EVAL CODE "cmake_language(DEFER CALL qt6_finalize_target ${target})")
+ else()
+ set_target_properties("${target}" PROPERTIES _qt_is_immediately_finalized TRUE)
+ qt6_finalize_target("${target}")
+ endif()
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
@@ -2669,6 +2618,7 @@ function(qt6_add_library target)
cmake_parse_arguments(PARSE_ARGV 1 arg "MANUAL_FINALIZATION" "" "")
_qt_internal_add_library("${target}" ${arg_UNPARSED_ARGUMENTS})
+ set_property(TARGET ${target} PROPERTY _qt_expects_finalization TRUE)
if(arg_MANUAL_FINALIZATION)
# Caller says they will call qt6_finalize_target() themselves later
@@ -2734,14 +2684,36 @@ function(_qt_internal_add_library target)
# This in contrast to CMake which defaults to STATIC.
if(NOT arg_STATIC AND NOT arg_SHARED AND NOT arg_MODULE AND NOT arg_INTERFACE
AND NOT arg_OBJECT)
- if(QT6_IS_SHARED_LIBS_BUILD)
- set(type_to_create SHARED)
+ if(DEFINED BUILD_SHARED_LIBS AND NOT QT_BUILDING_QT AND NOT QT_BUILD_STANDALONE_TESTS)
+ __qt_internal_setup_policy(QTP0003 "6.7.0"
+ "BUILD_SHARED_LIBS is set to ${BUILD_SHARED_LIBS} but it has no effect on\
+ default library type created by Qt CMake API commands. The default library type\
+ is set to the Qt build type.\
+ This behavior can be changed by setting QTP0003 to NEW.\
+ Check https://doc.qt.io/qt-6/qt-cmake-policy-qtp0003.html for policy details."
+ )
+ qt6_policy(GET QTP0003 build_shared_libs_policy)
else()
- set(type_to_create STATIC)
+ set(build_shared_libs_policy "")
+ endif()
+
+ if(build_shared_libs_policy STREQUAL "NEW" OR QT_BUILDING_QT OR QT_BUILD_STANDALONE_TESTS)
+ if(BUILD_SHARED_LIBS OR (NOT DEFINED BUILD_SHARED_LIBS AND QT6_IS_SHARED_LIBS_BUILD))
+ set(type_to_create SHARED)
+ else()
+ set(type_to_create STATIC)
+ endif()
+ else()
+ if(QT6_IS_SHARED_LIBS_BUILD)
+ set(type_to_create SHARED)
+ else()
+ set(type_to_create STATIC)
+ endif()
endif()
endif()
add_library(${target} ${type_to_create} ${arg_UNPARSED_ARGUMENTS})
+ _qt_internal_disable_autorcc_zstd_when_not_supported("${target}")
_qt_internal_set_up_static_runtime_library(${target})
if(NOT type_to_create STREQUAL "INTERFACE" AND NOT type_to_create STREQUAL "OBJECT")
@@ -2755,6 +2727,8 @@ function(_qt_internal_add_library target)
endif()
if(ANDROID)
+ set_property(TARGET "${target}"
+ PROPERTY _qt_android_apply_arch_suffix_called_from_qt_impl TRUE)
qt6_android_apply_arch_suffix("${target}")
endif()
endfunction()
@@ -2802,30 +2776,6 @@ function(_qt_internal_apply_strict_cpp target)
endif()
endfunction()
-# Wraps a tool command with a script that contains the necessary environment for the tool to run
-# correctly.
-# _qt_internal_wrap_tool_command(var <SET|APPEND> <command> [args...])
-# Arguments:
-# APPEND Selects the 'append' mode for the out_variable argument.
-# SET Selects the 'set' mode for the out_variable argument.
-function(_qt_internal_wrap_tool_command out_variable action)
- set(append FALSE)
- if(action STREQUAL "APPEND")
- set(append TRUE)
- elseif(NOT action STREQUAL "SET")
- message(FATAL_ERROR "Invalid action specified ${action}. Supported actions: SET, APPEND")
- endif()
-
- set(cmd COMMAND ${QT_TOOL_COMMAND_WRAPPER_PATH} ${ARGN})
-
- if(append)
- list(APPEND ${out_variable} ${cmd})
- else()
- set(${out_variable} ${cmd})
- endif()
- set(${out_variable} "${${out_variable}}" PARENT_SCOPE)
-endfunction()
-
# Copies properties of the dependency to the target.
# Arguments:
# PROPERTIES list of properties to copy. If not specified the following properties are copied
@@ -2929,6 +2879,10 @@ endfunction()
# Sets up the commands for use at install/deploy time
function(_qt_internal_setup_deploy_support)
+ if(QT_SKIP_SETUP_DEPLOYMENT)
+ return()
+ endif()
+
get_property(cmake_role GLOBAL PROPERTY CMAKE_ROLE)
if(NOT cmake_role STREQUAL "PROJECT")
return()
@@ -2960,6 +2914,22 @@ function(_qt_internal_setup_deploy_support)
set(target ${aliased_target})
endif()
+ # Generate deployment information for each target if the CMake version is recent enough.
+ # The call is deferred to have all targets of the projects available.
+ if(CMAKE_VERSION GREATER_EQUAL "3.19.0")
+ if(is_multi_config)
+ set(targets_file "${deploy_impl_dir}/QtDeployTargets-$<CONFIG>.cmake")
+ else()
+ set(targets_file "${deploy_impl_dir}/QtDeployTargets.cmake")
+ endif()
+ cmake_language(EVAL CODE
+ "cmake_language(DEFER
+ DIRECTORY [[${CMAKE_SOURCE_DIR}]]
+ CALL _qt_internal_write_target_deploy_info [[${targets_file}]])"
+ )
+ _qt_internal_add_deploy_support("${targets_file}")
+ endif()
+
# Make sure to look under the Qt bin dir with find_program, rather than randomly picking up
# a deployqt tool in the system.
# QT6_INSTALL_PREFIX is not set during Qt build, so add the hints conditionally.
@@ -2990,14 +2960,110 @@ function(_qt_internal_setup_deploy_support)
set(safe_target_file
"$<TARGET_FILE:$<IF:${have_deploy_tool},${target_if_exists},${target}>>")
set(__QT_DEPLOY_TOOL "$<IF:${have_deploy_tool},${safe_target_file},${fallback}>")
+ elseif(UNIX AND NOT APPLE AND NOT ANDROID AND NOT CMAKE_CROSSCOMPILING)
+ set(__QT_DEPLOY_TOOL "GRD")
else()
# Android is handled as a build target, not via this install-based approach.
# Therefore, we don't consider androiddeployqt here.
set(__QT_DEPLOY_TOOL "")
endif()
+ # Determine whether this is a multi-config build with a Debug configuration.
+ set(is_multi_config_build_with_debug_config FALSE)
+ get_target_property(target_is_imported ${target} IMPORTED)
+ if(target_is_imported)
+ get_target_property(target_imported_configs ${target} IMPORTED_CONFIGURATIONS)
+ list(LENGTH target_imported_configs target_imported_configs_length)
+ if(target_imported_configs_length GREATER "1"
+ AND "DEBUG" IN_LIST target_imported_configs)
+ set(is_multi_config_build_with_debug_config TRUE)
+ endif()
+ endif()
+
_qt_internal_add_deploy_support("${CMAKE_CURRENT_LIST_DIR}/Qt6CoreDeploySupport.cmake")
+ set(deploy_ignored_lib_dirs "")
+ if(__QT_DEPLOY_TOOL STREQUAL "GRD" AND NOT "${QT6_INSTALL_PREFIX}" STREQUAL "")
+ # Set up the directories we want to ignore when running file(GET_RUNTIME_DEPENDENCIES).
+ # If the Qt prefix is the root of one of those directories, don't ignore that directory.
+ # For example, if Qt's installation prefix is /usr, then we don't want to ignore /usr/lib.
+ foreach(link_dir IN LISTS CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES)
+ file(RELATIVE_PATH relative_dir "${QT6_INSTALL_PREFIX}" "${link_dir}")
+ if(relative_dir STREQUAL "")
+ # The Qt prefix is exactly ${link_dir}.
+ continue()
+ endif()
+ if(IS_ABSOLUTE "${relative_dir}" OR relative_dir MATCHES "^\\.\\./")
+ # The Qt prefix is outside of ${link_dir}.
+ list(APPEND deploy_ignored_lib_dirs "${link_dir}")
+ endif()
+ endforeach()
+ endif()
+
+ # Check whether we will have to adjust the RPATH of plugins.
+ if("${QT_DEPLOY_FORCE_ADJUST_RPATHS}" STREQUAL "")
+ set(must_adjust_plugins_rpath "")
+ if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows"
+ AND NOT CMAKE_INSTALL_LIBDIR STREQUAL QT6_INSTALL_LIBS)
+ set(must_adjust_plugins_rpath ON)
+ endif()
+ else()
+ set(must_adjust_plugins_rpath "${QT_DEPLOY_FORCE_ADJUST_RPATHS}")
+ endif()
+
+ # Find the patchelf executable if necessary.
+ if(must_adjust_plugins_rpath)
+ if(CMAKE_VERSION VERSION_LESS "3.21")
+ set(QT_DEPLOY_USE_PATCHELF ON)
+ endif()
+ if(QT_DEPLOY_USE_PATCHELF)
+ find_program(QT_DEPLOY_PATCHELF_EXECUTABLE patchelf)
+ if(NOT QT_DEPLOY_PATCHELF_EXECUTABLE)
+ set(QT_DEPLOY_PATCHELF_EXECUTABLE "patchelf")
+ message(WARNING "The patchelf executable could not be located. "
+ "To use Qt's CMake deployment API, install patchelf or upgrade CMake to 3.21 "
+ "or newer.")
+ endif()
+ endif()
+ endif()
+
+ # Generate path to the target (not host) qtpaths file. Needed for windeployqt when
+ # cross-compiling from an x86_64 host to an arm64 target, so it knows which architecture
+ # libraries should be deployed.
+ if(CMAKE_HOST_WIN32)
+ if(CMAKE_CROSSCOMPILING)
+ set(qt_paths_ext ".bat")
+ else()
+ set(qt_paths_ext ".exe")
+ endif()
+ else()
+ set(qt_paths_ext "")
+ endif()
+
+
+
+ set(target_qtpaths_path "")
+ set(qtpaths_prefix "${QT6_INSTALL_PREFIX}/${QT6_INSTALL_BINS}")
+ get_property(qt_major_version TARGET "${target}" PROPERTY INTERFACE_QT_MAJOR_VERSION)
+ if(qt_major_version)
+ set(target_qtpaths_with_major_version_path
+ "${qtpaths_prefix}/qtpaths${qt_major_version}${qt_paths_ext}")
+ if(EXISTS "${target_qtpaths_with_major_version_path}")
+ set(target_qtpaths_path "${target_qtpaths_with_major_version_path}")
+ endif()
+ endif()
+
+ if(NOT target_qtpaths_path)
+ set(target_qtpaths_path_without_version "${qtpaths_prefix}/qtpaths${qt_paths_ext}")
+ if(EXISTS "${target_qtpaths_path_without_version}")
+ set(target_qtpaths_path "${target_qtpaths_path_without_version}")
+ endif()
+ endif()
+
+ if(NOT target_qtpaths_path)
+ message(DEBUG "No qtpaths executable found for deployment purposes.")
+ endif()
+
file(GENERATE OUTPUT "${QT_DEPLOY_SUPPORT}" CONTENT
"cmake_minimum_required(VERSION 3.16...3.21)
@@ -3006,6 +3072,9 @@ function(_qt_internal_setup_deploy_support)
if(NOT QT_DEPLOY_BIN_DIR)
set(QT_DEPLOY_BIN_DIR \"${CMAKE_INSTALL_BINDIR}\")
endif()
+if(NOT QT_DEPLOY_LIBEXEC_DIR)
+ set(QT_DEPLOY_LIBEXEC_DIR \"${CMAKE_INSTALL_LIBEXECDIR}\")
+endif()
if(NOT QT_DEPLOY_LIB_DIR)
set(QT_DEPLOY_LIB_DIR \"${CMAKE_INSTALL_LIBDIR}\")
endif()
@@ -3015,12 +3084,18 @@ endif()
if(NOT QT_DEPLOY_QML_DIR)
set(QT_DEPLOY_QML_DIR \"qml\")
endif()
+if(NOT QT_DEPLOY_TRANSLATIONS_DIR)
+ set(QT_DEPLOY_TRANSLATIONS_DIR \"translations\")
+endif()
if(NOT QT_DEPLOY_PREFIX)
set(QT_DEPLOY_PREFIX \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}\")
endif()
if(QT_DEPLOY_PREFIX STREQUAL \"\")
set(QT_DEPLOY_PREFIX .)
endif()
+if(NOT QT_DEPLOY_IGNORED_LIB_DIRS)
+ set(QT_DEPLOY_IGNORED_LIB_DIRS \"${deploy_ignored_lib_dirs}\")
+endif()
# These are internal implementation details. They may be removed at any time.
set(__QT_DEPLOY_SYSTEM_NAME \"${CMAKE_SYSTEM_NAME}\")
@@ -3033,10 +3108,24 @@ set(__QT_DEPLOY_GENERATOR_IS_MULTI_CONFIG \"${is_multi_config}\")
set(__QT_DEPLOY_ACTIVE_CONFIG \"$<CONFIG>\")
set(__QT_NO_CREATE_VERSIONLESS_FUNCTIONS \"${QT_NO_CREATE_VERSIONLESS_FUNCTIONS}\")
set(__QT_DEFAULT_MAJOR_VERSION \"${QT_DEFAULT_MAJOR_VERSION}\")
+set(__QT_DEPLOY_QT_ADDITIONAL_PACKAGES_PREFIX_PATH \"${QT_ADDITIONAL_PACKAGES_PREFIX_PATH}\")
+set(__QT_DEPLOY_QT_INSTALL_PREFIX \"${QT6_INSTALL_PREFIX}\")
+set(__QT_DEPLOY_QT_INSTALL_BINS \"${QT6_INSTALL_BINS}\")
+set(__QT_DEPLOY_QT_INSTALL_DATA \"${QT6_INSTALL_DATA}\")
+set(__QT_DEPLOY_QT_INSTALL_LIBEXECS \"${QT6_INSTALL_LIBEXECS}\")
+set(__QT_DEPLOY_QT_INSTALL_PLUGINS \"${QT6_INSTALL_PLUGINS}\")
+set(__QT_DEPLOY_QT_INSTALL_TRANSLATIONS \"${QT6_INSTALL_TRANSLATIONS}\")
+set(__QT_DEPLOY_TARGET_QT_PATHS_PATH \"${target_qtpaths_path}\")
+set(__QT_DEPLOY_PLUGINS \"\")
+set(__QT_DEPLOY_MUST_ADJUST_PLUGINS_RPATH \"${must_adjust_plugins_rpath}\")
+set(__QT_DEPLOY_USE_PATCHELF \"${QT_DEPLOY_USE_PATCHELF}\")
+set(__QT_DEPLOY_PATCHELF_EXECUTABLE \"${QT_DEPLOY_PATCHELF_EXECUTABLE}\")
+set(__QT_DEPLOY_QT_IS_MULTI_CONFIG_BUILD_WITH_DEBUG \"${is_multi_config_build_with_debug_config}\")
+set(__QT_DEPLOY_QT_DEBUG_POSTFIX \"${QT6_DEBUG_POSTFIX}\")
# Define the CMake commands to be made available during deployment.
set(__qt_deploy_support_files
- \"$<JOIN:$<TARGET_PROPERTY:${target},_qt_deploy_support_files>,\"
+ \"$<JOIN:$<TARGET_GENEX_EVAL:${target},$<TARGET_PROPERTY:${target},_qt_deploy_support_files>>,\"
\">\"
)
foreach(__qt_deploy_support_file IN LISTS __qt_deploy_support_files)
@@ -3048,6 +3137,194 @@ unset(__qt_deploy_support_files)
")
endfunction()
+# Write deployment information for the targets of the project.
+function(_qt_internal_write_target_deploy_info out_file)
+ set(targets "")
+ _qt_internal_collect_buildsystem_targets(targets
+ "${CMAKE_SOURCE_DIR}" INCLUDE EXECUTABLE SHARED_LIBRARY MODULE_LIBRARY)
+ set(content "")
+ foreach(target IN LISTS targets)
+ set(var_prefix "__QT_DEPLOY_TARGET_${target}")
+ string(APPEND content "set(${var_prefix}_FILE $<TARGET_FILE:${target}>)\n")
+ if(WIN32 AND CMAKE_VERSION GREATER_EQUAL "3.21")
+ string(APPEND content
+ "set(${var_prefix}_RUNTIME_DLLS $<TARGET_RUNTIME_DLLS:${target}>)\n")
+ endif()
+ endforeach()
+ file(GENERATE OUTPUT "${out_file}" CONTENT "${content}")
+endfunction()
+
+function(_qt_internal_is_examples_deployment_supported_in_current_config out_var out_var_reason)
+ # Deployment API doesn't work when examples / tests are built in-tree of a prefix qt build.
+ if(QT_BUILDING_QT AND QT_WILL_INSTALL AND NOT QT_INTERNAL_BUILD_STANDALONE_PARTS)
+ set(deployment_supported FALSE)
+ set(not_supported_reason "PREFIX_BUILD")
+ else()
+ set(deployment_supported TRUE)
+ set(not_supported_reason "")
+ endif()
+
+ set(${out_var} "${deployment_supported}" PARENT_SCOPE)
+ set(${out_var_reason} "${not_supported_reason}" PARENT_SCOPE)
+endfunction()
+
+function(_qt_internal_should_skip_deployment_api out_var out_var_reason)
+ set(skip_deployment FALSE)
+ _qt_internal_is_examples_deployment_supported_in_current_config(
+ deployment_supported
+ not_supported_reason
+ )
+
+ # Allow opting out of deployment, so that we can add deployment api to all our examples,
+ # but only run it in the CI for a select few, to avoid the overhead of deploying all examples.
+ if(QT_INTERNAL_SKIP_DEPLOYMENT OR (NOT deployment_supported))
+ set(skip_deployment TRUE)
+ endif()
+
+ set(reason "")
+ if(NOT deployment_supported)
+ set(reason "${not_supported_reason}")
+ elseif(QT_INTERNAL_SKIP_DEPLOYMENT)
+ set(reason "SKIP_REQUESTED")
+ endif()
+
+ set(${out_var} "${skip_deployment}" PARENT_SCOPE)
+ set(${out_var_reason} "${reason}" PARENT_SCOPE)
+endfunction()
+
+function(_qt_internal_should_skip_post_build_deployment_api out_var out_var_reason)
+ set(skip_deployment FALSE)
+ set(deployment_supported TRUE)
+
+ # Allow opting out of deployment, so that we can add deployment api to all our examples,
+ # but only run it in the CI for a select few, to avoid the overhead of deploying all examples.
+ if(QT_INTERNAL_SKIP_DEPLOYMENT OR (NOT deployment_supported))
+ set(skip_deployment TRUE)
+ endif()
+
+ set(reason "")
+ if(NOT deployment_supported)
+ set(reason "REASON_UNSPECIFIED")
+ elseif(QT_INTERNAL_SKIP_DEPLOYMENT)
+ set(reason "SKIP_REQUESTED")
+ endif()
+
+ set(${out_var} "${skip_deployment}" PARENT_SCOPE)
+ set(${out_var_reason} "${reason}" PARENT_SCOPE)
+endfunction()
+
+# Generate a deploy script that does nothing aside from showing a warning message.
+# The warning can be hidden by setting the QT_INTERNAL_HIDE_NO_OP_DEPLOYMENT_WARNING variable.
+function(_qt_internal_generate_no_op_deploy_script)
+ set(no_value_options
+ )
+ set(single_value_options
+ FUNCTION_NAME
+ NAME
+ OUTPUT_SCRIPT
+ SKIP_REASON
+ TARGET
+ )
+ set(multi_value_options
+ )
+
+ cmake_parse_arguments(PARSE_ARGV 0 arg
+ "${no_value_options}" "${single_value_options}" "${multi_value_options}"
+ )
+
+ if(NOT arg_OUTPUT_SCRIPT)
+ message(FATAL_ERROR "No OUTPUT_SCRIPT option specified")
+ endif()
+ if(NOT arg_FUNCTION_NAME)
+ message(FATAL_ERROR "No FUNCTION_NAME option specified")
+ endif()
+
+ set(generate_args "")
+ if(arg_NAME)
+ list(APPEND generate_args NAME "${arg_NAME}")
+ endif()
+ if(arg_TARGET)
+ list(APPEND generate_args TARGET "${arg_TARGET}")
+ endif()
+
+ set(function_name "${arg_FUNCTION_NAME}")
+
+ # The empty space is required, otherwise
+ set(content "
+message(DEBUG \"Running no-op deployment script because QT_INTERNAL_SKIP_DEPLOYMENT was ON.\")
+")
+ if(NOT QT_INTERNAL_HIDE_NO_OP_DEPLOYMENT_WARNING AND arg_SKIP_REASON STREQUAL "PREFIX_BUILD")
+ set(content "
+message(STATUS \"${function_name}(TARGET ${arg_TARGET}) is a no-op for prefix \"
+\"non-standalone builds due to various issues. Consider using a -no-prefix build \"
+\"or qt-internal-configure-tests or qt-internal-configure-examples if you want deployment to run.\")
+")
+ endif()
+
+ qt6_generate_deploy_script(
+ ${generate_args}
+ OUTPUT_SCRIPT deploy_script
+ CONTENT "${content}")
+
+ set("${arg_OUTPUT_SCRIPT}" "${deploy_script}" PARENT_SCOPE)
+endfunction()
+
+# We basically mirror CMake's policy setup
+# A policy can be set to OLD, set to NEW or unset
+# unset is the default state
+#
+function(qt6_policy mode policy behaviorOrVariable)
+ # When building Qt, tests and examples might expect a policy to be known, but they won't be
+ # known depending on which scope or when a find_package(Module) with the respective policy
+ # is called. Check the global list of known policies to accommodate that.
+ if(QT_BUILDING_QT AND NOT DEFINED QT_KNOWN_POLICY_${policy})
+ get_property(global_known_policies GLOBAL PROPERTY _qt_global_known_policies)
+ if(policy IN_LIST global_known_policies)
+ set(QT_KNOWN_POLICY_${policy} TRUE)
+ endif()
+ endif()
+
+ if (NOT DEFINED QT_KNOWN_POLICY_${policy})
+ message(FATAL_ERROR
+ "${policy} is not a known Qt policy. Did you include the necessary Qt module?"
+ )
+ endif()
+ if (${mode} STREQUAL "SET")
+ set(behavior ${behaviorOrVariable})
+ if (${behavior} STREQUAL "NEW" OR ${behavior} STREQUAL "OLD")
+ set(__QT_INTERNAL_POLICY_${policy} ${behavior} PARENT_SCOPE)
+ else()
+ message(FATAL_ERROR "Qt policies must be either set to NEW or OLD, but got ${behavior}")
+ endif()
+ else(${mode} STREQUAL "GET")
+ set(variable "${behaviorOrVariable}")
+ set("${variable}" "${__QT_INTERNAL_POLICY_${policy}}" PARENT_SCOPE)
+ endif()
+endfunction()
+
+# Internal helper function; can be used in any module before doing a policy check
+function(__qt_internal_setup_policy policy sinceversion policyexplanation)
+ if(DEFINED __QT_INTERNAL_POLICY_${policy})
+ if (__QT_INTERNAL_POLICY_${policy} STREQUAL "OLD")
+ # policy is explicitly disabled
+ message(DEPRECATION
+ "Qt policy ${policy} is set to OLD. "
+ "Support for the old behavior will be removed in a future major version of Qt."
+ )
+ endif()
+ #else: policy is already enabled, nothing to do
+ elseif (${sinceversion} VERSION_LESS_EQUAL __qt_policy_check_version)
+ # we cannot use the public function here as we want to set it in parent scope
+ set(__QT_INTERNAL_POLICY_${policy} "NEW" PARENT_SCOPE)
+ elseif(NOT "${QT_NO_SHOW_OLD_POLICY_WARNINGS}")
+ message(AUTHOR_WARNING
+ "Qt policy ${policy} is not set: "
+ "${policyexplanation} "
+ "Use the qt_policy command to set the policy and suppress this warning.\n"
+ )
+ endif()
+endfunction()
+
# Note this needs to be a macro because it sets variables intended for the
# calling scope.
macro(qt6_standard_project_setup)
@@ -3056,6 +3333,66 @@ macro(qt6_standard_project_setup)
# They can set this variable to true to effectively disable this function.
if(NOT QT_NO_STANDARD_PROJECT_SETUP)
+ set(__qt_sps_args_option)
+ set(__qt_sps_args_single
+ REQUIRES
+ SUPPORTS_UP_TO
+ I18N_SOURCE_LANGUAGE
+ I18N_NATIVE_LANGUAGE # intermediate, remove after dependencies trickled through
+ )
+ set(__qt_sps_args_multi
+ I18N_TRANSLATED_LANGUAGES
+ I18N_LANGUAGES # intermediate, remove after dependencies trickled through
+ )
+ cmake_parse_arguments(__qt_sps_arg
+ "${__qt_sps_args_option}"
+ "${__qt_sps_args_single}"
+ "${__qt_sps_args_multi}"
+ ${ARGN}
+ )
+
+ # intermediate, remove after dependencies trickled through
+ if(DEFINED arg_I18N_NATIVE_LANGUAGE)
+ set(arg_I18N_SOURCE_LANGUAGE ${arg_I18N_NATIVE_LANGUAGE})
+ endif()
+ if(DEFINED arg_I18N_LANGUAGES)
+ set(arg_I18N_TRANSLATED_LANGUAGES ${arg_I18N_LANGUAGES})
+ endif()
+
+ if(__qt_sps_arg_UNPARSED_ARGUMENTS)
+ message(FATAL_ERROR "Unexpected arguments: ${arg_UNPARSED_ARGUMENTS}")
+ endif()
+
+ # Set the Qt CMake policy based on the requested version(s)
+ set(__qt_policy_check_version "6.0.0")
+ if(Qt6_VERSION_MAJOR)
+ set(__qt_current_version
+ "${Qt6_VERSION_MAJOR}.${Qt6_VERSION_MINOR}.${Qt6_VERSION_PATCH}")
+ elseif(QT_BUILDING_QT)
+ set(__qt_current_version
+ "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
+ else()
+ message(FATAL_ERROR "Can not determine Qt version.")
+ endif()
+ if(__qt_sps_arg_REQUIRES)
+ if("${__qt_current_version}" VERSION_LESS "${__qt_sps_arg_REQUIRES}")
+ message(FATAL_ERROR
+ "Project required a Qt minimum version of ${__qt_sps_arg_REQUIRES}, "
+ "but current version is only ${__qt_current_version}.")
+ endif()
+ set(__qt_policy_check_version "${__qt_sps_arg_REQUIRES}")
+ endif()
+ if(__qt_sps_arg_SUPPORTS_UP_TO)
+ if(__qt_sps_arg_REQUIRES)
+ if(${__qt_sps_arg_SUPPORTS_UP_TO} VERSION_LESS ${__qt_sps_arg_REQUIRES})
+ message(FATAL_ERROR "SUPPORTS_UP_TO must be larger than or equal to REQUIRES.")
+ endif()
+ set(__qt_policy_check_version "${__qt_sps_arg_SUPPORTS_UP_TO}")
+ else()
+ message(FATAL_ERROR "Please specify the REQUIRES as well.")
+ endif()
+ endif()
+
# All changes below this point should not result in a change to an
# existing value, except for CMAKE_INSTALL_RPATH which may append new
# values (but no duplicates).
@@ -3097,6 +3434,46 @@ macro(qt6_standard_project_setup)
set(CMAKE_AUTO${auto_set} TRUE)
endif()
endforeach()
+
+ # Enable folder support for IDEs. CMake >= 3.26 enables USE_FOLDERS by default but this is
+ # guarded by CMake policy CMP0143.
+ get_property(__qt_use_folders GLOBAL PROPERTY USE_FOLDERS)
+ if(__qt_use_folders OR "${__qt_use_folders}" STREQUAL "")
+ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+ get_property(__qt_qt_targets_folder GLOBAL PROPERTY QT_TARGETS_FOLDER)
+ if("${__qt_qt_targets_folder}" STREQUAL "")
+ set(__qt_qt_targets_folder QtInternalTargets)
+ set_property(GLOBAL PROPERTY QT_TARGETS_FOLDER ${__qt_qt_targets_folder})
+ endif()
+ get_property(__qt_autogen_targets_folder GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER)
+ if("${__qt_autogen_targets_folder}" STREQUAL "")
+ set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER ${__qt_qt_targets_folder})
+ endif()
+ endif()
+
+ # Hide generated files in dedicated folder. Unfortunately we can't use a
+ # top level "Generated Files" folder for this, as CMake will then put the
+ # folder first in the list of folders, whereas we want to keep Sources and
+ # Headers front and center. See also _qt_internal_finalize_source_groups
+ set_property(GLOBAL PROPERTY AUTOGEN_SOURCE_GROUP "Source Files/Generated")
+
+ # Treat metatypes JSON files as generated. We propagate these INTERFACE_SOURCES,
+ # due to CMake's lack of a generic mechanism for property inheritance (see
+ # https://gitlab.kitware.com/cmake/cmake/-/issues/20416), but we don't want
+ # them to clutter up the user's project.
+ source_group("Source Files/Generated" REGULAR_EXPRESSION "(_metatypes\\.json)$")
+
+ # I18N support.
+ if(DEFINED __qt_sps_arg_I18N_TRANSLATED_LANGUAGES
+ AND NOT DEFINED QT_I18N_TRANSLATED_LANGUAGES)
+ set(QT_I18N_TRANSLATED_LANGUAGES ${__qt_sps_arg_I18N_TRANSLATED_LANGUAGES})
+ endif()
+ if(NOT DEFINED __qt_sps_arg_I18N_SOURCE_LANGUAGE)
+ set(__qt_sps_arg_I18N_SOURCE_LANGUAGE en)
+ endif()
+ if(NOT DEFINED QT_I18N_SOURCE_LANGUAGE)
+ set(QT_I18N_SOURCE_LANGUAGE ${__qt_sps_arg_I18N_SOURCE_LANGUAGE})
+ endif()
endif()
endmacro()
@@ -3104,10 +3481,118 @@ if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
macro(qt_standard_project_setup)
qt6_standard_project_setup(${ARGV})
endmacro()
+ macro(qt_policy)
+ qt6_policy(${ARGV})
+ endmacro()
+endif()
+
+function(qt6_generate_deploy_script)
+ set(no_value_options "")
+ set(single_value_options
+ CONTENT
+ OUTPUT_SCRIPT
+ NAME
+ TARGET
+
+ # TODO: For backward compatibility / transitional use only,
+ # remove at some point
+ FILENAME_VARIABLE
+ )
+ set(multi_value_options "")
+ cmake_parse_arguments(PARSE_ARGV 0 arg
+ "${no_value_options}" "${single_value_options}" "${multi_value_options}"
+ )
+ if(arg_UNPARSED_ARGUMENTS)
+ message(FATAL_ERROR "Unexpected arguments: ${arg_UNPARSED_ARGUMENTS}")
+ endif()
+
+ # TODO: Remove when FILENAME_VARIABLE is fully removed
+ # Handle the slow deprecation of FILENAME_VARIABLE
+ if(arg_FILENAME_VARIABLE)
+ if(arg_OUTPUT_SCRIPT AND NOT arg_FILENAME_VARIABLE STREQUAL arg_OUTPUT_SCRIPT)
+ message(FATAL_ERROR
+ "Both FILENAME_VARIABLE and OUTPUT_SCRIPT were given and were different. "
+ "Only one of the two should be used."
+ )
+ endif()
+ message(AUTHOR_WARNING
+ "The FILENAME_VARIABLE keyword is deprecated and will be removed soon. Please use OUTPUT_SCRIPT instead.")
+ set(arg_OUTPUT_SCRIPT "${arg_FILENAME_VARIABLE}")
+ unset(arg_FILENAME_VARIABLE)
+ endif()
+
+ if(NOT arg_OUTPUT_SCRIPT)
+ message(FATAL_ERROR "OUTPUT_SCRIPT must be specified")
+ endif()
+
+ if("${arg_CONTENT}" STREQUAL "")
+ message(FATAL_ERROR "CONTENT must be specified")
+ endif()
+
+ # Check whether manual finalization is needed.
+ if(CMAKE_VERSION VERSION_LESS "3.19")
+ get_target_property(is_immediately_finalized ${arg_TARGET} _qt_is_immediately_finalized)
+ if(is_immediately_finalized)
+ message(WARNING
+ "Deployment of plugins for target '${arg_TARGET}' will not work. "
+ "Either, upgrade CMake to version 3.19 or newer, or call "
+ "qt_finalize_target(${arg_TARGET}) after generating the deployment script."
+ )
+ endif()
+ endif()
+
+ # Mark the target as "to be deployed".
+ set_property(TARGET ${arg_TARGET} PROPERTY _qt_marked_for_deployment ON)
+
+ # If the target already was finalized, maybe because it was defined in a subdirectory, generate
+ # the plugin deployment information here.
+ get_target_property(is_finalized "${arg_TARGET}" _qt_is_finalized)
+ if(is_finalized)
+ __qt_internal_generate_plugin_deployment_info(${arg_TARGET})
+ endif()
+
+ # Create a file name that will be unique for this target and the combination
+ # of arguments passed to this command. This allows the project to call us
+ # multiple times with different arguments for the same target (e.g. to
+ # create deployment scripts for different scenarios).
+ set(file_base_name "custom")
+ if(NOT "${arg_NAME}" STREQUAL "")
+ set(file_base_name "${arg_NAME}")
+ elseif(NOT "${arg_TARGET}" STREQUAL "")
+ set(file_base_name "${arg_TARGET}")
+ endif()
+ string(MAKE_C_IDENTIFIER "${file_base_name}" target_id)
+ string(SHA1 args_hash "${ARGV}")
+ string(SUBSTRING "${args_hash}" 0 10 short_hash)
+ _qt_internal_get_deploy_impl_dir(deploy_impl_dir)
+ set(deploy_script "${deploy_impl_dir}/deploy_${target_id}_${short_hash}")
+ get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG)
+ if(is_multi_config)
+ set(config_infix "-$<CONFIG>")
+ else()
+ set(config_infix "")
+ endif()
+ string(APPEND deploy_script "${config_infix}.cmake")
+ set(${arg_OUTPUT_SCRIPT} "${deploy_script}" PARENT_SCOPE)
+
+ set(boiler_plate "include(${QT_DEPLOY_SUPPORT})
+include(\"\${CMAKE_CURRENT_LIST_DIR}/${arg_TARGET}-plugins${config_infix}.cmake\" OPTIONAL)
+set(__QT_DEPLOY_ALL_MODULES_FOUND_VIA_FIND_PACKAGE \"${QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE}\")
+")
+ list(TRANSFORM arg_CONTENT REPLACE "\\$" "\$")
+ file(GENERATE OUTPUT ${deploy_script} CONTENT "${boiler_plate}${arg_CONTENT}")
+endfunction()
+
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ macro(qt_generate_deploy_script)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_generate_deploy_script(${ARGV})
+ else()
+ message(FATAL_ERROR "qt_generate_deploy_script() is only available in Qt 6.")
+ endif()
+ endmacro()
endif()
-# This function is currently in Technical Preview.
-# Its signature and behavior might change.
function(qt6_generate_deploy_app_script)
# We use a TARGET keyword option instead of taking the target as the first
# positional argument. This is to keep open the possibility of deploying
@@ -3116,13 +3601,31 @@ function(qt6_generate_deploy_app_script)
# package). We would add an EXECUTABLE keyword for that, which would be
# mutually exclusive with the TARGET keyword.
set(no_value_options
+ NO_TRANSLATIONS
+ NO_COMPILER_RUNTIME
NO_UNSUPPORTED_PLATFORM_ERROR
)
set(single_value_options
TARGET
+ OUTPUT_SCRIPT
+
+ # TODO: For backward compatibility / transitional use only,
+ # remove at some point
FILENAME_VARIABLE
)
- set(multi_value_options "")
+ set(qt_deploy_runtime_dependencies_options
+ # These options are forwarded as is to qt_deploy_runtime_dependencies.
+ DEPLOY_TOOL_OPTIONS
+ PRE_INCLUDE_REGEXES
+ PRE_EXCLUDE_REGEXES
+ POST_INCLUDE_REGEXES
+ POST_EXCLUDE_REGEXES
+ POST_INCLUDE_FILES
+ POST_EXCLUDE_FILES
+ )
+ set(multi_value_options
+ ${qt_deploy_runtime_dependencies_options}
+ )
cmake_parse_arguments(PARSE_ARGV 0 arg
"${no_value_options}" "${single_value_options}" "${multi_value_options}"
)
@@ -3132,72 +3635,122 @@ function(qt6_generate_deploy_app_script)
if(NOT arg_TARGET)
message(FATAL_ERROR "TARGET must be specified")
endif()
- if(NOT arg_FILENAME_VARIABLE)
- message(FATAL_ERROR "FILENAME_VARIABLE must be specified")
+
+ # TODO: Remove when FILENAME_VARIABLE is fully removed
+ # Handle the slow deprecation of FILENAME_VARIABLE
+ if(arg_FILENAME_VARIABLE)
+ if(arg_OUTPUT_SCRIPT AND NOT arg_FILENAME_VARIABLE STREQUAL arg_OUTPUT_SCRIPT)
+ message(FATAL_ERROR
+ "Both FILENAME_VARIABLE and OUTPUT_SCRIPT were given and were different. "
+ "Only one of the two should be used."
+ )
+ endif()
+ message(AUTHOR_WARNING
+ "The FILENAME_VARIABLE keyword is deprecated and will be removed soon. Please use OUTPUT_SCRIPT instead.")
+ set(arg_OUTPUT_SCRIPT "${arg_FILENAME_VARIABLE}")
+ unset(arg_FILENAME_VARIABLE)
endif()
- # Create a file name that will be unique for this target and the combination
- # of arguments passed to this command. This allows the project to call us
- # multiple times with different arguments for the same target (e.g. to
- # create deployment scripts for different scenarios).
- string(MAKE_C_IDENTIFIER "${arg_TARGET}" target_id)
- string(SHA1 args_hash "${ARGV}")
- string(SUBSTRING "${args_hash}" 0 10 short_hash)
- _qt_internal_get_deploy_impl_dir(deploy_impl_dir)
- set(file_name "${deploy_impl_dir}/deploy_${target_id}_${short_hash}")
- get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG)
- if(is_multi_config)
- string(APPEND file_name "-$<CONFIG>")
+ if(NOT arg_OUTPUT_SCRIPT)
+ message(FATAL_ERROR "OUTPUT_SCRIPT must be specified")
endif()
- set(${arg_FILENAME_VARIABLE} "${file_name}" PARENT_SCOPE)
+ get_target_property(is_bundle ${arg_TARGET} MACOSX_BUNDLE)
+
+ set(unsupported_platform_extra_message "")
if(QT6_IS_SHARED_LIBS_BUILD)
set(qt_build_type_string "shared Qt libs")
else()
set(qt_build_type_string "static Qt libs")
endif()
- if(APPLE AND NOT IOS AND QT6_IS_SHARED_LIBS_BUILD)
- # TODO: Handle non-bundle applications if possible.
- get_target_property(is_bundle ${arg_TARGET} MACOSX_BUNDLE)
- if(NOT is_bundle)
- message(FATAL_ERROR
- "Executable targets have to be app bundles to use this command "
- "on Apple platforms."
- )
+ if(CMAKE_CROSSCOMPILING)
+ string(APPEND qt_build_type_string ", cross-compiled")
+ endif()
+
+ if(NOT is_bundle)
+ string(APPEND qt_build_type_string ", non-bundle app")
+ set(unsupported_platform_extra_message
+ "Executable targets have to be app bundles to use this command on Apple platforms.")
+ endif()
+
+ set(generate_args
+ TARGET ${arg_TARGET}
+ OUTPUT_SCRIPT deploy_script
+ )
+
+ set(common_deploy_args "")
+ if(arg_NO_TRANSLATIONS)
+ string(APPEND common_deploy_args " NO_TRANSLATIONS\n")
+ endif()
+ if(arg_NO_COMPILER_RUNTIME)
+ string(APPEND common_deploy_args " NO_COMPILER_RUNTIME\n")
+ endif()
+
+ # Forward the arguments that are exactly the same for qt_deploy_runtime_dependencies.
+ foreach(var IN LISTS qt_deploy_runtime_dependencies_options)
+ if(NOT "${arg_${var}}" STREQUAL "")
+ list(APPEND common_deploy_args ${var} ${arg_${var}})
endif()
- file(GENERATE OUTPUT "${file_name}" CONTENT "
-include(${QT_DEPLOY_SUPPORT})
+ endforeach()
+
+ _qt_internal_should_skip_deployment_api(skip_deployment skip_reason)
+ if(skip_deployment)
+ _qt_internal_generate_no_op_deploy_script(
+ FUNCTION_NAME "qt6_generate_deploy_app_script"
+ SKIP_REASON "${skip_reason}"
+ ${generate_args}
+ )
+ elseif(APPLE AND NOT IOS AND QT6_IS_SHARED_LIBS_BUILD AND is_bundle)
+ # TODO: Consider handling non-bundle applications in the future using the generic cmake
+ # runtime dependency feature.
+ qt6_generate_deploy_script(${generate_args}
+ CONTENT "
qt6_deploy_runtime_dependencies(
EXECUTABLE $<TARGET_FILE_NAME:${arg_TARGET}>.app
-)
+${common_deploy_args})
")
elseif(WIN32 AND QT6_IS_SHARED_LIBS_BUILD)
- file(GENERATE OUTPUT "${file_name}" CONTENT "
-include(${QT_DEPLOY_SUPPORT})
+ qt6_generate_deploy_script(${generate_args}
+ CONTENT "
+qt6_deploy_runtime_dependencies(
+ EXECUTABLE $<TARGET_FILE:${arg_TARGET}>
+ GENERATE_QT_CONF
+${common_deploy_args})
+")
+
+ elseif(UNIX AND NOT APPLE AND NOT ANDROID AND QT6_IS_SHARED_LIBS_BUILD
+ AND NOT CMAKE_CROSSCOMPILING)
+ qt6_generate_deploy_script(${generate_args}
+ CONTENT "
qt6_deploy_runtime_dependencies(
- EXECUTABLE \${QT_DEPLOY_BIN_DIR}/$<TARGET_FILE_NAME:${arg_TARGET}>
+ EXECUTABLE $<TARGET_FILE:${arg_TARGET}>
GENERATE_QT_CONF
-)")
+${common_deploy_args})
+")
elseif(NOT arg_NO_UNSUPPORTED_PLATFORM_ERROR AND NOT QT_INTERNAL_NO_UNSUPPORTED_PLATFORM_ERROR)
# Currently we don't deploy runtime dependencies if cross-compiling or using a static Qt.
- # We also don't do it if targeting Linux, but we could provide an option to do
- # so if we had a deploy tool or purely CMake-based deploy implementation.
# Error out by default unless the project opted out of the error.
# This provides us a migration path in the future without breaking compatibility promises.
message(FATAL_ERROR
"Support for installing runtime dependencies is not implemented for "
- "this target platform (${CMAKE_SYSTEM_NAME}, ${qt_build_type_string})."
+ "this target platform (${CMAKE_SYSTEM_NAME}, ${qt_build_type_string}). "
+ ${unsupported_platform_extra_message}
)
else()
- file(GENERATE OUTPUT "${file_name}" CONTENT "
-include(${QT_DEPLOY_SUPPORT})
-_qt_internal_show_skip_runtime_deploy_message(\"${qt_build_type_string}\")
-")
+ set(skip_message
+ "_qt_internal_show_skip_runtime_deploy_message(\"${qt_build_type_string}\"")
+ if(unsupported_platform_extra_message)
+ string(APPEND skip_message
+ "\n EXTRA_MESSAGE \"${unsupported_platform_extra_message}\"")
+ endif()
+ string(APPEND skip_message "\n)")
+ qt6_generate_deploy_script(${generate_args} CONTENT "${skip_message}")
endif()
+ set(${arg_OUTPUT_SCRIPT} "${deploy_script}" PARENT_SCOPE)
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)