I know how much its confusing when you need to configure some new technologies for the first time.Its just , you know how everything works and connects ,but no idea about those little tricky stuff.
In this blog post I am going to write about how to configure QT with CMake. I have uploaded a sample CMake project which will helpful for much clearer understanding.
Download sample project from : http://dl.dropbox.com/u/17399055/cmake-qt-sample.zip
Key points :
- QT comes with its own build tool called “qmake”.So, for Cmake to utilize that , you need to add the folder where “qmake” locates to your PATH environment variable.
Here are important snippets from the CakeList.txt file of the sample project.
- FIND_PACKAGE(Qt4 REQUIRED)
– This will find QT library folder,header files..etc using `qmake` .
- INCLUDE(${QT_USE_FILE})
– This will include QT related header folders to the make file.
- QT4_WRAP_CPP(myprj_moh_srcs ${myprj_moh_hdrs})
– This compiles QT related class headers with QT MOH compiler and generate standard C++ code.Technically any class which uses QTs signal slots (basically classes which inherits `QObjec`) should be passed to this.
- QT4_ADD_RESOURCES(myprj_rccs_srcs ${myprj_rccs})
– This compiles `QT resource files` and wrap all resources into C++ header.This is useful if you want to embed your resources into the executable.
- QT4_WRAP_UI(myprj_ui_hdrs ${myprj_uis})
– This compiles QT UI files into standard C++ code.QT UI files contain user designed interfaces using QT Creator or QT IDE plugins .(eg- QT Eclipse plugin)