https://git.reactos.org/?p=reactos.git;a=commitdiff;h=62d1a2c884da401adb381…
commit 62d1a2c884da401adb381798d712490930aeff83
Author: Victor Perevertkin <victor.perevertkin(a)reactos.org>
AuthorDate: Mon Sep 13 23:39:03 2021 +0300
Commit: Victor Perevertkin <victor.perevertkin(a)reactos.org>
CommitDate: Tue Sep 14 17:58:23 2021 +0300
[CMAKE] Fixes for clang-cl build
- User lib.exe instead of llvm-lib due to incompatibility
- Avoid wrapping resource compiler with cmcldeps
- Fix several conditional flags
---
ntoskrnl/CMakeLists.txt | 2 +-
sdk/cmake/config.cmake | 2 +-
toolchain-msvc.cmake | 9 +++++++++
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/ntoskrnl/CMakeLists.txt b/ntoskrnl/CMakeLists.txt
index b0cf73eec86..9109a7bc3c7 100644
--- a/ntoskrnl/CMakeLists.txt
+++ b/ntoskrnl/CMakeLists.txt
@@ -8,7 +8,7 @@ endif()
include(ntos.cmake)
-if (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
+if(NOT MSVC)
# Make sure we don't duplicate some symbols
add_compile_options(-fno-common)
endif()
diff --git a/sdk/cmake/config.cmake b/sdk/cmake/config.cmake
index 63e5d71f0dd..75a63261eb6 100644
--- a/sdk/cmake/config.cmake
+++ b/sdk/cmake/config.cmake
@@ -79,7 +79,7 @@ else()
message("WARNING: the compiler has not been recognized")
endif()
-if(MSVC AND (NOT USE_CLANG_CL))
+if(MSVC)
set(KDBG FALSE CACHE BOOL
"Whether to compile in the integrated kernel debugger.")
if(CMAKE_BUILD_TYPE STREQUAL "Release")
diff --git a/toolchain-msvc.cmake b/toolchain-msvc.cmake
index 97921b216f7..12e499fd3ad 100644
--- a/toolchain-msvc.cmake
+++ b/toolchain-msvc.cmake
@@ -24,6 +24,10 @@ if(USE_CLANG_CL)
set(CMAKE_CXX_COMPILER clang-cl)
# Clang now defaults to lld-link which we're not compatible with yet
set(CMAKE_LINKER link)
+ # llvm-lib with link.exe can't generate proper delayed imports
+ set(CMAKE_AR lib)
+ set(CMAKE_C_COMPILER_AR lib)
+ set(CMAKE_CXX_COMPILER_AR lib)
# Explicitly set target so CMake doesn't get confused
if (ARCH STREQUAL "amd64")
set(CMAKE_C_COMPILER_TARGET "x86_64-pc-windows-msvc")
@@ -38,6 +42,11 @@ if(USE_CLANG_CL)
set(CMAKE_C_COMPILER_TARGET "i686-pc-windows-msvc")
set(CMAKE_CXX_COMPILER_TARGET "i686-pc-windows-msvc")
endif()
+
+ # Avoid wrapping RC compiler with cmcldeps utility for clang-cl.
+ # Otherwise it breaks cross-compilation (32bit ReactOS cannot be compiled by 64bit
LLVM),
+ # target architecture is not passed properly
+ set(CMAKE_NINJA_CMCLDEPS_RC OFF)
else()
set(CMAKE_C_COMPILER cl)
set(CMAKE_CXX_COMPILER cl)