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

Hauke Heibel hauke.heibel at googlemail.com
Tue Mar 6 07:46:42 EST 2012


Hi Andreas,

as far as I know, your only chance to achieve this is by modifying your
source code by adding

#ifndef NDEBUG
#pragma comment(linker, "/SUBSYSTEM:CONSOLE")
#endif

Using add_executable(... win32 ...) is correct because the pragma statement
will override the behaviour in debug mode (in my example in all but release
builds)

I hope this helps.

Regards,
Hauke

On Tue, Mar 6, 2012 at 11:55 AM, Andreas Haferburg <ahaferburg at scopis.com>wrote:

> 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
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/**
> opensource/opensource.html<http://www.kitware.com/opensource/opensource.html>
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/**CMake_FAQ<http://www.cmake.org/Wiki/CMake_FAQ>
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/**listinfo/cmake<http://www.cmake.org/mailman/listinfo/cmake>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120306/412a7d77/attachment.htm>


More information about the CMake mailing list