I want to use CMake to generate .vcxproj files. Then I open specific project/solution and work in VS as usual. How do I customize default configurations, generated by VS generator? In particular, how do I specify in my cmake files (whatever it should be) that I need release runtime for "Debug" configuration? (i.e. /MD instead of /MDd).
As far as I understand, such an option is VS-specific (VS/MSBuild flag) and thus is not manupulated my CMake naturally.
This will work:
Then all of the targets you build in all configurations will use
-MD. See the documentation here: https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.htmlThe default value is
MultiThreaded$<$<CONFIG:Debug>:Debug>DLLwhich uses-MDdfor theDebugconfiguration and-MDfor all others. This uses generator expressions, which are out of scope for this question.An alternative: you can lean in to CMake's defaults and use the
RelWithDebInfobuild config. If you need to override the optimization flags, you can always setCMAKE_CXX_FLAGS_RELWITHDEBINFO.