mirror of https://github.com/qt/qtbase.git
CMake: Add optional propagation argument to qt_add_win_app_sdk
This propagation is used for including header files and linking to the Windows App SDK library. Pick-to: 6.10 Task-number: QTBUG-124800 Change-Id: Ib5132de3bd673a57f55dda92381315070b6ecb99 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
d022503606
commit
2c6167942a
|
@ -8,6 +8,23 @@ function(qt6_add_win_app_sdk target)
|
|||
return()
|
||||
endif()
|
||||
|
||||
set(no_value_options INTERFACE PUBLIC PRIVATE)
|
||||
set(single_value_options "")
|
||||
set(multi_value_options "")
|
||||
cmake_parse_arguments(PARSE_ARGV 1 arg
|
||||
"${no_value_options}" "${single_value_options}" "${multi_value_options}"
|
||||
)
|
||||
if(arg_UNPARSED_ARGUMENTS)
|
||||
message(FATAL_ERROR "Unexpected arguments: ${arg_UNPARSED_ARGUMENTS}")
|
||||
endif()
|
||||
|
||||
set(propagation PRIVATE)
|
||||
if(arg_PUBLIC)
|
||||
set(propagation PUBLIC)
|
||||
elseif(arg_INTERFACE)
|
||||
set(propagation INTERFACE)
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" OR
|
||||
CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64")
|
||||
set(win_app_sdk_arch "arm64")
|
||||
|
@ -87,15 +104,15 @@ function(qt6_add_win_app_sdk target)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
target_include_directories(${target} PRIVATE "${win_app_sdk_root}/include")
|
||||
target_include_directories(${target} ${propagation} "${win_app_sdk_root}/include")
|
||||
target_include_directories(${target}
|
||||
PRIVATE "${generated_headers_path}")
|
||||
${propagation} "${generated_headers_path}")
|
||||
target_link_directories(${target}
|
||||
PRIVATE "${win_app_sdk_root}/lib/win10-${win_app_sdk_arch}")
|
||||
${propagation} "${win_app_sdk_root}/lib/win10-${win_app_sdk_arch}")
|
||||
target_link_directories(${target}
|
||||
PRIVATE "${win_app_sdk_root}/runtimes/win-${win_app_sdk_arch}/native")
|
||||
${propagation} "${win_app_sdk_root}/runtimes/win-${win_app_sdk_arch}/native")
|
||||
target_link_libraries(${target}
|
||||
PRIVATE Microsoft.WindowsAppRuntime.lib Microsoft.WindowsAppRuntime.Bootstrap.lib)
|
||||
${propagation} Microsoft.WindowsAppRuntime.lib Microsoft.WindowsAppRuntime.Bootstrap.lib)
|
||||
endfunction()
|
||||
|
||||
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
|
||||
|
|
|
@ -16,7 +16,13 @@
|
|||
\section1 Synopsis
|
||||
|
||||
\badcode
|
||||
qt_add_win_app_sdk(target)
|
||||
qt_add_win_app_sdk(<TARGET>)
|
||||
\endcode
|
||||
|
||||
Since 6.10:
|
||||
|
||||
\badcode
|
||||
qt_add_win_app_sdk(<TARGET> [<PROPAGATION>])
|
||||
\endcode
|
||||
|
||||
\versionlessCMakeCommandsNote qt6_add_win_app_sdk()
|
||||
|
@ -24,7 +30,8 @@ qt_add_win_app_sdk(target)
|
|||
\section1 Description
|
||||
|
||||
Adds Windows App SDK include files to the project, and links the necessary
|
||||
libraries to the given CMake target. Windows App SDK is provided as a \l{https://learn.microsoft.com/en-us/nuget/what-is-nuget}{NuGet}
|
||||
libraries to the given CMake target. Windows App SDK is provided as
|
||||
a \l{https://learn.microsoft.com/en-us/nuget/what-is-nuget}{NuGet}
|
||||
package so it can be easily used in managed apps. However, for unmanaged
|
||||
C++ applications we need header files.
|
||||
The function takes the following steps:
|
||||
|
@ -34,5 +41,43 @@ The function takes the following steps:
|
|||
\li Includes those header files and links the library to the given CMake target
|
||||
\endlist
|
||||
|
||||
\section1 Arguments
|
||||
|
||||
\c PROPAGATION
|
||||
|
||||
Specifies the propagation visibility of include directories, link directories, and linked libraries
|
||||
for the target.
|
||||
This argument is passed directly to the following CMake commands:
|
||||
\list 1
|
||||
\li target_include_directories()
|
||||
\li target_link_directories()
|
||||
\li target_link_libraries()
|
||||
\endlist
|
||||
|
||||
It determines how these properties are applied to the target itself and whether they are propagated
|
||||
to other targets that link against it.
|
||||
\section2 Accepted values:
|
||||
\list 1
|
||||
\li PRIVATE:
|
||||
The settings (include directories, link directories, and linked libraries) are applied only
|
||||
to the current target. They are not visible to targets that link against this one.
|
||||
\li PUBLIC:
|
||||
The settings are applied to the current target and are also propagated to any target that
|
||||
links against it. Use this when the dependency is required both for building the target and
|
||||
for its consumers.
|
||||
\li INTERFACE:
|
||||
The settings are not used when building the current target, but are propagated to targets
|
||||
that link against it. This is typically used for header-only libraries or interface targets
|
||||
that expose usage requirements without needing them for their own build.
|
||||
\endlist
|
||||
|
||||
\section2 Notes
|
||||
\list 1
|
||||
\li This argument is optional.
|
||||
\li If omitted, the default behavior is equivalent to PRIVATE (or specify your actual default).
|
||||
\li Use the appropriate propagation scope to accurately describe your target’s dependencies
|
||||
and usage requirements.
|
||||
\endlist
|
||||
|
||||
\warning This command is not supported on non-MSVC platforms.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue