[CMake] KDevelop, QT and CMake

Pau Garcia i Quiles pgquiles at elpauer.org
Fri Aug 17 09:45:04 EDT 2007


Quoting Marcin Gil <marcin.gil at gmail.com>:

> Hi!
>
> I am a bit frustrated, since I haven't found any good value tutorial
> how to develop QT4 software using KDevelop and CMake instead of QMake.
>
> QMake automatically parses .ui files, creates includes, .moc files etc.
>
> How can this be achieved by using CMake?
>
> Can anyone point me to a good tutorial or provide some examples?

It can be done but the current CMake template and build system  
(in-tree, creating files everywhere and messing everything) is awful.  
I am talking about KDevelop 3.4 here.

I removed the CMakeFiles directory and the Makefile KDevelop creates  
and used my own stuff:
1. Create a "build" directory in your project's directory
2. Use this Makefile:

========
all:
         cd build; cmake ..; make

elampodaemon.wt: all

clean:
         rm -rf build/*
========
(replace "elampodaemon.wt" with your target)

3. Use this CMakeLists.txt:
========
PROJECT( elampo )

SET( DESIRED_QT_VERSION GREATER 4.3 )

FIND_PACKAGE( Qt4 REQUIRED )
FIND_PACKAGE( BoostDateTime REQUIRED )
FIND_PACKAGE( Witty REQUIRED )

INCLUDE(${QT_USE_FILE})

ADD_DEFINITIONS( -Wall -O2 -DQT_NO_KEYWORDS )

SET(CMAKE_BUILD_TYPE Debug)

SET( elampo_SRCs main.cpp searchpagewidget.cpp resultspagewidget.cpp  
configpagewidget.cpp resultsetwidget.cpp elampo.cpp )

ADD_EXECUTABLE( elampodaemon.wt ${elampo_SRCs} )

TARGET_LINK_LIBRARIES( elampodaemon.wt ${Witty_LIBRARY}  
${Witty_HTTP_LIBRARY} ${BoostDateTime_LIBRARY} ${QT_LIBRARIES} )

EXECUTE_PROCESS(COMMAND cp ${CMAKE_SOURCE_DIR}/elampo.png  
${CMAKE_BINARY_DIR}/elampo.png )
EXECUTE_PROCESS(COMMAND cp ${CMAKE_SOURCE_DIR}/elampo_small.png  
${CMAKE_BINARY_DIR}/elampo_small.png )
EXECUTE_PROCESS(COMMAND cp ${CMAKE_SOURCE_DIR}/elampo.css  
${CMAKE_BINARY_DIR}/elampo.css )
========
(replace with your stuff when needed, the "SET(CMAKE_BUILD_TYPE  
Debug)" is only needed if you want to debug from withing KDevelop)

-- 
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)


More information about the CMake mailing list