PDA

View Full Version : build project with cmake does not work



codebehind
15th August 2008, 16:25
Hello!

I'm learning cmake and i run into a problem.
the code that I compiled with qmake/make from a .pro file it builds OK.

So I've wrote a CMakeLists.txt like on the wiki (http://wiki.qtcentre.org/index.php?title=Compiling_Qt4_apps_with_CMake) and made some changes.

cmake process execute with no errors, but make returns me this:

Linking CXX executable test.x
CMakeFiles/test.x.dir/bgPannel.cpp.o: In function `BGPannel::BGPannel(QWidget*, char const*)':
bgPannel.cpp:(.text+0x15d): undefined reference to `vtable for BGPannel'
bgPannel.cpp:(.text+0x16c): undefined reference to `vtable for BGPannel'
CMakeFiles/test.x.dir/bgPannel.cpp.o: In function `BGPannel::BGPannel(QWidget*, char const*)':
bgPannel.cpp:(.text+0x4d9): undefined reference to `vtable for BGPannel'
bgPannel.cpp:(.text+0x4e8): undefined reference to `vtable for BGPannel'
collect2: ld returned 1 exit status
make[2]: *** [test.x] Error 1
make[1]: *** [CMakeFiles/test.x.dir/all] Error 2
make: *** [all] Error 2

any clue?
as I understand the problem should be in finding .h file, but don't know how to implement it in CMakeLists.txt
the CMakeLists.txt and .pro are attached.

jacek
16th August 2008, 00:25
add_executable( test.x ${${PACKAGE}_SRCS} ${${PACKAGE}_MOC_HDRS} ${${PACKAGE}_HDRS} )
Shouldn't you use ${PACKAGE}_MOC_LIBS here instead of ..._HDRS?

codebehind
16th August 2008, 12:32
i have done that. cmake returns this:

-- Configuring done
CMake Error in CMakeLists.txt:
Cannot find source file "moc_bgPannel.o". Tried extensions .c .C .c++ .cc
.cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx
and my knowledge ends here

codebehind
16th August 2008, 14:22
Is there a chance that the problem is making qmake?
cmake uses qmake by default. But my qmake points to qmake of qt4.
if so is there a variable to set which version of qmake should cmake use?

codebehind
18th August 2008, 12:29
Finally I've done it.

the problem was at:

add_executable( test.x ${${PACKAGE}_SRCS} .moc/moc_bgPannel.cpp)

i forgot the hidden directory .moc!!!