Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions Windows.EWDK.toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#
# The toolchain expects the following environment variables to have been initialized by the EWDK build environment:
#
# | CMake Variable | Description |
# | Environment Variable | Description |
# |---------------------------------------------|-------------------------------------------------------------------------------------------------------|
# | VCToolsVersion | The version of the MSVC platform toolset to use (e.g. 14.31.31103). |
# | VSCMD_ARG_HOST_ARCH | The architecture of the host tooling to use (e.g. x86). |
Expand Down Expand Up @@ -62,6 +62,7 @@
# | MSVC_VERSION | The '<major><minor>' version of the C++ compiler being used. For example, '1929' |
# | VS_INSTALLATION_PATH | The path to the Visual Studio instance to use. |
# | WIN32 | 1 |
# | EWDK | 1 |
#
# Resources:
# <https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html>
Expand All @@ -74,15 +75,22 @@ if("$ENV{BuildLabSetupRoot}" STREQUAL "")
message(FATAL_ERROR "The ${CMAKE_CURRENT_LIST_FILE} toolchain can only be used from an initialized EWDK build prompt.")
endif()

if(CMAKE_SYSTEM_PROCESSOR)
if(NOT (CMAKE_SYSTEM_PROCESSOR STREQUAL $ENV{VSCMD_ARG_TGT_ARCH}))
message(FATAL_ERROR "The 'CMAKE_SYSTEM_PROCESSOR' property - if set - must match the VSCMD_ARG_TGT_ARCH environment variable.")
if("$ENV{VSCMD_ARG_TGT_ARCH}" STREQUAL "x64")
if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "AMD64")
# Not cross-compiling
else()
set(CMAKE_SYSTEM_PROCESSOR "AMD64")
endif()
else()
set(CMAKE_SYSTEM_PROCESSOR $ENV{VSCMD_ARG_TGT_ARCH})
if(NOT CMAKE_SYSTEM_PROCESSOR)
message(FATAL_ERROR "The 'VSCMD_ARG_TGT_ARCH' environment variable should specify the architecture of the host toolset to use.")
elseif($ENV{VSCMD_ARG_TGT_ARCH} STREQUAL "arm64")
if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "ARM64")
# Not cross-compiling
else()
set(CMAKE_SYSTEM_PROCESSOR "ARM64")
endif()
elseif($ENV{VSCMD_ARG_TGT_ARCH} STREQUAL "x86")
set(CMAKE_SYSTEM_PROCESSOR "X86")
else()
message(FATAL_ERROR "The 'VSCMD_ARG_TGT_ARCH' environment variable specifies an unsupported target architecture: '$ENV{VSCMD_ARG_TGT_ARCH}'")
endif()

set(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE $ENV{VSCMD_ARG_HOST_ARCH})
Expand Down Expand Up @@ -111,3 +119,5 @@ if(NOT CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION)
endif()

include("${CMAKE_CURRENT_LIST_DIR}/Windows.MSVC.toolchain.cmake")

set(EWDK 1)
2 changes: 1 addition & 1 deletion example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ add_subdirectory(CommandLineC)
add_subdirectory(SharedLibrary)
add_subdirectory(WindowsApplication)

if((CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") AND (CMAKE_SYSTEM_PROCESSOR STREQUAL AMD64))
if((CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") AND (CMAKE_SYSTEM_PROCESSOR STREQUAL AMD64) AND (NOT EWDK))
if(DEFINED ENV{CUDA_PATH})
add_subdirectory(CommandLineCuda)
else()
Expand Down
3 changes: 2 additions & 1 deletion example/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@
"VS_EXPERIMENTAL_MODULE": "OFF",
"VS_USE_SPECTRE_MITIGATION_RUNTIME": "OFF"
},
"binaryDir": "${sourceDir}/__output/${presetName}-$env{VSCMD_ARG_TGT_ARCH}"
"binaryDir": "${sourceDir}/__output/${presetName}-$env{VSCMD_ARG_TGT_ARCH}",
"condition": { "lhs": "$env{VSCMD_ARG_TGT_ARCH}", "type": "notEquals", "rhs": "" }
},
{
"name": "windows-vs",
Expand Down