From 5ebfc927306fd7ce551fa22244be801cf2b9fdd9 Mon Sep 17 00:00:00 2001 From: zjyhjqs <141055431+zjyhjqs@users.noreply.github.com> Date: Mon, 22 Jul 2024 18:37:28 +0800 Subject: [PATCH] fix: set `/Zc:__cplusplus` and `/MP` to MSVC only (#3139) 1. macro `__cplusplus` is enabled by clang-cl 2. `/MP` is not supported by clang-cl (warning `-Wunused-command-line-argument` will be generated) --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a554ef4..ad903e64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ elseif(NOT CMAKE_CXX_STANDARD) endif() # make sure __cplusplus is defined when using msvc and enable parallel build -if(MSVC) +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") string(APPEND CMAKE_CXX_FLAGS " /Zc:__cplusplus /MP") endif() @@ -161,7 +161,7 @@ if(SPDLOG_BUILD_SHARED OR BUILD_SHARED_LIBS) endif() add_library(spdlog SHARED ${SPDLOG_SRCS} ${SPDLOG_ALL_HEADERS}) target_compile_definitions(spdlog PUBLIC SPDLOG_SHARED_LIB) - if(MSVC) + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") target_compile_options(spdlog PUBLIC $<$,$>>:/wd4251 /wd4275>) endif()