[CMake] How to write CMakeLists.txt for Qt4 when Q_OBJECT in xxx.cpp file
1+1=2
dbzhang800 at gmail.com
Sat Jul 31 07:38:56 EDT 2010
Hi,everyone
I am new to cmake. I don't know how to write a CMakeList.txt file if
Q_OBJECT in a "xxx.cpp" source file.
for example,
A very simple qt4 program like this.
// filename main.cpp
#include <QtGui/QApplication>
#include <QtGui/QWidget>
class Widget:public QWidget
{
Q_OBJECT
public:
Widget(QWidget * parent=0):QWidget(parent) {}
};
#include "main.moc"
int main(int argc, char** argv) {
QApplication app(argc, argv);
Widget w;
w.show();
return app.exec();
}
if i use qmake, i only needed a simple .pro file like this:
TEMPLATE = app
SOURCES += main.cpp
I try to write a CMakeList.txt, try qt4_wrap_cpp qt4_automoc and
qt4_generate_moc, but They did not seem to work
PROJECT(mytest)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui REQUIRED)
INCLUDE(${QT_USE_FILE})
SET(pro_SOURCES main.cpp)
#QT4_WRAP_CPP(${pro_SOURCES})
#QT4_AUTOMOC(${pro_SOURCES})
#QT4_GENERATE_MOC(${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
${CMAKE_CURRENT_BINARY_DIR}/main.moc)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
ADD_DEFINITIONS(${QT_DEFINITIONS})
ADD_EXECUTABLE(mytest ${pro_SOURCES})
TARGET_LINK_LIBRARIES(mytest ${QT_LIBRARIES})
Is there any solution to this?
thanks
More information about the CMake
mailing list