MantisBT - CMake
View Issue Details
0013292CMakeCMakepublic2012-06-11 16:242012-11-05 14:33
Ryan H. Kawicki 
 
normalminoralways
closedno change required 
Windows76.1.7601
CMake 2.8.7 
 
0013292: Windows : CMake Does Not Define _CONSOLE When Not Building A Win32 Target
Command add_executable does not define _CONSOLE when WIN32 is not specified.

Expected that final output would have _CONSOLE defined for preprocessor definitions if WIN32 is not specified and _WINDOWS when WIN32 is specified.
Create a very simple test with one single file.
project(test-console)

add_executable(test test.cpp)

# the generated project has _WINDOWS define when _CONSOLE should be defined.
No tags attached.
Issue History
2012-06-11 16:24Ryan H. KawickiNew Issue
2012-06-11 16:59Brad KingNote Added: 0029662
2012-06-11 19:40Ryan H. KawickiNote Added: 0029663
2012-06-12 08:13Brad KingStatusnew => resolved
2012-06-12 08:13Brad KingResolutionopen => no change required
2012-11-05 14:33David ColeNote Added: 0031449
2012-11-05 14:33David ColeStatusresolved => closed

Notes
(0029662)
Brad King   
2012-06-11 16:59   
Can you link to documentation that claims this macro is standard in any way?
(0029663)
Ryan H. Kawicki   
2012-06-11 19:40   
I could not find any documentation on _CONSOLE or _WINDOWS and it isn't even listed under their standard predefined macros.

I am only observing this from Visual Studio. When creating a console application, _CONSOLE is defined in the predefined symbols. When creating a GUI application, _WINDOWS is defined.

This became an issue when upgrading to CMake with a project that had a console application. Apparently, some 3rd party libraries use this flag. We were able to get around it by removing _WINDOWS and defining _CONSOLE ourselves.

I just wanted to bring this to the developers attention and to see if this truly needed to be addressed.
(0031449)
David Cole   
2012-11-05 14:33   
Closing resolved issues that have not been updated in more than 4 months.