Index: cmake/platforms/WinMsvc.cmake =================================================================== --- cmake/platforms/WinMsvc.cmake +++ cmake/platforms/WinMsvc.cmake @@ -5,6 +5,7 @@ # cmake -G Ninja # -DCMAKE_TOOLCHAIN_FILE=/path/to/this/file # -DLLVM_NATIVE_TOOLCHAIN=/path/to/llvm/installation +# -DHOST_ARCH=[aarch64|armv7|i686|x86_64] # -DMSVC_BASE=/path/to/MSVC/system/libraries/and/includes # -DWINSDK_BASE=/path/to/windows-sdk # -DWINSDK_VER=windows sdk version folder name @@ -16,6 +17,9 @@ # copy of clang-cl, clang, clang++, and lld-link, as well as a lib directory # containing clang's system resource directory. # +# HOST_ARCH: +# The architecture to build for. +# # MSVC_BASE: # *Absolute path* to the folder containing MSVC headers and system libraries. # The layout of the folder matches that which is intalled by MSVC 2017 on @@ -152,17 +156,32 @@ endforeach() endfunction() -# FIXME: We should support target architectures other than x64 set(CMAKE_SYSTEM_NAME Windows) set(CMAKE_SYSTEM_VERSION 10.0) set(CMAKE_SYSTEM_PROCESSOR AMD64) init_user_prop(LLVM_NATIVE_TOOLCHAIN) +init_user_prop(HOST_ARCH) init_user_prop(MSVC_BASE) init_user_prop(WINSDK_BASE) init_user_prop(WINSDK_VER) init_user_prop(WINSDK_CASE_SENSITIVE) +if(NOT HOST_ARCH) + set(HOST_ARCH x86_64) +endif() +if(HOST_ARCH STREQUAL "aarch64") + set(WINSDK_ARCH "arm64") +elseif(HOST_ARCH STREQUAL "armv7") + set(WINSDK_ARCH "arm") +elseif(HOST_ARCH STREQUAL "i686") + set(WINSDK_ARCH "x86") +elseif(HOST_ARCH STREQUAL "x86_64") + set(WINSDK_ARCH "x64") +else() + message(SEND_ERROR "Unknown host architecture ${HOST_ARCH}. Must be aarch64, armv7, i686, or x86_64.") +endif() + set(MSVC_INCLUDE "${MSVC_BASE}/include") set(MSVC_LIB "${MSVC_BASE}/lib") set(WINSDK_INCLUDE "${WINSDK_BASE}/Include/${WINSDK_VER}") @@ -211,6 +230,7 @@ set(COMPILE_FLAGS -D_CRT_SECURE_NO_WARNINGS + -Xclang -triple -Xclang ${HOST_ARCH}-pc-windows-msvc19.11.0 -fms-compatibility-version=19.11 -imsvc "${MSVC_INCLUDE}" -imsvc "${WINSDK_INCLUDE}/ucrt" @@ -248,17 +268,16 @@ # Prevent CMake from attempting to invoke mt.exe. It only recognizes the slashed form and not the dashed form. /manifest:no - # FIXME: We should support target architectures other than x64. - -libpath:"${MSVC_LIB}/x64" - -libpath:"${WINSDK_LIB}/ucrt/x64" - -libpath:"${WINSDK_LIB}/um/x64") + -libpath:"${MSVC_LIB}/${WINSDK_ARCH}" + -libpath:"${WINSDK_LIB}/ucrt/${WINSDK_ARCH}" + -libpath:"${WINSDK_LIB}/um/${WINSDK_ARCH}") if(WINSDK_CASE_SENSITIVE) # Ensure all sub-configures use the top-level symlinks dir instead of generating their own. init_user_prop(winsdk_lib_symlinks_dir) if(NOT winsdk_lib_symlinks_dir) set(winsdk_lib_symlinks_dir "${CMAKE_BINARY_DIR}/winsdk_lib_symlinks") - generate_winsdk_lib_symlinks("${WINSDK_BASE}/Lib/${WINSDK_VER}/um/x64" "${winsdk_lib_symlinks_dir}") + generate_winsdk_lib_symlinks("${WINSDK_BASE}/Lib/${WINSDK_VER}/um/${WINSDK_ARCH}" "${winsdk_lib_symlinks_dir}") init_user_prop(winsdk_lib_symlinks_dir) endif() list(APPEND LINK_FLAGS