I am trying to learn CMake with a simple project. This is my sample CMakeLists.txt
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
set(PROJECT_NAME "MyLib" CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
project(${PROJECT_NAME})
include(${CMAKE_SOURCE_DIR}/Sources.cmake)
set(SOURCE_FILES ${COMMON_CPP_FILES} ${COMMON_H_FILES})
include_directories(include)
add_compile_options("$<$<CONFIG:Debug>:/EHa /MTd /W3 /w14640>")
add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES})
I tried to create a Visual Studio project based on this file but I cannot figure out how to properly set the compile flags. When I open Visual Studio I can see the flags (/EHa) as part of "Additional Options" but I can still see the default (/EHsc) flags.
Why the default flags are still there and how can I make sure the compiler is really using the flags that I have specified?