From 2f0ba177802ba3a1b35150c553b7c801c05c41c9 Mon Sep 17 00:00:00 2001 From: germanaizek Date: Fri, 10 Jun 2022 14:58:10 +0300 Subject: [PATCH] Added support building on MSVC toolkit ClangCL More info in answer: https://stackoverflow.com/questions/49480535/how-to-differentiate-between-clang-and-clang-cl --- CMakeLists.txt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e2f8c5c..3f72db2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,9 +9,17 @@ PROJECT(${NAME}) ENABLE_TESTING() # Update if necessary -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3") +IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + IF("${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /O2") + else() + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3") + endif() +endif() # BUILD AND INCLUDE GOOGLETEST ADD_SUBDIRECTORY(libs/googletest/)