VS: handling of '/analyze' flags
When I tried using target_compile_options
to enable code analysis on build for MSVC, I wrote a function as following:
function(enable_msvc_static_analysis_for_target TARGET)
target_compile_options(${TARGET}
PRIVATE
/analyze
/analyze:WX-
)
endfunction(enable_msvc_static_analysis_for_target)
/analyze
here to turn on code analysis functionality and /analyze:WX-
to make analysis warnings not being treated as errors because I had a /WX
(which indicates the compiler treats all warnings as errors) flag.
However, when I generated the Visual Studio solution, I found the flag /analyze
was missing, and only /analyze:WX-
was given as the commandline args.
and, of course, the code analysis was not enabled.
I tried using Visual Studio 2017 and Visual Studio 2019 as generator, respectively, and both have the issue.
- Platform: Windows 10 1809
- CMake Version: 3.14.3
References
Edited by Brad King