https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5f94b23d2b4d4bdea986f…
commit 5f94b23d2b4d4bdea986ffeb8fa2b6059ec81ccd
Author: Mark Jansen <mark.jansen(a)reactos.org>
AuthorDate: Sun Apr 11 15:57:14 2021 +0200
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Mon May 24 17:34:49 2021 +0200
[HOST-TOOLS] Configure environment for MSVC cross-compiling
This makes ARM builds on a non-arm host work again.
CORE-17542
CORE-17517
---
sdk/cmake/host-tools.cmake | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/sdk/cmake/host-tools.cmake b/sdk/cmake/host-tools.cmake
index 6c550c57d4a..1f00f74e6a2 100644
--- a/sdk/cmake/host-tools.cmake
+++ b/sdk/cmake/host-tools.cmake
@@ -29,6 +29,48 @@ function(setup_host_tools)
set(HOST_MODULE_SUFFIX ".so")
endif()
+ # Normalize to the same format as our own ARCH, and add one for the VC shell
+ string(TOLOWER "${CMAKE_HOST_SYSTEM_PROCESSOR}"
lowercase_CMAKE_HOST_SYSTEM_PROCESSOR)
+ if(lowercase_CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL x86 OR
lowercase_CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^i[3456]86$")
+ set(HOST_ARCH i386)
+ set(VCVARSALL_ARCH x86)
+ elseif(lowercase_CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL x86_64 OR
lowercase_CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL amd64)
+ set(HOST_ARCH amd64)
+ set(VCVARSALL_ARCH amd64_x86) # x64 host-tools are not happy compiling for
x86...
+ elseif(lowercase_CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL arm)
+ set(HOST_ARCH arm)
+ set(VCVARSALL_ARCH arm)
+ else()
+ message(FATAL_ERROR "Unknown host architecture:
${lowercase_CMAKE_HOST_SYSTEM_PROCESSOR}")
+ endif()
+
+ if(ARCH STREQUAL HOST_ARCH)
+ set(HOST_TOOLS_CMAKE_COMMAND "${CMAKE_COMMAND}")
+ message("Not cross-compiling, no special host-tools cmake command")
+ elseif(MSVC)
+ message("Compiling on ${HOST_ARCH} for ${ARCH} (MSVC)")
+ set(HOST_TOOLS_CMAKE_COMMAND
"${REACTOS_BINARY_DIR}/host-tools/cmake_shim.cmd")
+ if(MSVC_VERSION EQUAL 1900)
+ file(WRITE ${HOST_TOOLS_CMAKE_COMMAND}
+ "@call \"$ENV{VCINSTALLDIR}\\vcvarsall.bat\"
${VCVARSALL_ARCH}\n"
+ "\"${CMAKE_COMMAND}\" %*"
+ )
+ elseif(MSVC_VERSION GREATER_EQUAL 1910)
+ # 2017 and 2019 use the same folder structure
+ file(WRITE ${HOST_TOOLS_CMAKE_COMMAND}
+ "@set VSCMD_ARG_no_logo=1\n"
+ "@call
\"$ENV{VCINSTALLDIR}\\Auxiliary\\Build\\vcvarsall.bat\" /clean_env\n"
+ "@call
\"$ENV{VCINSTALLDIR}\\Auxiliary\\Build\\vcvarsall.bat\"
${VCVARSALL_ARCH}\n"
+ "\"${CMAKE_COMMAND}\" %*"
+ )
+ else()
+ message(FATAL "Unable to figure out vcvarsall path")
+ endif()
+ else()
+ set(HOST_TOOLS_CMAKE_COMMAND "${CMAKE_COMMAND}")
+ message("Cross-compiling on non-msvc, no special host-tools cmake
command")
+ endif()
+
# CMake might choose clang if it finds it in the PATH. Always prefer cl for host
tools
if (MSVC)
list(APPEND CMAKE_HOST_TOOLS_EXTRA_ARGS
@@ -40,6 +82,7 @@ function(setup_host_tools)
SOURCE_DIR ${REACTOS_SOURCE_DIR}
PREFIX ${REACTOS_BINARY_DIR}/host-tools
BINARY_DIR ${REACTOS_BINARY_DIR}/host-tools/bin
+ CMAKE_COMMAND ${HOST_TOOLS_CMAKE_COMMAND}
CMAKE_ARGS
-UCMAKE_TOOLCHAIN_FILE
-DARCH:STRING=${ARCH}