<br><font size=2 face="sans-serif">Filipe, Julien, William and Andy,</font>
<br>
<br><font size=2 face="sans-serif">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.</font>
<br>
<br><font size=2 face="sans-serif">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.</font>
<br>
<br><font size=2 face="sans-serif">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.</font>
<br>
<br><font size=2 face="sans-serif">This still works just fine for Linux and GCC ;-&gt;.</font>
<br>
<br><font size=2 face="sans-serif">Best regards,</font>
<br>
<br><font size=2 face="sans-serif">Nick</font>
<br>
<br>
<br><font size=2 face="sans-serif">&lt;begin code&gt;</font>
<br>
<br>
<br><font size=2 face="sans-serif"># </font>
<br><font size=2 face="sans-serif"># Find QT (Obviously)</font>
<br><font size=2 face="sans-serif">#</font>
<br><font size=2 face="sans-serif">INCLUDE (${CMAKE_ROOT}/Modules/FindQt.cmake)</font>
<br>
<br><font size=2 face="sans-serif">INCLUDE_DIRECTORIES(</font>
<br><font size=2 face="sans-serif">${QT_INCLUDE_DIR}</font>
<br><font size=2 face="sans-serif">${QT_INCLUDE_PATH}</font>
<br><font size=2 face="sans-serif">)</font>
<br>
<br><font size=2 face="sans-serif">LINK_LIBRARIES (</font>
<br><font size=2 face="sans-serif">${QT_QT_LIBRARY}</font>
<br><font size=2 face="sans-serif">)</font>
<br>
<br><font size=2 face="sans-serif"># Only include the qtmain lib if we are on the windows platform</font>
<br><font size=2 face="sans-serif">IF(WIN32)</font>
<br><font size=2 face="sans-serif">LINK_LIBRARIES(</font>
<br><font size=2 face="sans-serif">${QT_QTMAIN_LIBRARY}</font>
<br><font size=2 face="sans-serif">)</font>
<br><font size=2 face="sans-serif">ENDIF(WIN32)</font>
<br>
<br><font size=2 face="sans-serif">IF(WIN32)</font>
<br><font size=2 face="sans-serif">ADD_DEFINITIONS(-DQT_DLL) </font>
<br><font size=2 face="sans-serif">ENDIF(WIN32)</font>
<br>
<br>
<br><font size=2 face="sans-serif">SET(VIEWER_SRCS </font>
<br><font size=2 face="sans-serif">MainWindow.cpp</font>
<br><font size=2 face="sans-serif">MainWindow.h </font>
<br><font size=2 face="sans-serif">main.cpp &nbsp;</font>
<br><font size=2 face="sans-serif">)</font>
<br>
<br>
<br><font size=2 face="sans-serif">SET(VIEWER_MOC_SRCS </font>
<br><font size=2 face="sans-serif">MainWindow.h</font>
<br><font size=2 face="sans-serif">)</font>
<br>
<br><font size=2 face="sans-serif">IF(QT_WRAP_CPP)</font>
<br><font size=2 face="sans-serif">&nbsp; QT_WRAP_CPP(viewer VIEWER_SRCS VIEWER_MOC_SRCS)</font>
<br><font size=2 face="sans-serif">ENDIF(QT_WRAP_CPP)</font>
<br>
<br>
<br><font size=2 face="sans-serif"># Julien's suggested lines</font>
<br><font size=2 face="sans-serif">IF(WIN32)</font>
<br><font size=2 face="sans-serif">SET(CMAKE_EXE_LINKER_FLAGS &quot;${CMAKE_EXE_LINKER_FLAGS} /subsystem:windows&quot;) </font>
<br><font size=2 face="sans-serif">ENDIF(WIN32)</font>
<br>
<br>
<br><font size=2 face="sans-serif">ADD_EXECUTABLE(viewer WIN32 VIEWER_SRCS)</font>
<br>
<br>
<br><font size=2 face="sans-serif">&lt;end code&gt;</font>
<br>
<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">07/06/2004 19:16</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>There is no need to write WinMain. The library qtmain.lib has the WinMain that<br>
calls the user's main() function.<br>
</tt></font>
<br><font size=2><tt>On Monday 07 June 2004 16:07, William A. Hoffman wrote:<br>
&gt; This is really a QT question. &nbsp; You should look at some QT examples and<br>
&gt; figure out how QT deals with WinMain. &nbsp; If it has a WinMain, then use<br>
&gt; the WIN32 option in ADD_EXECUTABLE:<br>
&gt; ADD_EXECUTABLE(viewer WIN32 VIEWER_SRCS)<br>
&gt; If it uses main, then leave out the WIN32 option.<br>
&gt;<br>
&gt; -Bill<br>
&gt;<br>
-- Filipe Sousa</tt></font>
<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>