Skip to content

Commit 8758a6f

Browse files
committed
Add LLVM toolchain for Windows
1 parent a7ebd46 commit 8758a6f

File tree

2 files changed

+78
-3
lines changed

2 files changed

+78
-3
lines changed

CMakePresets.json

+18-3
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,21 @@
3030
"cacheVariables": {
3131
"CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/${presetName}.cmake",
3232
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/build-scripts/MSVC.cmake",
33+
{
34+
"name": "windows-tiles-sounds-x64-llvm",
35+
"binaryDir": "${sourceDir}/out/build/${presetName}",
36+
"displayName": "Windows Tiles Sounds x64 LLVM",
37+
"description": "Target Windows (64-bit) with the LLVM development environment.",
38+
"inherits": "windows-tiles-sounds-x64",
39+
"environment": {
40+
"VCPKG_ROOT": "C:/vcpkg"
41+
},
42+
"cacheVariables": {
43+
"LLVM_ROOT": "C:/Program Files/LLVM",
44+
"CMAKE_PROJECT_INCLUDE_BEFORE": "${sourceDir}/build-scripts/windows-tiles-sounds-x64-msvc.cmake",
45+
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/build-scripts/LLVM.cmake",
3346
"VCPKG_TARGET_TRIPLET": "x64-windows-static",
34-
"DYNAMIC_LINKING": "False",
35-
"CURSES": "False", "LOCALIZE": "True", "TILES": "True", "SOUND": "True", "TESTS": "True",
36-
"CMAKE_INSTALL_MESSAGE": "NEVER"
47+
"VCPKG_APPLOCAL_DEPS": "False"
3748
}
3849
},
3950
{
@@ -80,6 +91,10 @@
8091
{
8192
"name": "windows-tiles-sounds-x64-msvc",
8293
"configurePreset": "windows-tiles-sounds-x64-msvc"
94+
},
95+
{
96+
"name": "windows-tiles-sounds-x64-llvm",
97+
"configurePreset": "windows-tiles-sounds-x64-llvm"
8398
}
8499
],
85100
"testPresets": [

build-scripts/LLVM.cmake

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#[=======================================================================[
2+
3+
LLVM
4+
----
5+
6+
Toolchain file for LLVM CLANG on Windows
7+
8+
Used by CMakePresets.json -> "toolchainFile".
9+
10+
Using clang-cl.exe so we can copy MSVC.cmake flags over here.
11+
12+
Refer to MSVC.cmake documentation
13+
14+
#]=======================================================================]
15+
16+
set(CMAKE_C_COMPILER "${LLVM_ROOT}/bin/clang-cl.exe")
17+
set(CMAKE_CXX_COMPILER ${CMAKE_C_COMPILER})
18+
set(CMAKE_RC_COMPILER "${LLVM_ROOT}/bin/llvm-rc.exe")
19+
set(CMAKE_MT "${LLVM_ROOT}/bin/llvm-mt.exe")
20+
set(CMAKE_OBJDUMP "${LLVM_ROOT}/bin/llvm-objdump.exe")
21+
22+
set(CMAKE_CXX_FLAGS_INIT "\
23+
/utf-8 /bigobj /permissive- /sdl- /FC /Gd /GS- /Gy /GF \
24+
/wd4068 /wd4146 /wd4661 /wd4819 /wd6237 /wd6319 /wd26444 /wd26451 /wd26495 /WX- /W1 \
25+
/Zc:forScope /Zc:inline /Zc:wchar_t"
26+
)
27+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT
28+
"/Oi"
29+
)
30+
31+
add_compile_definitions(
32+
_SCL_SECURE_NO_WARNINGS
33+
_CRT_SECURE_NO_WARNINGS
34+
WIN32_LEAN_AND_MEAN
35+
LOCALIZE
36+
USE_VCPKG
37+
)
38+
39+
add_link_options(
40+
/OPT:REF
41+
/OPT:ICF
42+
/LTCG:OFF
43+
/INCREMENTAL:NO
44+
/DYNAMICBASE
45+
/NXCOMPAT
46+
"$<$<CONFIG:Debug>:/NODEFAULTLIB:LIBCMT>"
47+
"$<$<CONFIG:RelWithDebInfo>:/NODEFAULTLIB:LIBCMTD>"
48+
)
49+
50+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
51+
52+
# Where is vcpkg.json ?
53+
set(VCPKG_MANIFEST_DIR ${CMAKE_SOURCE_DIR}/msvc-full-features)
54+
55+
set(VCPKG_ROOT "" CACHE PATH "Path to VCPKG installation")
56+
if (NOT $ENV{VCPKG_ROOT} STREQUAL "")
57+
include($ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake)
58+
elseif(NOT $CACHE{VCPKG_ROOT} STREQUAL "")
59+
include($CACHE{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake)
60+
endif()

0 commit comments

Comments
 (0)