<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 &lt;filipe.gr.sousa@alunos.ipb.pt&gt;</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">&nbsp; &nbsp; &nbsp; &nbsp; </font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; To: &nbsp; &nbsp; &nbsp; &nbsp;cmake@www.cmake.org</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; cc: &nbsp; &nbsp; &nbsp; &nbsp;</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; Subject: &nbsp; &nbsp; &nbsp; &nbsp;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>
&gt; Filipe, Julien, William and Andy,<br>
&gt;<br>
&gt; Thanks for all your suggestions. I finally got a combination that works<br>
&gt; for me. I am posting it here (and not to Qt-interest) because all the<br>
&gt; additions are to the CMakeLists.txt file and did not require any changes<br>
&gt; to the source code.<br>
&gt;<br>
&gt; Filipe was right that I didnt need to write a WinMain and use nasty<br>
&gt; #ifdefs. My main program is still calling main() and is unchanged.<br>
&gt;<br>
&gt; When using Qt on Windows it seems you need to link to the qtmain.lib<br>
&gt; library. To be safe I also included the lines that Julien suggested. The<br>
&gt; important bits of my CMakeLists.txt file now look like below.<br>
&gt;<br>
&gt; This still works just fine for Linux and GCC ;-&gt;.<br>
&gt;<br>
&gt; Best regards,<br>
&gt;<br>
&gt; Nick<br>
&gt;<br>
&gt;<br>
&gt; &lt;begin code&gt;<br>
&gt;<br>
&gt;<br>
&gt; #<br>
&gt; # Find QT (Obviously)<br>
&gt; #<br>
&gt; 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>&gt;<br>
&gt; INCLUDE_DIRECTORIES(<br>
&gt; ${QT_INCLUDE_DIR}<br>
&gt; ${QT_INCLUDE_PATH}<br>
&gt; )<br>
&gt;<br>
&gt; LINK_LIBRARIES (<br>
&gt; ${QT_QT_LIBRARY}<br>
&gt; )<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>&gt; # Only include the qtmain lib if we are on the windows platform<br>
&gt; IF(WIN32)<br>
&gt; LINK_LIBRARIES(<br>
&gt; ${QT_QTMAIN_LIBRARY}<br>
&gt; )<br>
&gt; ENDIF(WIN32)<br>
&gt;<br>
&gt; IF(WIN32)<br>
&gt; ADD_DEFINITIONS(-DQT_DLL)<br>
&gt; ENDIF(WIN32)<br>
&gt;<br>
&gt;<br>
&gt; SET(VIEWER_SRCS<br>
&gt; MainWindow.cpp<br>
&gt; MainWindow.h<br>
&gt; main.cpp<br>
&gt; )<br>
&gt;<br>
&gt;<br>
&gt; SET(VIEWER_MOC_SRCS<br>
&gt; MainWindow.h<br>
&gt; )<br>
&gt;<br>
&gt; IF(QT_WRAP_CPP)<br>
&gt; &nbsp; QT_WRAP_CPP(viewer VIEWER_SRCS VIEWER_MOC_SRCS)<br>
&gt; ENDIF(QT_WRAP_CPP)<br>
&gt;<br>
&gt;<br>
&gt; # Julien's suggested lines<br>
&gt; IF(WIN32)<br>
&gt; SET(CMAKE_EXE_LINKER_FLAGS &quot;${CMAKE_EXE_LINKER_FLAGS} /subsystem:windows&quot;)<br>
&gt;<br>
&gt; ENDIF(WIN32)<br>
I never had to use &quot;/subsystem:windows&quot; I thinks this is added with WIN32 on<br>
ADD_EXECUTABLE<br>
&gt;<br>
&gt; ADD_EXECUTABLE(viewer WIN32 VIEWER_SRCS)<br>
&gt;<br>
&gt;<br>
&gt; &lt;end code&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Filipe Sousa &lt;filipe.gr.sousa@alunos.ipb.pt&gt;<br>
&gt; Sent by: cmake-bounces@www.cmake.org<br>
&gt; 07/06/2004 19:16<br>
&gt;<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; To: &nbsp; &nbsp; cmake@www.cmake.org<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; cc:<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; Subject: &nbsp; &nbsp; &nbsp; &nbsp;Re: [Cmake] WinMain<br>
&gt;<br>
&gt;<br>
&gt; There is no need to write WinMain. The library qtmain.lib has the WinMain<br>
&gt; that<br>
&gt; calls the user's main() function.<br>
&gt;<br>
&gt; On Monday 07 June 2004 16:07, William A. Hoffman wrote:<br>
&gt; &gt; This is really a QT question. &nbsp; You should look at some QT examples and<br>
&gt; &gt; figure out how QT deals with WinMain. &nbsp; If it has a WinMain, then use<br>
&gt; &gt; the WIN32 option in ADD_EXECUTABLE:<br>
&gt; &gt; ADD_EXECUTABLE(viewer WIN32 VIEWER_SRCS)<br>
&gt; &gt; If it uses main, then leave out the WIN32 option.<br>
&gt; &gt;<br>
&gt; &gt; -Bill<br>
&gt;<br>
&gt; -- Filipe Sousa<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Cmake mailing list<br>
&gt; Cmake@www.cmake.org<br>
&gt; 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>