I would like to use the new (and better) diagnostic information from visual studio 2017.
To have it enabled to all my project at once I want to declare this flag fro
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" [=[
Caret
]=])
set_target_properties(
${PROJECT_NAME}
PROPERTIES
VS_USER_PROPS "${PROJECT_NAME}.Cpp.user.props"
)
Reference