[CMake] VS2010: /subsystem:console only in debug build

Andreas Haferburg ahaferburg at scopis.com
Tue Mar 6 05:55:41 EST 2012


Hi,

I'd like to suppress the console, but only in release builds. What's the official way to do that?

add_executable(... win32 ...) doesn't work, because it switches off the console in debug builds.

When I set LINKER_FLAGS_RELEASE to "/subsystem:windows", I can suppress the console in the release 
builds. However, the Properties window in VS2010 still displays "Console (/SUBSYSTEM:CONSOLE)" in 
the linker settings, and has two entries in the command line: "/SUBSYSTEM:CONSOLE" and 
"/subsystem:windows". Only the latter seems to count.

When I set LINKER_FLAGS_RELEASE to "/SUBSYSTEM:WINDOWS", CMake just drops it, and only retains 
"/SUBSYSTEM:CONSOLE" in the linker flags.

It seems to me that CMake recognizes "/SUBSYSTEM:WINDOWS", but chooses to ignore it for some reason. 
The fact that "/subsystem:windows" works the way it does seems like a bug. So what's the proper way 
to achieve what I want?

I'm using CMake 2.8.7 on Win 7 with VS2010.

Cheers
Andreas


More information about the CMake mailing list