[Qt-interest] Lots of problems with cmake.

Dorosky, Christopher G christopher.g.dorosky at lmco.com
Fri Jun 12 18:59:58 CEST 2009


SOLVED. What follows is the CMakeLists.txt that works for me.
Much thanks, good karma, happy thoughts to Clint for his clean example
and Andreas for giving direction.

This is an example CMakeLists.txt that will compile and link the example
broadcastsender.cpp that comes with QT.
I copied it to another directory without the .moc files.


#START HERE


cmake_minimum_required(VERSION 2.6)

PROJECT (qttest CXX)

#so that we can see what happens in the make, in case of problems.
set(CMAKE_VERBOSE_MAKEFILE on)

# find QT4
find_package(Qt4 REQUIRED)

# Tell QT_LIBRARIES what I'll be needing, plus help with headers.
set(QT_USE_OPENGL TRUE)
set(QT_USE_QTNETWORK TRUE)

# Setup the build environment for any following lib / exec
include(${QT_USE_FILE})

#convenience
SET(test_SRCS sender.cpp main.cpp)
# for generating MOC's later.
SET(test_MOC_HDRS sender.h)

#magic call that asks for generation of MOC src files
QT4_WRAP_CPP(test_MOC_SRCS ${test_MOC_HDRS})

#be sure to add the MOC files to the build.
ADD_EXECUTABLE(qttest ${test_SRCS} ${test_MOC_SRCS})

# Add in the right libraries. QT_LIBRARIES gets default + the sets above
TARGET_LINK_LIBRARIES(qttest ${QT_LIBRARIES} )

#END HERE


It's probably not nearly perfect, but it is simple.
I also had QTDIR (trunk of QT) defined, added to the start of the search
path, and had the libs directory added to LD_LIBRARY_PATH
CMAKE_PREFIX_PATH was also created as equal to QTDIR


I'm adding some happy words here to make google searching easier for the
next guy/gal.

example CMakeLists.txt with QT.
QT and CMake example

Thanks again!

Chris



More information about the Qt-interest-old mailing list