From 42418b02f769858d68ce21a58dab3025d30f31a2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 20 Oct 2021 12:07:59 -0400 Subject: Android: Refactor sysroot detection under Visual Studio Since commit 6051a49c78 (Visual Studio: Add Android support, 2020-06-12, v3.19.0-rc1~619^2) we run MSBuild to build a sample project to detect the sysroot. Previously we relied on `CMAKE_VS_MSBUILD_COMMAND` being available. That required commit d5b5c19278 (cmGlobalGenerator: FindMakeProgram() before CMakeDetermineSystem, 2020-06-15, v3.19.0-rc1~619^2~3) to make it available early enough. However, that ordering broke `CMAKE_GENERATOR_INSTANCE` so we need to prepare to revert it. Use `cmake_host_system_information` to get the location of MSBuild under a VS generator instead. --- Modules/Platform/Android-Determine.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/Platform/Android-Determine.cmake b/Modules/Platform/Android-Determine.cmake index 7b67f83..a4e9574 100644 --- a/Modules/Platform/Android-Determine.cmake +++ b/Modules/Platform/Android-Determine.cmake @@ -52,14 +52,16 @@ if(CMAKE_GENERATOR MATCHES "Visual Studio") endif() configure_file(${CMAKE_ROOT}/Modules/Platform/Android/VCXProjInspect.vcxproj.in ${CMAKE_PLATFORM_INFO_DIR}/VCXProjInspect.vcxproj @ONLY) + cmake_host_system_information(RESULT _msbuild QUERY VS_MSBUILD_COMMAND) # undocumented query execute_process( - COMMAND "${CMAKE_VS_MSBUILD_COMMAND}" "VCXProjInspect.vcxproj" + COMMAND "${_msbuild}" "VCXProjInspect.vcxproj" "/p:Configuration=Debug" "/p:Platform=${vcx_platform}" WORKING_DIRECTORY ${CMAKE_PLATFORM_INFO_DIR} OUTPUT_VARIABLE VCXPROJ_INSPECT_OUTPUT ERROR_VARIABLE VCXPROJ_INSPECT_OUTPUT RESULT_VARIABLE VCXPROJ_INSPECT_RESULT ) + unset(_msbuild) if(NOT CMAKE_SYSROOT AND VCXPROJ_INSPECT_OUTPUT MATCHES "CMAKE_SYSROOT=([^%\r\n]+)[\r\n]") # Strip VS diagnostic output from the end of the line. string(REGEX REPLACE " \\(TaskId:[0-9]*\\)$" "" _sysroot "${CMAKE_MATCH_1}") -- cgit v0.12