cmake: Generate Apple privacy manifest files for Qt modules

The default manifest is a minimal file that claims NSPrivacyTracking
false, along with an empty list of NSPrivacyTrackingDomains and
NSPrivacyCollectedDataTypes, as Qt does not generally do user tracking.

Modules can override the default manifest by setting the
PRIVACY_MANIFEST target property, specifying a custom privacy
manifest.

The NSPrivacyAccessedAPITypes key is only required for iOS for now.
Even though we don't build Qt for iOS as frameworks yet, which is
required to embed a privacy manifest, we include the keys for the
APIs we known we use.

Task-number: QTBUG-114319
Change-Id: I654bb52b98ee963adeeb744b35f3a1c2a1270969
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Tor Arne Vestbø 2024-02-12 15:19:56 +01:00
parent 6657acf8f5
commit 9cca899574
11 changed files with 151 additions and 0 deletions

View File

@ -329,6 +329,7 @@ if(APPLE)
set(platform_shortname "ios")
endif()
# Info.plist
qt_copy_or_install(FILES "cmake/${platform_shortname}/Info.plist.app.in"
DESTINATION "${__GlobalConfig_install_dir}/${platform_shortname}"
)
@ -337,6 +338,15 @@ if(APPLE)
DESTINATION "${__GlobalConfig_build_dir}/${platform_shortname}"
)
# Privacy manifest
qt_copy_or_install(FILES "cmake/${platform_shortname}/PrivacyInfo.xcprivacy"
DESTINATION "${__GlobalConfig_install_dir}/${platform_shortname}"
)
# For examples built as part of prefix build before install
file(COPY "cmake/${platform_shortname}/PrivacyInfo.xcprivacy"
DESTINATION "${__GlobalConfig_build_dir}/${platform_shortname}"
)
if(IOS)
qt_copy_or_install(FILES "cmake/ios/LaunchScreen.storyboard"
DESTINATION "${__GlobalConfig_install_dir}/ios"

View File

@ -131,6 +131,10 @@ macro(qt_internal_set_apple_archiver_flags)
endif()
endmacro()
macro(qt_internal_set_apple_privacy_manifest target manifest_file)
set_target_properties(${target} PROPERTIES _qt_privacy_manifest "${manifest_file}")
endmacro()
macro(qt_internal_set_debug_extend_target)
option(QT_CMAKE_DEBUG_EXTEND_TARGET "Debug extend_target calls in Qt's build system" OFF)
endmacro()

View File

@ -911,6 +911,22 @@ set(QT_ALLOW_MISSING_TOOLS_PACKAGES TRUE)")
qt_add_list_file_finalizer(qt_finalize_module ${target} ${arg_INTERNAL_MODULE} ${arg_NO_PRIVATE_MODULE})
endfunction()
function(qt_internal_apply_apple_privacy_manifest target)
if(APPLE)
# Privacy manifest
get_target_property(is_framework ${target} FRAMEWORK)
if(is_framework)
get_target_property(privacy_manifest ${target} _qt_privacy_manifest)
if(NOT privacy_manifest)
set(privacy_manifest
"${__qt_internal_cmake_apple_support_files_path}/PrivacyInfo.xcprivacy")
endif()
target_sources("${target}" PRIVATE "${privacy_manifest}")
set_property(TARGET "${target}" APPEND PROPERTY RESOURCE "${privacy_manifest}")
endif()
endif()
endfunction()
function(qt_finalize_module target)
qt_internal_collect_module_headers(module_headers ${target})
@ -934,6 +950,7 @@ function(qt_finalize_module target)
qt_generate_prl_file(${target} "${INSTALL_LIBDIR}")
qt_generate_module_pri_file("${target}" ${ARGN})
qt_internal_generate_pkg_config_file(${target})
qt_internal_apply_apple_privacy_manifest(${target})
endfunction()
# Get a set of Qt module related values based on the target.

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypes</key>
<array/>
<key>NSPrivacyTrackingDomains</key>
<array/>
<key>NSPrivacyAccessedAPITypes</key>
<array/>
</dict>
</plist>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypes</key>
<array/>
<key>NSPrivacyTrackingDomains</key>
<array/>
</dict>
</plist>

View File

@ -1442,6 +1442,11 @@ if(APPLE AND QT_FEATURE_framework AND QT_FEATURE_separate_debug_info)
)
endif()
if(IOS)
qt_internal_set_apple_privacy_manifest(Core
"${CMAKE_CURRENT_SOURCE_DIR}/platform/ios/PrivacyInfo.xcprivacy")
endif()
set(linker_script_contents "")
if (QT_NAMESPACE STREQUAL "")
set(tag_symbol "qt_version_tag")

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypes</key>
<array/>
<key>NSPrivacyTrackingDomains</key>
<array/>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>0A2A.1</string> <!-- QFileInfo -->
</array>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryDiskSpace</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>85F4.1</string> <!-- QStorageInfo -->
</array>
</dict>
</array>
</dict>
</plist>

View File

@ -1032,4 +1032,9 @@ qt_internal_add_docs(Gui
doc/qtgui.qdocconf
)
if(IOS)
qt_internal_set_apple_privacy_manifest(Gui
"${CMAKE_CURRENT_SOURCE_DIR}/platform/ios/PrivacyInfo.xcprivacy")
endif()
qt_internal_add_optimize_full_flags()

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypes</key>
<array/>
<key>NSPrivacyTrackingDomains</key>
<array/>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategorySystemBootTime</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>35F9.1</string> <!-- QUIView event handling -->
</array>
</dict>
</array>
</dict>
</plist>

View File

@ -911,6 +911,11 @@ qt_internal_add_docs(Widgets
doc/qtwidgets.qdocconf
)
if(IOS)
qt_internal_set_apple_privacy_manifest(Widgets
"${CMAKE_CURRENT_SOURCE_DIR}/platform/ios/PrivacyInfo.xcprivacy")
endif()
# include the snippet projects for developer-builds
if(QT_FEATURE_private_tests)
add_subdirectory(doc/snippets/customviewstyle)

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypes</key>
<array/>
<key>NSPrivacyTrackingDomains</key>
<array/>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>DDA9.1</string> <!-- QFileDialog -->
<string>C617.1</string> <!-- QFileDialog -->
<string>3B52.1</string> <!-- QFileDialog -->
</array>
</dict>
</array>
</dict>
</plist>