[CMake] Suppressing Windows console in Qt app
Mike Jackson
imikejackson at gmail.com
Mon Mar 24 10:55:00 EDT 2008
My guess is that in your
ADD_EXECUTABLE statement, you are missing the WIN32 Argument:
cmake version 2.4-patch 8 ADD_EXECUTABLE Add an executable to
the project using the specified source files.
ADD_EXECUTABLE(exename [WIN32] [MACOSX_BUNDLE]
[EXCLUDE_FROM_ALL] source1 source2 ... sourceN)
This command adds an executable target to the current
directory. The executable will be built from the list of
source files specified.
After specifying the executable name, WIN32 and/or
MACOSX_BUNDLE can
be specified. WIN32 indicates that the executable (when compiled on
windows) is a windows app (using WinMain) not a console app (using
main). The variable CMAKE_MFC_FLAG be used if the windows app uses
MFC. This variable can be set to the following values:
0: Use Standard Windows Libraries
1: Use MFC in a Static Library
2: Use MFC in a Shared DLL
MACOSX_BUNDLE indicates that when build on Mac OSX,
executable should
be in the bundle form. The MACOSX_BUNDLE also allows several
variables to be specified:
MACOSX_BUNDLE_INFO_STRING
MACOSX_BUNDLE_ICON_FILE
MACOSX_BUNDLE_GUI_IDENTIFIER
MACOSX_BUNDLE_LONG_VERSION_STRING
MACOSX_BUNDLE_BUNDLE_NAME
MACOSX_BUNDLE_SHORT_VERSION_STRING
MACOSX_BUNDLE_BUNDLE_VERSION
MACOSX_BUNDLE_COPYRIGHT
If EXCLUDE_FROM_ALL is given the target will not be built by
default.
It will be built only if the user explicitly builds the target or
another target that requires the target depends on it.
If you are going to be building this as a cross platform application,
then the following is useful:
# Set some Win32 Specific Settings
IF(WIN32)
SET(GUI_TYPE WIN32)
ENDIF(WIN32)
# Set some Apple MacOS Specific settings
IF (APPLE)
SET(GUI_TYPE MACOSX_BUNDLE)
ENDIF (APPLE)
ADD_EXECUTABLE( MyApplication ${GUI_TYPE} ${PROJECT_SRCS} )
Mike
--
Mike Jackson Senior Research Engineer
Innovative Management & Technology Services
On Mar 24, 2008, at 9:45 AM, Matthew Smith wrote:
> Hi everyone,
>
> When I build my Qt 4 app (QTM) using CMake on Windows Vista and
> then run it from a prompt, the prompt does not come back as it does
> with normal Windows GUI apps; it behaves as if it's running a
> console-based application. If you press Ctrl+C, it kills the
> program. If you run it from Explorer, it opens a prompt window but
> doesn't give you a prompt, and similarly you can kill QTM by
> closing the window. When I build using qmake, I do not have this
> problem; it just gives me the prompt back. Does anyone know how to
> fix this?
>
> Regards,
>
> Matt Smith
>
> --
>
> http://qtm.blogistan.co.uk/
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
More information about the CMake
mailing list