From 2a7fc9e30edc03488c689811d1ef239d3ea567e5 Mon Sep 17 00:00:00 2001 From: Trond H Emaus Date: Fri, 27 Mar 2020 19:59:22 +0100 Subject: [PATCH] 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 --- cmake/utils.cmake | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 997bc2d1..6b6bfa5f 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -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 $<$,$,$>: -Wall -Wextra -Wconversion -pedantic -Wfatal-errors> - $<$:/W3>) - if(MSVC_VERSION GREATER 1900) #Allow non fatal security wanrnings for msvc 2015 - target_compile_options(${target_name} PRIVATE /WX) - endif() + $<$:${MSVC_OPTIONS}>) + endfunction()