[Cmake] WinMain
Nick Arini
nick.arini at amersham.com
Thu Jun 10 04:58:33 EDT 2004
Thanks Filipe,
that is much neater.
Nick
Filipe Sousa <filipe.gr.sousa at alunos.ipb.pt>
Sent by: cmake-bounces at www.cmake.org
08/06/2004 18:32
To: cmake at www.cmake.org
cc:
Subject: Re: [Cmake] WinMain
Hi Nick!
On Tuesday 08 June 2004 15:37, Nick Arini wrote:
> Filipe, Julien, William and Andy,
>
> Thanks for all your suggestions. I finally got a combination that works
> for me. I am posting it here (and not to Qt-interest) because all the
> additions are to the CMakeLists.txt file and did not require any changes
> to the source code.
>
> Filipe was right that I didnt need to write a WinMain and use nasty
> #ifdefs. My main program is still calling main() and is unchanged.
>
> When using Qt on Windows it seems you need to link to the qtmain.lib
> library. To be safe I also included the lines that Julien suggested. The
> important bits of my CMakeLists.txt file now look like below.
>
> This still works just fine for Linux and GCC ;->.
>
> Best regards,
>
> Nick
>
>
> <begin code>
>
>
> #
> # Find QT (Obviously)
> #
> INCLUDE (${CMAKE_ROOT}/Modules/FindQt.cmake)
It's easier to do FIND_PACKAGE(Qt) instead of INCLUDE
>
> INCLUDE_DIRECTORIES(
> ${QT_INCLUDE_DIR}
> ${QT_INCLUDE_PATH}
> )
>
> LINK_LIBRARIES (
> ${QT_QT_LIBRARY}
> )
Here is the problem, you shouldn't use QT_QT_LIBRARY, you have to use
QT_LIBRARIES both on windows and linux that has qt.lib and qtmain.lib.
> # Only include the qtmain lib if we are on the windows platform
> IF(WIN32)
> LINK_LIBRARIES(
> ${QT_QTMAIN_LIBRARY}
> )
> ENDIF(WIN32)
>
> IF(WIN32)
> ADD_DEFINITIONS(-DQT_DLL)
> ENDIF(WIN32)
>
>
> SET(VIEWER_SRCS
> MainWindow.cpp
> MainWindow.h
> main.cpp
> )
>
>
> SET(VIEWER_MOC_SRCS
> MainWindow.h
> )
>
> IF(QT_WRAP_CPP)
> QT_WRAP_CPP(viewer VIEWER_SRCS VIEWER_MOC_SRCS)
> ENDIF(QT_WRAP_CPP)
>
>
> # Julien's suggested lines
> IF(WIN32)
> SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}
/subsystem:windows")
>
> ENDIF(WIN32)
I never had to use "/subsystem:windows" I thinks this is added with WIN32
on
ADD_EXECUTABLE
>
> ADD_EXECUTABLE(viewer WIN32 VIEWER_SRCS)
>
>
> <end code>
>
>
>
>
>
>
> Filipe Sousa <filipe.gr.sousa at alunos.ipb.pt>
> Sent by: cmake-bounces at www.cmake.org
> 07/06/2004 19:16
>
>
> To: cmake at www.cmake.org
> cc:
> Subject: Re: [Cmake] WinMain
>
>
> There is no need to write WinMain. The library qtmain.lib has the
WinMain
> that
> calls the user's main() function.
>
> On Monday 07 June 2004 16:07, William A. Hoffman wrote:
> > This is really a QT question. You should look at some QT examples
and
> > figure out how QT deals with WinMain. If it has a WinMain, then use
> > the WIN32 option in ADD_EXECUTABLE:
> > ADD_EXECUTABLE(viewer WIN32 VIEWER_SRCS)
> > If it uses main, then leave out the WIN32 option.
> >
> > -Bill
>
> -- Filipe Sousa
>
> _______________________________________________
> Cmake mailing list
> Cmake at www.cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
_______________________________________________
Cmake mailing list
Cmake at www.cmake.org
http://www.cmake.org/mailman/listinfo/cmake
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20040610/6f99929d/attachment.html
More information about the Cmake
mailing list