Merge topic 'vs2022-android'

16d8b65bc0 VS/Android: Use safe API level when detecting the NDK directory
f7af10100c VS/Android: Detect full NDK root instead of sysroot
850ee280e0 VS/Android: Set API level explicitly during compiler identification
5d5b6c741d VS/Android: Do not specify Windows Runtime library type during compiler id
e78abf94e3 VS/Android: Use ApplicationTypeRevision 3.0 in VS2022

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8426
This commit is contained in:
Brad King
2023-04-26 14:28:29 +00:00
committed by Kitware Robot
4 changed files with 16 additions and 17 deletions
+3 -1
View File
@@ -345,6 +345,7 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
set(id_platform ${CMAKE_VS_PLATFORM_NAME})
set(id_lang "${lang}")
set(id_PostBuildEvent_Command "")
set(id_api_level "")
if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "^[Ll][Ll][Vv][Mm](_v[0-9]+(_xp)?)?$")
set(id_cl_var "ClangClExecutable")
elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "^[Cc][Ll][Aa][Nn][Gg]([Cc][Ll]$|_[0-9])")
@@ -430,9 +431,10 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
set(id_system "")
endif()
if(id_keyword STREQUAL "Android")
set(id_api_level "<AndroidAPILevel>android-${CMAKE_SYSTEM_VERSION}</AndroidAPILevel>")
if(CMAKE_GENERATOR MATCHES "Visual Studio 14")
set(id_system_version "<ApplicationTypeRevision>2.0</ApplicationTypeRevision>")
elseif(CMAKE_GENERATOR MATCHES "Visual Studio 1[56]")
elseif(CMAKE_GENERATOR MATCHES "Visual Studio 1[567]")
set(id_system_version "<ApplicationTypeRevision>3.0</ApplicationTypeRevision>")
else()
set(id_system_version "")
+2 -1
View File
@@ -26,6 +26,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@id_platform@'" Label="Configuration">
<ConfigurationType>@id_config_type@</ConfigurationType>
@id_toolset@
@id_api_level@
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -44,7 +45,7 @@
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<RuntimeLibrary Condition="'$(ApplicationType)'!='Android'">MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
+9 -14
View File
@@ -34,18 +34,13 @@ cmake_policy(PUSH)
cmake_policy(SET CMP0057 NEW) # if IN_LIST
# If using Android tools for Visual Studio, compile a sample project to get the
# sysroot.
# NDK path
if(CMAKE_GENERATOR MATCHES "Visual Studio")
if(NOT CMAKE_SYSROOT)
if(NOT CMAKE_ANDROID_NDK)
set(vcx_platform ${CMAKE_GENERATOR_PLATFORM})
if(CMAKE_GENERATOR MATCHES "Visual Studio 1[45]")
set(vcx_sysroot_var "Sysroot")
else()
set(vcx_sysroot_var "SysrootLink")
endif()
if(CMAKE_GENERATOR MATCHES "Visual Studio 14")
set(vcx_revision "2.0")
elseif(CMAKE_GENERATOR MATCHES "Visual Studio 1[56]")
elseif(CMAKE_GENERATOR MATCHES "Visual Studio 1[567]")
set(vcx_revision "3.0")
else()
set(vcx_revision "")
@@ -62,16 +57,16 @@ if(CMAKE_GENERATOR MATCHES "Visual Studio")
RESULT_VARIABLE VCXPROJ_INSPECT_RESULT
)
unset(_msbuild)
if(NOT CMAKE_SYSROOT AND VCXPROJ_INSPECT_OUTPUT MATCHES "CMAKE_SYSROOT=([^%\r\n]+)[\r\n]")
if(VCXPROJ_INSPECT_OUTPUT MATCHES "CMAKE_ANDROID_NDK=([^%\r\n]+)[\r\n]")
# Strip VS diagnostic output from the end of the line.
string(REGEX REPLACE " \\(TaskId:[0-9]*\\)$" "" _sysroot "${CMAKE_MATCH_1}")
if(EXISTS "${_sysroot}")
file(TO_CMAKE_PATH "${_sysroot}" CMAKE_SYSROOT)
string(REGEX REPLACE " \\(TaskId:[0-9]*\\)$" "" _ndk "${CMAKE_MATCH_1}")
if(EXISTS "${_ndk}")
file(TO_CMAKE_PATH "${_ndk}" CMAKE_ANDROID_NDK)
endif()
endif()
if(VCXPROJ_INSPECT_RESULT)
message(CONFIGURE_LOG
"Determining the sysroot for the Android NDK failed.
"Determining the Android NDK failed from msbuild failed.
The output was:
${VCXPROJ_INSPECT_RESULT}
${VCXPROJ_INSPECT_OUTPUT}
@@ -79,7 +74,7 @@ ${VCXPROJ_INSPECT_OUTPUT}
")
else()
message(CONFIGURE_LOG
"Determining the sysroot for the Android NDK succeeded.
"Determining the Android NDK succeeded.
The output was:
${VCXPROJ_INSPECT_RESULT}
${VCXPROJ_INSPECT_OUTPUT}
@@ -19,6 +19,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@vcx_platform@'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<AndroidAPILevel>android-21</AndroidAPILevel>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@@ -29,7 +30,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@vcx_platform@'">
<PostBuildEvent>
<Command>%40echo CMAKE_SYSROOT=$(@vcx_sysroot_var@)</Command>
<Command>%40echo CMAKE_ANDROID_NDK=$(VS_NdkRoot)</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />