[Qt-interest] How to write CMakeLists.txt when Q_OBJECT in xxx.cpp file
Clinton Stimpson
clinton at elemtech.com
Sat Jul 31 18:40:57 CEST 2010
This is a bit better:
#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 ${CMAKE_CURRENT_BINARY_DIR}/main.moc)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
ADD_EXECUTABLE(mytest ${pro_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/main.moc)
TARGET_LINK_LIBRARIES(mytest ${QT_LIBRARIES})
You were manually specifying dependencies, but if you put main.moc (or
any other generated file) in the add_executable(), cmake computes those
dependencies for you.
Clint
On 07/31/2010 10:15 AM, 1+1=2 wrote:
> 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
>>
>>
> _______________________________________________
> 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