<div dir="ltr"><div class="gmail_quote"><br><div dir="ltr">Thank you all very much for your help. The problem is solved. I&#39;d like to post my CMakeLists.txt file here for other people with similar problems:<div><br><div>
<div class="Ih2E3d"><div>PROJECT ( COMBINED )</div><div>FIND_PACKAGE (Qt4 REQUIRED)</div>
<div>SET(QT_USE_QTOPENGL TRUE)</div></div><div class="Ih2E3d"><div>SET(QT_WRAP_CPP TRUE)</div><div><br></div></div><div>INCLUDE( ${QT_USE_FILE} )</div><div>SET(MOCHEADER glwidget.h window.h)</div><div>QT4_WRAP_CPP(MOCFILES ${MOCHEADER})</div>
<div>ADD_EXECUTABLE(exe main.cpp glwidget.cpp window.cpp ${MOCFILES})</div><div class="Ih2E3d">
<div>TARGET_LINK_LIBRARIES(exe ${QT_LIBRARIES})</div><div><br></div><div><br></div></div><font color="#888888"><div>Linge</div></font><div><div></div><div class="Wj3C7c"><br><div class="gmail_quote">On Sat, Sep 27, 2008 at 11:11 AM, Bill Hoffman <span dir="ltr">&lt;<a href="mailto:bill.hoffman@kitware.com" target="_blank">bill.hoffman@kitware.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Linge Bai wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It is the moc stuff that&#39;s causing the problem. After used qmake to generate moc_*.cpp files, I was able to use cmake to compile the code. But I still have no idea on how to use cmake to compile the code without using qmake to generate the moc files first.<br>


<br>
The change to my CMakeLists.txt file I made is:<br>
SET(QT_WRAP_CPP TRUE)<br>
<br>
</blockquote></div>
See here:<br>
<a href="http://www.cmake.org/cmake/help/cmake2.6docs.html#module:FindQt4" target="_blank">http://www.cmake.org/cmake/help/cmake2.6docs.html#module:FindQt4</a><br>
<br>
Specifically:<br>
<br>
There are also some files that need processing by some Qt tools such as moc and uic. Listed below are macros that may be used to process those files.<br>
<br>
<br>
 &nbsp;macro QT4_WRAP_CPP(outfiles inputfile ... OPTIONS ...)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;create moc code from a list of files containing Qt class with<br>
 &nbsp; &nbsp; &nbsp; &nbsp;the Q_OBJECT declaration. &nbsp;Per-direcotry preprocessor definitions<br>
 &nbsp; &nbsp; &nbsp; &nbsp;are also added. &nbsp;Options may be given to moc, such as those found<br>
 &nbsp; &nbsp; &nbsp; &nbsp;when executing &quot;moc -help&quot;.<br>
<br>
-Bill<br><font color="#888888">
<br>
-- <br>
Bill Hoffman<br>
Kitware, Inc.<br>
28 Corporate Drive<br>
Clifton Park, NY 12065<br>
<a href="mailto:bill.hoffman@kitware.com" target="_blank">bill.hoffman@kitware.com</a><br>
<a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a><br>
518-371-3971 (phone and fax)<br>
</font></blockquote></div><br></div></div></div></div></div>
</div><br></div>