You just have to know that VS compiler options that CMake does not yet officially support will end up under:
Properties
/C/C++
/Command Line
/Additional Options
That's why you get
cl : Command line error D8016: '/diagnostics:classic' and '/diagnostics:caret'
command-line options are incompatible
But you can give cl
options globally with the new VS_USER_PROPS
target property (version >= 3.8).
Here is a working example:
CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(VSAnyFlag)
file(WRITE main.cpp "int main() { return 0; }")
add_executable(${PROJECT_NAME} main.cpp)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.Cpp.user.props" [=[
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemDefinitionGroup>
<ClCompile>
<DiagnosticsFormat>Caret</DiagnosticsFormat>
</ClCompile>
</ItemDefinitionGroup>
</Project>
]=])
set_target_properties(
${PROJECT_NAME}
PROPERTIES
VS_USER_PROPS "${PROJECT_NAME}.Cpp.user.props"
)
Reference