[CMake] [PATCH] FindQt4.cmake qt4_automoc improvements
Tanguy Krotoff
tkrotoff at gmail.com
Sat May 17 14:18:29 EDT 2008
Hello
I've noticed some lake of features inside FindQt4.cmake qt4_automoc macro
This patch intend to fix this.
(patch against CMake 2.6.0)
How current qt4_automoc works:
Looks for files that contain string: #include "*.moc"
Issues:
- With QMake, it is possible to specify also #include "moc_*.cpp"
Current qt4_automoc does not handle this.
Here the fix:
- STRING(REGEX MATCHALL "#include +[^ ]+\\.moc[\">]" _match
"${_contents}")
+ STRING(REGEX MATCHALL "#include +([^
]+\\.moc[\">])|(\"moc_+[^ ]+\\.cpp[\">])" _match "${_contents}")
- Current qt4_automoc doesn't check if the .h corresponding to the
*.moc file exists.
Sometimes the Q_OBJECT macro is directly inside the .cpp file and
there is no .h file
Here the fix:
+ IF(NOT EXISTS ${_header})
+ SET(_header ${_abs_PATH}/${_basename}.cpp)
+ ENDIF(NOT EXISTS ${_header})
As you see .cpp extension is hardcoded but I don't think there is the
need for using CMAKE_CXX_SOURCE_FILE_EXTENSIONS as QMake probably
don't support it.
Test:
I managed to compile Phonon library that relies exclusively on
#include "moc_*.cpp" and #include "*.moc" feature
--
Tanguy Krotoff <tkrotoff at gmail.com>
+33 6 68 42 70 24
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt4automoc.patch
Type: application/octet-stream
Size: 1338 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080517/dbd4dee9/attachment.obj>
More information about the CMake
mailing list