mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-10-07 04:02:23 +03:00
FindVulkan: Add support for cross-compiling between Windows x64/ARM64
The LunarG Vulkan SDK on Windows provides arch-specific library directories for cross-compiling. On X64 hosts it provides `-ARM64` directories. On ARM64 hosts it provides `-X64` directories. It also provides arch-specific `bin` directories, but only for the `.dll`s of the cross architecture. We still want the plain `bin` directory containing host-architecture executable tools. Co-authored-by: Giancane, Francesco <fgiancan@qti.qualcomm.com> Co-authored-by: Arnaud, Adrien <aarnaud@qti.qualcomm.com> Tested-by: Giancane, Francesco <fgiancan@qti.qualcomm.com> Tested-by: Arnaud, Adrien <aarnaud@qti.qualcomm.com>
This commit is contained in:
1 parent
f9a09f76f3
commit
5e1440302a
1 file changed
+35
-1
@@ -345,9 +345,43 @@ if(DEFINED ENV{VULKAN_SDK} AND IS_DIRECTORY "$ENV{VULKAN_SDK}")
|
||||
set(_Vulkan_hint_executable_search_paths
|
||||
"$ENV{VULKAN_SDK}/bin"
|
||||
)
|
||||
if(WIN32)
|
||||
# Detect the target architecture from one of:
|
||||
# - the C++ compiler,
|
||||
# - the C compiler,
|
||||
# - the VS generator,
|
||||
# - the command-line environment,
|
||||
# - fallback to CMAKE_SYSTEM_PROCESSOR.
|
||||
if(CMAKE_CXX_COMPILER_LOADED AND CMAKE_CXX_COMPILER_ARCHITECTURE_ID)
|
||||
set(_Vulkan_arch_name "${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}")
|
||||
elseif(CMAKE_C_COMPILER_LOADED AND CMAKE_C_COMPILER_ARCHITECTURE_ID)
|
||||
set(_Vulkan_arch_name "${CMAKE_C_COMPILER_ARCHITECTURE_ID}")
|
||||
elseif(CMAKE_VS_PLATFORM_NAME)
|
||||
set(_Vulkan_arch_name "${CMAKE_VS_PLATFORM_NAME}")
|
||||
elseif(DEFINED ENV{VSCMD_ARG_TGT_ARCH})
|
||||
set(_Vulkan_arch_name "$ENV{VSCMD_ARG_TGT_ARCH}")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR)
|
||||
set(_Vulkan_arch_name "${CMAKE_SYSTEM_PROCESSOR}")
|
||||
endif()
|
||||
# The Vulkan SDK may provide arch-specific directories for cross-compiling.
|
||||
if(_Vulkan_arch_name MATCHES "^(ARM64|arm64|aarch64)" AND IS_DIRECTORY "$ENV{VULKAN_SDK}/lib-arm64")
|
||||
# On X64 hosts the Vulkan SDK provides `-arm64` dirs for cross-compiling to ARM64.
|
||||
set(_Vulkan_arch_suffix "-arm64")
|
||||
elseif(_Vulkan_arch_name MATCHES "^(X64|x64|x86_64)" AND IS_DIRECTORY "$ENV{VULKAN_SDK}/lib-x64")
|
||||
# On ARM64 hosts the Vulkan SDK provides `-x64` dirs for cross-compiling to x64.
|
||||
set(_Vulkan_arch_suffix "-x64")
|
||||
else()
|
||||
# Otherwise assume we are compiling for the host.
|
||||
set(_Vulkan_arch_suffix "")
|
||||
endif()
|
||||
unset(_Vulkan_arch_name)
|
||||
else()
|
||||
set(_Vulkan_arch_suffix "")
|
||||
endif()
|
||||
set(_Vulkan_hint_library_search_paths
|
||||
"$ENV{VULKAN_SDK}/lib"
|
||||
"$ENV{VULKAN_SDK}/lib${_Vulkan_arch_suffix}"
|
||||
)
|
||||
unset(_Vulkan_arch_suffix)
|
||||
if(APPLE)
|
||||
cmake_path(SET _MoltenVK_path NORMALIZE "$ENV{VULKAN_SDK}/../MoltenVK")
|
||||
if(IS_DIRECTORY "${_MoltenVK_path}")
|
||||
|
||||
Reference in new issue
Block a user