Don’t modify CMAKE_CXX_FLAGS in your project. Leave variables like those for the user to manipulate. If the project needs to add flags project-wide, it can use add_compile_options() from the top level CMakeLists.txt instead. If you need to leave out some of those options for a specific target, then that suggests those flags shouldn’t have been applied project-wide to begin with. That said, there may be scenarios where that is justified (and I have had to do this before myself). If you’ve set a common set of options at the top level, you could search for those specific options in the COMPILE_OPTIONS directory property in a particular target’s CMakeLists.txt and remove them from that property. This assumes you want to remove those options for all targets in that CMakeLists.txt file’s directory scope. That’s the tradeoff to using this approach. It’s also quite fragile, because you’re assuming contents of those directory properties. It gets much worse if you start mixing in generator expressions, etc. Consider very carefully if this is really what you want to do before you commit to this approach.
I should point out that the COMPILE_OPTIONS directory property is only used to initialise the COMPILE_OPTIONS property of targets created in that directory scope or below. Rather than modifying the directory property, you could just modify the target property instead if you only wanted to adjust the flags for that one target.
Avoid setting CMAKE_<LANG>_FLAGS, CMAKE_<LANG>_FLAGS_<CONFIG>, CMAKE_<TYPE>_LINKER_FLAGS or CMAKE_<TYPE>_LINKER_FLAGS_<CONFIG> variables in the project. These are for the user to manipulate. For those things, use either the directory or target property manipulation commands like add_compile_options(), add_link_options(), target_compile_options() or target_link_options().
The CMAKE_<LANG>_STANDARD flag is more contentious. Personally, I see that as something the project should set, but some people hold strong views that it should be under the user’s control. I understand the arguments for and against. I think the project can and should set it, but that can be done in a way that the user can still override it if they need to build everything with a higher language standard.
Regarding the use vcpkg and wanting to use your own toolchain file, vcpkg provides the VCPKG_CHAINLOAD_TOOLCHAIN_FILE variable for that. Or you can just include their toolchain file at the bottom of yours. Both methods are supported by vcpkg.