diff options
author | Michael Karcher <kitware@mkarcher.dialup.fu-berlin.de> | 2023-04-21 16:08:30 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-04-25 17:48:33 (GMT) |
commit | f7af10100c034e485970cdff13822675b78eb48e (patch) | |
tree | 98f866ce1afc99668f180f83839f757fff207117 | |
parent | 850ee280e0bb726771ea14f247ba1524b0c3dd64 (diff) | |
download | CMake-f7af10100c034e485970cdff13822675b78eb48e.zip CMake-f7af10100c034e485970cdff13822675b78eb48e.tar.gz CMake-f7af10100c034e485970cdff13822675b78eb48e.tar.bz2 |
VS/Android: Detect full NDK root instead of sysroot
Visual Studio always uses a complete NDK and not a standalone toolchain.
Let CMake handle the NDK and related logic correctly, avoid trying to
find the standalone toolchain version from the unified clang toolchain
in newer NDKs.
-rw-r--r-- | Modules/Platform/Android-Determine.cmake | 21 | ||||
-rw-r--r-- | Modules/Platform/Android/VCXProjInspect.vcxproj.in | 2 |
2 files changed, 9 insertions, 14 deletions
diff --git a/Modules/Platform/Android-Determine.cmake b/Modules/Platform/Android-Determine.cmake index bf717af..bc60222 100644 --- a/Modules/Platform/Android-Determine.cmake +++ b/Modules/Platform/Android-Determine.cmake @@ -34,15 +34,10 @@ 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[567]") @@ -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} diff --git a/Modules/Platform/Android/VCXProjInspect.vcxproj.in b/Modules/Platform/Android/VCXProjInspect.vcxproj.in index 6919d2c..71fd214 100644 --- a/Modules/Platform/Android/VCXProjInspect.vcxproj.in +++ b/Modules/Platform/Android/VCXProjInspect.vcxproj.in @@ -29,7 +29,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" /> |