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