[CMake] CMake for Qt4 ( FindQt4.cmake created )
Filipe Sousa
natros at gmail.com
Sat Apr 23 15:18:48 EDT 2005
On Friday 22 April 2005 07:15, Alexander Neundorf wrote:
> > I haven't tried your FindQt4.cmake file, but it looks great!
> > Qt4's UI compiler takes different arguments. So the QT_WRAP_UI command
> > will need changing.
> > Also, Qt4 comes with a new resource compiler which should supported as
> > well.
>
> IMHO this should be done via cmake macros, not via source changes in
> cmake itself.
I agree with you.
> Here I have done something like this (but still for Qt3):
> http://webcvs.kde.org/kdevelop/cmake/
I like the idea of having auto moc macros. I've been using it for some time.
Instead of ADD_EXECUTABLE and ADD_LIBRARY I have QT_ADD_EXECUTABLE and
QT_ADD_LIBRARY :)
#----------------------------------------------------------------------------
# QT_AUTO_MOC(moc_files file1.h [file2.h [file3.h ...]])
#
# Example:
# SET(sources main.cc mainwindow.h mainwindow.cc dialog.h dialog.cc)
# QT_AUTO_MOC(moc_files ${sources})
# ADD_EXECUTABLE(myexe ${sources} ${moc_files})
#----------------------------------------------------------------------------
MACRO(QT_AUTO_MOC outputList)
FOREACH(source ${ARGN})
GET_FILENAME_COMPONENT(ext ${source} EXT)
SET(supportedExtensions "\\.h|\\.hpp|\\.H")
IF("${ext}" MATCHES "${supportedExtensions}")
SET(sourceFile ${CMAKE_CURRENT_SOURCE_DIR}/${source})
IF(EXISTS ${sourceFile})
# search for Q_OBJECT in source file
FILE(READ ${sourceFile} fileContents)
SET(matchRegEx "class.*{.*Q_OBJECT.*}")
IF("${fileContents}" MATCHES "${matchRegEx}")
GET_FILENAME_COMPONENT(baseName ${source} NAME_WE)
SET(outputFile ${CMAKE_CURRENT_BINARY_DIR}/${baseName}.moc.cc)
# moc file
ADD_CUSTOM_COMMAND(
OUTPUT ${outputFile}
COMMAND ${QT_MOC_EXECUTABLE} ARGS ${sourceFile} -o ${outputFile}
DEPENDS ${QT_MOC_EXECUTABLE} ${sourceFile})
SET(${outputList} ${${outputList}} ${outputFile})
ENDIF("${fileContents}" MATCHES "${matchRegEx}")
ENDIF(EXISTS ${sourceFile})
ENDIF("${ext}" MATCHES "${supportedExtensions}")
ENDFOREACH(source)
ENDMACRO(QT_AUTO_MOC)
#----------------------------------------------------------------------------
# QT_ADD_EXECUTABLE(target [WIN32] [MACOSX_BUNDLE] source1 [source2
[source3 ...]])
#
# Example:
# SET(sources main.cc mainwindow.h mainwindow.cc dialog.h dialog.cc)
# QT_ADD_EXECUTABLE(myexe ${sources})
#----------------------------------------------------------------------------
MACRO(QT_ADD_EXECUTABLE target)
QT_AUTO_MOC(mocFiles ${ARGN})
ADD_EXECUTABLE(${target} ${ARGN} ${mocFiles})
ENDMACRO(QT_ADD_EXECUTABLE)
#----------------------------------------------------------------------------
# QT_ADD_LIBRARY(target [SHARED | STATIC | MODULE] source1 [source2
[source3 ...]])
#
# Example:
# SET(sources main.cc mainwindow.h mainwindow.cc dialog.h dialog.cc)
# QT_ADD_LIBRARY(mylib ${sources})
#----------------------------------------------------------------------------
MACRO(QT_ADD_LIBRARY target)
QT_AUTO_MOC(mocFiles ${ARGN})
ADD_LIBRARY(${target} ${ARGN} ${mocFiles})
ENDMACRO(QT_ADD_LIBRARY)
> Bye
> Alex
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/cmake/attachments/20050423/43c2339c/attachment.pgp
More information about the CMake
mailing list