don't have David's mail here for replying to it...

but attached is a patch to create the .moc file from the .cpp file if the .cpp 
file matches ^\s*Q_OBJECT. For moc_foo.cpp files it always creates it from 
the .h file. That way you can include both
#include "moc_foo.cpp"
#include "foo.moc"

and with that include the moc generated code from the .cpp and the .h files. 
(If I understood correctly that's compatible with qmake.)

-- 
________________________________________________________
Matthias Kretz (Germany)                            <><
http://Vir.homelinux.org/
[EMAIL PROTECTED], [EMAIL PROTECTED],
[EMAIL PROTECTED]
Index: kde4automoc.cmake
===================================================================
--- kde4automoc.cmake	(revision 680441)
+++ kde4automoc.cmake	(working copy)
@@ -24,14 +24,24 @@
             string(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}")
             if(_current_MOC)
                get_filename_component(_basename ${_current_MOC} NAME_WE)
+
+               # if the .cpp file contains the Q_OBJECT macro we create the .moc file from the .cpp file
+               string(REGEX MATCH "^[ \t]*Q_OBJECT" _matches_q_object "${_contents}")
+               if (_matches_q_object)
+                  set(_header ${_abs_PATH}/${_basename}.h)
+               else (_matches_q_object)
+                  set(_header ${_filename})
+               endif (_matches_q_object)
             else(_current_MOC)
                string(REGEX MATCH "moc_[^ <\"]+\\.cpp" _current_MOC "${_current_MOC_INC}")
                get_filename_component(_basename ${_current_MOC} NAME_WE)
                string(REPLACE "moc_" "" _basename "${_basename}")
+
+               # always create moc_foo.cpp from the .h
+               set(_header ${_abs_PATH}/${_basename}.h)
             endif(_current_MOC)
 
-            set(_header ${_abs_PATH}/${_basename}.h)
-            set(_moc    ${KDE4_CURRENT_BINARY_DIR}/${_current_MOC})
+            set(_moc ${KDE4_CURRENT_BINARY_DIR}/${_current_MOC})
 
             if (NOT EXISTS ${_header})
                message(FATAL_ERROR "In the file \"${_filename}\" the moc file \"${_current_MOC}\" is included, but \"${_header}\" doesn't exist.")

Attachment: pgp7SGHRlPg5u.pgp
Description: PGP signature

_______________________________________________
Kde-buildsystem mailing list
Kde-buildsystem@kde.org
https://mail.kde.org/mailman/listinfo/kde-buildsystem

Reply via email to