CMake: fix clang-cl builds on Windows
Broke this in https://dawn-review.googlesource.com/c/tint/+/45621
We don't want /MP enabled for clang-cl builds as this results in an
unused parameter /MP warning.
Also opportunistically clean up CMake script a little.
Bug: tint:665
Change-Id: I4047b75332c1aa64b32b695dfe050c255009e922
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45820
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 373724c..edfb182 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -84,11 +84,6 @@
endif()
endif()
-# Enable msbuild multiprocessor builds
-if (MSVC)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
-endif()
-
if (${TINT_CHECK_CHROMIUM_STYLE})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xclang -add-plugin -Xclang find-bad-constructs")
endif()
@@ -97,13 +92,22 @@
include_directories("${PROJECT_SOURCE_DIR}/third_party/spirv-tools/include")
endif()
-if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR
- ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") OR
- (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") AND
- (NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")))
+if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"))
+ set(COMPILER_IS_CLANG_CL TRUE)
+endif()
+
+if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR
+ (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") OR
+ ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND
+ (NOT COMPILER_IS_CLANG_CL)))
set(COMPILER_IS_LIKE_GNU TRUE)
endif()
+# Enable msbuild multiprocessor builds
+if (MSVC AND NOT COMPILER_IS_CLANG_CL)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
+endif()
+
if(${TINT_BUILD_DOCS})
find_package(Doxygen)
if(DOXYGEN_FOUND)