Qt-UI

Compilation with C Make

Compilation with QMake | | Debugging

QMake is simple to start with, but offers little control over the build configuration and installation paths. In this respect the multi-platform build tool CMake is superior.

To compile our Qt examples with CMake we create a meta project description named “CMakeLists.txt”. This project description is transformed into Makefiles, XCode projects or Windows solutions similar to QMake.

# cmake build file

PROJECT(MyQtApp)

CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)

# non-standard path to Qt4
SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH};
    /usr/local/Trolltech/Qt-4.7.4;
   )

# Qt4 dependency
FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui REQUIRED)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})

# executable
ADD_EXECUTABLE(main main.cpp)
TARGET_LINK_LIBRARIES(main
   ${QT_LIBRARIES}
   )

On Unix and Mac we type the following command to compile:

cmake . && make

To change the configuration (e.g. paths, compiler settings etc.) we type

ccmake .

to open the interactive cmake configuration tool.

Note: On Windows those tools are integrated into the CMake GUI application.

Compilation with QMake | | Debugging

Options: