-
Notifications
You must be signed in to change notification settings - Fork 56
/
toolchain_ninja_clang-cl.cmake
49 lines (43 loc) · 1.53 KB
/
toolchain_ninja_clang-cl.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
include_guard(GLOBAL)
find_program(VS_CL_COMPILER NAMES cl)
if(NOT VS_CL_COMPILER)
message(FATAL_ERROR "Cannot find cl from visual studio! Forgot to run vcvars?")
endif()
message(STATUS "Loading clang-cl using ninja toolchain!")
if (DEFINED ENV{ProgramW6432})
file(TO_CMAKE_PATH "$ENV{ProgramW6432}" PROG_ROOT)
else()
file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" PROG_ROOT)
endif()
find_program(CLANG_CL clang-cl HINTS "${PROG_ROOT}/LLVM/bin")
if(NOT CLANG_CL AND NOT CMAKE_CXX_COMPILER MATCHES "clang-cl")
message(FATAL_ERROR "Unable to find clang-cl with hint '${PROG_ROOT}/LLVM/bin'")
else()
get_filename_component(LLVM_BIN_DIR "${CLANG_CL}" DIRECTORY CACHE)
message(STATUS "Found clang-cl in ${LLVM_BIN_DIR}")
list(APPEND CMAKE_PROGRAM_PATH "${LLVM_BIN_DIR}")
endif()
if(NOT DEFINED CMAKE_C_COMPILER)
set(CMAKE_C_COMPILER "${LLVM_BIN_DIR}/clang-cl.exe")
endif()
if(NOT DEFINED CMAKE_CXX_COMPILER)
set(CMAKE_CXX_COMPILER "${LLVM_BIN_DIR}/clang-cl.exe")
endif()
if(NOT DEFINED CMAKE_LINKER)
set(CMAKE_LINKER "${LLVM_BIN_DIR}/lld-link.exe")
endif()
if(NOT DEFINED CMAKE_AR)
set(CMAKE_AR "${LLVM_BIN_DIR}/llvm-lib.exe")
endif()
if(NOT DEFINED CMAKE_RANLIB)
set(CMAKE_RANLIB)
endif()
if(NOT DEFINED CMAKE_RC_COMPILER)
set(CMAKE_RC_COMPILER "${LLVM_BIN_DIR}/llvm-rc.exe")
endif()
if(NOT DEFINED CMAKE_NM)
set(CMAKE_NM "${LLVM_BIN_DIR}/llvm-nm.exe")
endif()
set(CMAKE_MT "mt.exe")
include("${CMAKE_CURRENT_LIST_DIR}/toolchain_msvc_general.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/toolchain_vs_llvm.cmake")