add /WX mscv compiler option for only mscv compiler

clang on windows support both gcc and mscv style options. Clang.exe on windows
defaults to gcc style, which will result in /WX unknown compiler command.
This will set /WX if and only if the compiler is MSVC and greater than version 1900
This commit is contained in:
Trond H Emaus 2020-03-27 19:59:22 +01:00
parent f1b4f15dbb
commit 2a7fc9e30e

View File

@ -28,13 +28,15 @@ endfunction()
# Turn on warnings on the given target
function(spdlog_enable_warnings target_name)
set(MSVC_OPTIONS "/W3")
if(MSVC_VERSION GREATER 1900) #Allow non fatal security wanrnings for msvc 2015
set(MSVC_OPTIONS "${MSVC_OPTIONS} /WX")
endif()
target_compile_options(${target_name} PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
-Wall -Wextra -Wconversion -pedantic -Wfatal-errors>
$<$<CXX_COMPILER_ID:MSVC>:/W3>)
if(MSVC_VERSION GREATER 1900) #Allow non fatal security wanrnings for msvc 2015
target_compile_options(${target_name} PRIVATE /WX)
endif()
$<$<CXX_COMPILER_ID:MSVC>:${MSVC_OPTIONS}>)
endfunction()