I am now attaching the log about the following files:

1) CMakeLists.txt file
2) main.cpp
3) build log
4) moc_main.cxx

Q_MOC_OUTPUT_REVISION is somehow not defined, but not sure why.

Best Regards,
Laszlo Papp

On Mon, Oct 31, 2011 at 1:31 PM, Andreas Pakulat <[email protected]> wrote:
> On 31.10.11 13:10:28, Laszlo Papp wrote:
>> Thank you for your help Andreas. I have tried your approach. Please
>> see the attached logs. The moc files are now somehow not generated. I
>> might need to use qt4_wrap_cpp after all ?
>
> Sorry, seems like my local experiments led to wrong conclusions here. At
> least CMake 2.8.5-rc2 ships with a Qt4Macros.cmake file in which
> QT4_AUTOMOC can only QObject subclasses in header files (i.e. the
> foo.moc form). Don't know about the cmake-builtin automoc support since
> I don't have 2.8.6 at hand here.
>
> So yes, at least with the macro's you'll have to go with qt4_wrap_cpp or
> write your own automoc macro, which shouldn't be too hard if you look at
> the existing one.
>
> Andreas
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: 
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
cmake_minimum_required(VERSION 2.8)

include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})

find_package(Qt4)

include_directories(
    ${QT_INCLUDES}
    ${CMAKE_CURRENT_BINARY_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}
)

set(test_SRCS
    main.cpp
)

qt4_wrap_cpp(test_MOC_FILES ${test_SRCS})

#qt4_automoc(${test_SRCS})

add_executable(test ${test_SRCS} ${test_MOC_FILES})

target_link_libraries(test ${QT_QTCORE_LIBRARY})

#include <QtCore/QObject>

class MyClass : public QObject
{
    Q_OBJECT
};

#include "moc_main.cxx"

int main( int argc, char** argv )
{
    return 0;
}

-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/colorgcc
-- Check for working C compiler: /usr/bin/colorgcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/lib/colorgcc/bin/c++
-- Check for working CXX compiler: /usr/lib/colorgcc/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for Q_WS_X11
-- Looking for Q_WS_X11 - found
-- Looking for Q_WS_WIN
-- Looking for Q_WS_WIN - not found.
-- Looking for Q_WS_QWS
-- Looking for Q_WS_QWS - not found.
-- Looking for Q_WS_MAC
-- Looking for Q_WS_MAC - not found.
-- Found Qt4: /usr/bin/qmake (found version "4.7.4")
-- Configuring done
-- Generating done
-- Build files have been written to: /home/lpapp/Projects/kde/test/build
/usr/bin/cmake -H/home/lpapp/Projects/kde/test -B/home/lpapp/Projects/kde/test/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/lpapp/Projects/kde/test/build/CMakeFiles /home/lpapp/Projects/kde/test/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/lpapp/Projects/kde/test/build'
make -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/depend
make[2]: Entering directory `/home/lpapp/Projects/kde/test/build'
/usr/bin/cmake -E cmake_progress_report /home/lpapp/Projects/kde/test/build/CMakeFiles 3
[ 33%] Generating moc_main.cxx
/usr/bin/moc -I/home/lpapp/Projects/kde/test -I/home/lpapp/Projects/kde/test/build -I/usr/include/QtDesigner -I/usr/include/QtDeclarative -I/usr/include/QtScriptTools -I/usr/include/QtDBus -I/usr/include/QtXml -I/usr/include/QtSql -I/usr/include/QtOpenGL -I/usr/include/QtMultimedia -I/usr/include/QtNetwork -I/usr/include/phonon -I/usr/include/QtXmlPatterns -I/usr/include/QtWebKit -I/usr/include/QtHelp -I/usr/include/QtUiTools -I/usr/include/QtTest -I/usr/include/QtScript -I/usr/include/QtSvg -I/usr/include/Qt3Support -I/usr/include/QtGui -I/usr/include/QtCore -I/usr/share/qt/mkspecs/default -I/usr/include -o /home/lpapp/Projects/kde/test/build/moc_main.cxx /home/lpapp/Projects/kde/test/main.cpp
cd /home/lpapp/Projects/kde/test/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/lpapp/Projects/kde/test /home/lpapp/Projects/kde/test /home/lpapp/Projects/kde/test/build /home/lpapp/Projects/kde/test/build /home/lpapp/Projects/kde/test/build/CMakeFiles/test.dir/DependInfo.cmake --color=
Dependee "/home/lpapp/Projects/kde/test/build/CMakeFiles/test.dir/DependInfo.cmake" is newer than depender "/home/lpapp/Projects/kde/test/build/CMakeFiles/test.dir/depend.internal".
Dependee "/home/lpapp/Projects/kde/test/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/home/lpapp/Projects/kde/test/build/CMakeFiles/test.dir/depend.internal".
Scanning dependencies of target test
make[2]: Leaving directory `/home/lpapp/Projects/kde/test/build'
make -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/build
make[2]: Entering directory `/home/lpapp/Projects/kde/test/build'
/usr/bin/cmake -E cmake_progress_report /home/lpapp/Projects/kde/test/build/CMakeFiles 1
[ 66%] Building CXX object CMakeFiles/test.dir/main.cpp.o
/usr/lib/colorgcc/bin/c++    -g -I/home/lpapp/Projects/kde/test -I/home/lpapp/Projects/kde/test/build -I/usr/include/QtDesigner -I/usr/include/QtDeclarative -I/usr/include/QtScriptTools -I/usr/include/QtDBus -I/usr/include/QtXml -I/usr/include/QtSql -I/usr/include/QtOpenGL -I/usr/include/QtMultimedia -I/usr/include/QtNetwork -I/usr/include/phonon -I/usr/include/QtXmlPatterns -I/usr/include/QtWebKit -I/usr/include/QtHelp -I/usr/include/QtUiTools -I/usr/include/QtTest -I/usr/include/QtScript -I/usr/include/QtSvg -I/usr/include/Qt3Support -I/usr/include/QtGui -I/usr/include/QtCore -I/usr/share/qt/mkspecs/default    -o CMakeFiles/test.dir/main.cpp.o -c /home/lpapp/Projects/kde/test/main.cpp
/usr/bin/cmake -E cmake_progress_report /home/lpapp/Projects/kde/test/build/CMakeFiles 2
[100%] Building CXX object CMakeFiles/test.dir/moc_main.cxx.o
/usr/lib/colorgcc/bin/c++    -g -I/home/lpapp/Projects/kde/test -I/home/lpapp/Projects/kde/test/build -I/usr/include/QtDesigner -I/usr/include/QtDeclarative -I/usr/include/QtScriptTools -I/usr/include/QtDBus -I/usr/include/QtXml -I/usr/include/QtSql -I/usr/include/QtOpenGL -I/usr/include/QtMultimedia -I/usr/include/QtNetwork -I/usr/include/phonon -I/usr/include/QtXmlPatterns -I/usr/include/QtWebKit -I/usr/include/QtHelp -I/usr/include/QtUiTools -I/usr/include/QtTest -I/usr/include/QtScript -I/usr/include/QtSvg -I/usr/include/Qt3Support -I/usr/include/QtGui -I/usr/include/QtCore -I/usr/share/qt/mkspecs/default    -o CMakeFiles/test.dir/moc_main.cxx.o -c /home/lpapp/Projects/kde/test/build/moc_main.cxx
/home/lpapp/Projects/kde/test/build/moc_main.cxx:11:2: error: #error "The header file `main.cpp' doesn't include <QObject>."
/home/lpapp/Projects/kde/test/build/moc_main.cxx:18:1: error: ‘QT_BEGIN_MOC_NAMESPACE’ does not name a type
/home/lpapp/Projects/kde/test/build/moc_main.cxx:39:7: error: ‘QMetaObject’ does not name a type
/home/lpapp/Projects/kde/test/build/moc_main.cxx:48:7: error: ‘QMetaObject’ does not name a type
/home/lpapp/Projects/kde/test/build/moc_main.cxx:53:7: error: ‘MyClass’ has not been declared
/home/lpapp/Projects/kde/test/build/moc_main.cxx: In function ‘void* qt_metacast(const char*)’:
/home/lpapp/Projects/kde/test/build/moc_main.cxx:56:52: error: ‘strcmp’ was not declared in this scope
/home/lpapp/Projects/kde/test/build/moc_main.cxx:57:47: error: expected type-specifier before ‘MyClass’
/home/lpapp/Projects/kde/test/build/moc_main.cxx:57:47: error: expected ‘>’ before ‘MyClass’
/home/lpapp/Projects/kde/test/build/moc_main.cxx:57:47: error: expected ‘(’ before ‘MyClass’
/home/lpapp/Projects/kde/test/build/moc_main.cxx:57:47: error: ‘MyClass’ was not declared in this scope
/home/lpapp/Projects/kde/test/build/moc_main.cxx:57:55: error: expected primary-expression before ‘>’ token
/home/lpapp/Projects/kde/test/build/moc_main.cxx:57:57: error: invalid use of ‘this’ in non-member function
/home/lpapp/Projects/kde/test/build/moc_main.cxx:57:63: error: expected ‘)’ before ‘;’ token
/home/lpapp/Projects/kde/test/build/moc_main.cxx:58:12: error: ‘QObject’ has not been declared
/home/lpapp/Projects/kde/test/build/moc_main.cxx: At global scope:
/home/lpapp/Projects/kde/test/build/moc_main.cxx:61:5: error: ‘MyClass’ has not been declared
/home/lpapp/Projects/kde/test/build/moc_main.cxx:61:26: error: ‘QMetaObject’ has not been declared
/home/lpapp/Projects/kde/test/build/moc_main.cxx:61:48: error: expected primary-expression before ‘int’
/home/lpapp/Projects/kde/test/build/moc_main.cxx:61:57: error: expected primary-expression before ‘void’
/home/lpapp/Projects/kde/test/build/moc_main.cxx:61:66: error: expression list treated as compound expression in initializer [-fpermissive]
/home/lpapp/Projects/kde/test/build/moc_main.cxx:62:1: error: expected ‘,’ or ‘;’ before ‘{’ token
/home/lpapp/Projects/kde/test/build/moc_main.cxx:68:1: error: ‘QT_END_MOC_NAMESPACE’ does not name a type
make[2]: *** [CMakeFiles/test.dir/moc_main.cxx.o] Error 1
make[2]: Leaving directory `/home/lpapp/Projects/kde/test/build'
make[1]: *** [CMakeFiles/test.dir/all] Error 2
make[1]: Leaving directory `/home/lpapp/Projects/kde/test/build'
make: *** [all] Error 2

/****************************************************************************
** Meta object code from reading C++ file 'main.cpp'
**
** Created: Mon Oct 31 17:41:37 2011
**      by: The Qt Meta Object Compiler version 62 (Qt 4.7.4)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/

#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'main.cpp' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 62
#error "This file was generated using the moc from 4.7.4. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif

QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_MyClass[] = {

 // content:
       5,       // revision
       0,       // classname
       0,    0, // classinfo
       0,    0, // methods
       0,    0, // properties
       0,    0, // enums/sets
       0,    0, // constructors
       0,       // flags
       0,       // signalCount

       0        // eod
};

static const char qt_meta_stringdata_MyClass[] = {
    "MyClass\0"
};

const QMetaObject MyClass::staticMetaObject = {
    { &QObject::staticMetaObject, qt_meta_stringdata_MyClass,
      qt_meta_data_MyClass, 0 }
};

#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &MyClass::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION

const QMetaObject *MyClass::metaObject() const
{
    return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}

void *MyClass::qt_metacast(const char *_clname)
{
    if (!_clname) return 0;
    if (!strcmp(_clname, qt_meta_stringdata_MyClass))
        return static_cast<void*>(const_cast< MyClass*>(this));
    return QObject::qt_metacast(_clname);
}

int MyClass::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    return _id;
}
QT_END_MOC_NAMESPACE

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to