All pastes #590174 Raw Edit

Miscellany

public text v1 · immutable
#590174 ·published 2007-06-26 12:19 UTC
rendered paste body
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 "^\s*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.")