Skip to content

Commit

Permalink
build: add clang x86_64 Windows toolchain file (#265)
Browse files Browse the repository at this point in the history
* build: add clang x86_64 Windows toolchain file

* review: fix comments
  • Loading branch information
rjaegers committed Apr 20, 2023
1 parent baf9ee1 commit 30a8ae1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.cache/
.vs/
.xwin-cache/
build/
install/
megalinter-reports/
Expand Down
22 changes: 22 additions & 0 deletions cmake/toolchain-x86_64-pc-windows-msvc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This toolchain file enables cross-compilation from non-Windows hosts to Windows hosts.
# It assumes the Windows SDK and CRT are installed at a path specified by WINDOWS_SDK_ROOT.
#
# The recommended way of installing the SDK and CRT is by using xwin (https://github.com/Jake-Shadle/xwin):
# $ xwin --accept-license splat --preserve-ms-arch-notation
#
# xwin patches the SDK and CRT for case-sensitive filesystems; the --preserve-ms-arch-notation is
# necessary to make the /winsdkdir and /vctoolsdir options of clang work.

set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86_64)

set(CMAKE_TRY_COMPILE_CONFIGURATION Release)

set(WINDOWS_SDK_ROOT "/winsdk" CACHE PATH "Path to a Windows SDK and CRT installation")

find_program(CMAKE_C_COMPILER NAMES clang-cl REQUIRED)
find_program(CMAKE_CXX_COMPILER NAMES clang-cl REQUIRED)
find_program(CMAKE_AR NAMES llvm-lib REQUIRED)

add_compile_options(--target=x86_64-pc-windows-msvc -Wno-error -fuse-ld=lld /winsdkdir ${WINDOWS_SDK_ROOT}/sdk /vctoolsdir ${WINDOWS_SDK_ROOT}/crt)
add_link_options(/manifest:no -libpath:${WINDOWS_SDK_ROOT}/sdk/lib/um/x64 -libpath:${WINDOWS_SDK_ROOT}/sdk/lib/ucrt/x64 -libpath:${WINDOWS_SDK_ROOT}/crt/lib/x64)

0 comments on commit 30a8ae1

Please sign in to comment.