[CMake] How to change (and account for) default Visual Studio compiler flags

Innokentiy Alaytsev alaitsev at gmail.com
Thu Jun 28 04:07:41 EDT 2018


Hello!


Jason Heeris wrote
> I'm not 100% that the latter is relevant, because I think the "_DEBUG"
> affects the build *type* (a Makefile generator thing) and not the build
> *configuration* (a VS thing).

AFAIK, the CMAKE_C[XX]_FLAGS_<CONFIG> work for all generators, so if you are
using MSVS they will apply to respective configurations (i.e. Release,
Debug, RelWithDebInfo). You can provide the desired build configuration with
the --config option to cmake in the command line:

cmake --build . --config Release [--target <target name]>

It may also worth looking at CMAKE_C[XX]_FLAGS_RELEASE as well as
CMAKE_EXE_LINKER_FLAGS[_<CONFIG>], CMAKE_MODULE_LINKER_FLAGS[_<CONFIG>] (if
you are building MODULE_LIBRARY targets),
CMAKE_SHARED_LINKER_FLAGS[_<CONFIG>] and
CMAKE_STATIC_LINKER_FLAGS[_<CONFIG>]. These flags are visible in cmake-gui
if you set (I don't know/remember the right word) the Advanced combo box
(setting Grouped will dramatically improve readability).

Hope this will be helpful in any way.

Best regards,
Innokentiy Alaytsev




--
Sent from: http://cmake.3232098.n2.nabble.com/


More information about the CMake mailing list