[CMake] Problem running moc, Qt.

Christian Marshall Rieck rieck at stud.ntnu.no
Wed Jan 31 10:30:41 EST 2007


Hello,

I have some problems using Qt4, MS Visual C++,  cmake. Google gave 
several pages with 
this, but none helped. I have CMake 2.4 patch 3.

I have a main.cpp that only includes standard Qt headers. This compiles, 
links and runs fine.
Once I try to include my Test.h (with a Test.cpp) and reruns cmake to 
update the solution file the linking fails. Test.h contains Q_OBJECT.

I was told cmake would make the moc-files needed for VC to work. No 
moc-files are created. The cmake-window with all the variables has 
detected the moc-directory correctly. But as far as I can tell, moc is not 
ran at all.

If I manually run moc and turn test.h into moc_test.cpp and include 
moc_test.cpp instead of test.h in test.cpp, it links fine. 

I have among others tried this:
http://qtnode.net/wiki/Qt_with_cmake
I have also tried automoc.

>From my (current) CmakeLists.txt

SET(cqtlib_SRCS
	Test.cpp
)

SET(cqtlib_MOC_HDRS 
	Test.h
)

QT4_WRAP_CPP(cqtlib_MOC_SRC ${cqtlib_MOC_HDRS})
ADD_EXECUTABLE(Segmentation ${cqtlib_SRCS})


If anyone can help me I would be very grateful. 

Christian Marshall Rieck
----------------------------------------
All the good things in life are
fattening, cancer-causing or NP-complete.



More information about the CMake mailing list