Thought this was handy enough to add a wiki entry:

http://www.cmake.org/Wiki/VSConfigSpecificSettings

Mike
On Oct 7, 2008, at 12:49 AM, Jason Eubank wrote:

Thanks Stefan, this worked well.

My exact usage using your recommendations was as follows:

if(WIN32)
set_target_properties(WindowApplicationExample PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE") set_target_properties(WindowApplicationExample PROPERTIES RELWITHDEBINFO "/SUBSYSTEM:CONSOLE") set_target_properties(WindowApplicationExample PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS") set_target_properties(WindowApplicationExample PROPERTIES MINSIZEREL "/SUBSYSTEM:WINDOWS")
endif(WIN32)

This allows per-config setting of weather or not to use a console in visual studio, although it does not change the actual Subsytem setting in the Linker section, it does add it to the Additional Options setting in the Command Line section, which is then appended to the list of these settings and produces the same result.

Thanks for the help!

Jason

On Mon, Oct 6, 2008 at 10:49 AM, Stefan Buschmann <[EMAIL PROTECTED]> wrote:
Jason Eubank schrieb:

Hello,

I am wondering if it is possible to set the target property 'WIN32_EXECUTABLE' on a per-config basis (i.e. you can set link- flags on a per-config basis using LINK_FLAGS_<Config>). From reading the documentation this does not seem possible and if you set this property then all configurations (in Visual Studio) use the same subsystem setting. I don't know whether or not CMake is able to set a property on a per- configuration basis. I doubt this is possible (yet), but could be that I'm wrong here.

But you could simply set the appropriate flags for a console/win32 application yourself, without using this flag at all. The only differences I could find between a win32 application and a console application are - Linker flag: "/SUBSYSTEM:CONSOLE" for console apps and "/ SUBSYSTEM:WINDOWS" for win32 apps
- Preprocessor definition: '_CONSOLE' for console apps

Setting these using LINK_FLAGS_<Config> and COMPILE_DEFINITIONS_<Config> should do exactly what you want. The only problem I see that could possibly arise is that you can't depend on the WIN32_EXECUTABLE flag in your CMake file(s) anymore, to test for it or use it in any other way later.

Another solution that comes to my mind is to always create a win32 application, and then open a console window later by using the win32 function 'AllocConsole' in your code. I never really needed this, but I know those functions are there to create or attach a console window to a win32 application. Have a look at the documentation for this function.

Stefan

_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to