[UWP] Add cmake option: AX_VS_DEPLOYMENT_TARGET

a. It's useful to specify UWP apps deploy target version, vs property is
TargetPlatformMinVersion
b. Use `CMAKE_VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION` possible
supported by cmake-3.27.0 or later
This commit is contained in:
halx99 2023-03-14 08:24:27 +08:00
parent 32c32bf98a
commit 2f04914405
5 changed files with 43 additions and 23 deletions

View File

@ -29,6 +29,7 @@
- AX_ENABLE_EXT_LIVE2D: the live2d extension, default: `FALSE`
- AX_ENABLE_EXT_EFFEKSEER: the effekseer extension, default: `FALSE`
- AX_WITH_XXX: usually user don't need care it
- AX_VS_DEPLOYMENT_TARGET: specify windows store deploy target, default: `10.0.17763.0`
## The options for axmol apps

View File

@ -141,7 +141,7 @@ Examples:
6. Use Visual Studio to open the newly created solution file. For example, `./build/ProjectName.sln`
#### Windows UWP (Visual Studio 2022), because microsoft limit, only support C++17
```cmake -B build_uwp -DCMAKE_SYSTEM_NAME=WindowsStore "-DCMAKE_SYSTEM_VERSION=10.0"```
```cmake -B build_uwp -DCMAKE_SYSTEM_NAME=WindowsStore "-DCMAKE_SYSTEM_VERSION=10.0" "-DAX_VS_DEPLOYMENT_TARGET=10.0.17763.0"```
##### Creating the Visual Studio solution for all axmol test projects
@ -233,14 +233,7 @@ See [windows workflow guide](https://github.com/axmolengine/axmol/issues/564)
6. After cmake finishes generating, you can open the xcode project at ```build``` folder and run cpp-tests or other test targets.
7. Notes
- **The code signing is required to run the ios/tvos app on your device, just change the bundle identifier until the auto manage signing is solved**
- **axmol only provides armv7, arm64, x86_64 prebuilt libraries for ios/tvos**
### Notes
- ThreadLocalStorage (TLS)
- ios x86 simulator ios>=10 and axmol no longer provide x86 libraries
- ios x64 or devices (armv7, arm64) ios sdk>=9.0
- the 'OpenAL Soft' maintained by kcat uses TLS
- **axmol only provides aarm64, x86_64 prebuilt libraries for ios/tvos**
### Reference links

View File

@ -82,10 +82,9 @@
1. 安装CMake要求3.22以上
2. 确保 Visual Studio 2019/2022 已正确安装
3. 执行下面的命令
```bat
cd axmol
cmake -S . -B build -G "Visual Studio 16 2019" -A Win32
```
- PC: ```cmake -S . -B build -G "Visual Studio 16 2019"```
- UWP: ```cmake -S . -B build -G "Visual Studio 17 2022" -A x64 -DCMAKE_SYSTEM_NAME=WindowsStore "-DCMAKE_SYSTEM_VERSION=10.0" "-DAX_VS_DEPLOYMENT_TARGET=10.0.17763.0"```
4. 之后就可以用vs打开```axmol/build/axmol.sln```启动cpp-tests等测试工程了
#### Android

View File

@ -432,17 +432,23 @@ endmacro()
function (ax_uwp_set_all_targets_deploy_min_version)
if (WINRT)
set(oneValueArgs TARGET_PLATFORM_MIN_VERSION)
cmake_parse_arguments(opt "" "${oneValueArgs}" "" ${ARGN})
if (NOT opt_TARGET_PLATFORM_MIN_VERSION)
set(opt_TARGET_PLATFORM_MIN_VERSION "10.0.19041.0")
endif()
get_all_targets(all_targets)
if (DEFINED CMAKE_VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION)
message(STATUS "You are using a cmake version which is support CMAKE_VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION=${CMAKE_VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION}, \nskip set VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION for targets one by one.")
else()
set(oneValueArgs TARGET_PLATFORM_MIN_VERSION)
cmake_parse_arguments(opt "" "${oneValueArgs}" "" ${ARGN})
if (NOT opt_TARGET_PLATFORM_MIN_VERSION)
# The minmal deploy target version: Windows 10, version 1809 (Build 10.0.17763) for building msix package
# refer to: https://learn.microsoft.com/en-us/windows/msix/supported-platforms?source=recommendations
set(opt_TARGET_PLATFORM_MIN_VERSION ${AX_VS_DEPLOYMENT_TARGET})
endif()
get_all_targets(all_targets)
foreach(target ${all_targets})
set_target_properties(${target} PROPERTIES VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION "${opt_TARGET_PLATFORM_MIN_VERSION}")
endforeach()
foreach(target ${all_targets})
set_target_properties(${target} PROPERTIES VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION "${opt_TARGET_PLATFORM_MIN_VERSION}")
endforeach()
endif()
endif()
endfunction()

View File

@ -8,12 +8,33 @@ define_property(TARGET
FULL_DOCS "use to save depend libs of axmol lua project"
)
# UWP min deploy target support, VS property: targetPlatformMinVersion
if (WINRT)
if (NOT DEFINED AX_VS_DEPLOYMENT_TARGET)
set(AX_VS_DEPLOYMENT_TARGET "10.0.17763.0")
endif()
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER_EQUAL "3.27.0")
if (NOT DEFINED)
# The minmal deploy target version: Windows 10, version 1809 (Build 10.0.17763) for building msix package
# refer to: https://learn.microsoft.com/en-us/windows/msix/supported-platforms?source=recommendations
set(CMAKE_VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION ${AX_VS_DEPLOYMENT_TARGET})
endif()
else()
if(DEFINED CMAKE_VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION)
unset(CMAKE_VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION)
endif()
endif()
endif()
# config c standard
if(NOT DEFINED CMAKE_C_STANDARD)
if (WINDOWS)
message(STATUS "CMAKE_HOST_SYSTEM_VERSION: ${CMAKE_HOST_SYSTEM_VERSION}")
message(STATUS "CMAKE_SYSTEM_VERSION: ${CMAKE_SYSTEM_VERSION}")
message(STATUS "CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
if (DEFINED CMAKE_VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION)
message(STATUS "CMAKE_VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION}")
endif()
if (NOT CMAKE_SYSTEM_VERSION)
set(CMAKE_SYSTEM_VERSION ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION})
endif()