[Qt-interest] How to write CMakeLists.txt when Q_OBJECT in xxx.cpp file

1+1=2 dbzhang800 at gmail.com
Sat Jul 31 18:15:48 CEST 2010


I found an solution, which seems to work under Mingw, MSVC and linux now.

#CMakeLists.txt
PROJECT(mytest)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui REQUIRED)
INCLUDE(${QT_USE_FILE})
SET(pro_SOURCES  main.cpp)

QT4_GENERATE_MOC(main.cpp main.moc)
SET_SOURCE_FILES_PROPERTIES(main.cpp PROPERTIES OBJECT_DEPENDS main.moc)

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
ADD_DEFINITIONS(${QT_DEFINITIONS})
ADD_EXECUTABLE(mytest  ${pro_SOURCES})
TARGET_LINK_LIBRARIES(mytest ${QT_LIBRARIES})


Debao

On Sun, Aug 1, 2010 at 12:04 AM, Guido Seifert <Wargand at gmx.de> wrote:
>
>
>
>> Thank you, but this does not work if your xxx.cpp file contains Q_OBJECT.
>
> Come to think about this, does this even work? I mean Q_OBJECT in .cpp not in .h?  Q_OBJECT belongs in the class declaration, which is usually found in the header. Should not even compile if you have signals or slots in your header.
>
> Guido
>
> --
> GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>




More information about the Qt-interest-old mailing list