[CMake] How to write CMakeLists.txt for Qt4 when Q_OBJECT in xxx.cpp file

2010-07-31 Thread 1+1=2
Hi,everyone I am new to cmake. I don't know how to write a CMakeList.txt file if Q_OBJECT in a "xxx.cpp" source file. for example, A very simple qt4 program like this. // filename main.cpp #include #include class Widget:public QWidget { Q_OBJECT public: Widget(QWidget * parent=0):QWidge

Re: [CMake] How to write CMakeLists.txt for Qt4 when Q_OBJECT in xxx.cpp file

2010-07-31 Thread Michael Jackson
PROJECT(mytest) CMAKE_MINIMUM_REQUIRED(VERSION 2.6) FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui REQUIRED) INCLUDE(${QT_USE_FILE}) SET(pro_SOURCESmain.cpp) QT4_WRAP_CPP( Generated_MOC_SRCS main.cpp ) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) ADD_EXECUTABLE(mytest ${pro_SOURCES} ${Generat

Re: [CMake] How to write CMakeLists.txt for Qt4 when Q_OBJECT in xxx.cpp file

2010-07-31 Thread 1+1=2
Thanks for your answer. when use QT4_WRAP_CPP( Generated_MOC_SRCS main.cpp ), moc_main.cxx will be generated. then I use #include "moc_main.cxx" instead of #include "main.moc" but ${Generated_MOC_SRCS} can not be added to ADD_EXECUTABLE. otherwise moc_main.cxx will be compiled too. This works

Re: [CMake] How to write CMakeLists.txt for Qt4 when Q_OBJECT in xxx.cpp file

2010-07-31 Thread John Drescher
> when use QT4_WRAP_CPP( Generated_MOC_SRCS main.cpp ),  moc_main.cxx > will be generated. > then I use #include "moc_main.cxx" instead of #include "main.moc" > > but ${Generated_MOC_SRCS}  can not be added to  ADD_EXECUTABLE. > otherwise moc_main.cxx will be compiled too. > I am confused at the p

Re: [CMake] How to write CMakeLists.txt for Qt4 when Q_OBJECT in xxx.cpp file

2010-07-31 Thread John Drescher
On Sat, Jul 31, 2010 at 10:50 AM, 1+1=2 wrote: > I want to use command like this: > > QT4_GENERATE_MOC(${CMAKE_CURRENT_SOURCE_DIR}/main.cpp main.moc) > > but I do not know how to make this run before main.cpp being compiled to > main.o > > anyone can help me? > Besides the fact that your syntax

Re: [CMake] How to write CMakeLists.txt for Qt4 when Q_OBJECT in xxx.cpp file

2010-07-31 Thread John Drescher
On Sat, Jul 31, 2010 at 9:05 AM, 1+1=2 wrote: > Thanks for your answer. > > when use QT4_WRAP_CPP( Generated_MOC_SRCS main.cpp ),  moc_main.cxx > will be generated. > then I use #include "moc_main.cxx" instead of #include "main.moc" > > but ${Generated_MOC_SRCS}  can not be added to  ADD_EXECUTABL

Re: [CMake] How to write CMakeLists.txt for Qt4 when Q_OBJECT in xxx.cpp file

2010-07-31 Thread John Drescher
On Sat, Jul 31, 2010 at 11:28 AM, John Drescher wrote: > On Sat, Jul 31, 2010 at 9:05 AM, 1+1=2 wrote: >> Thanks for your answer. >> >> when use QT4_WRAP_CPP( Generated_MOC_SRCS main.cpp ),  moc_main.cxx >> will be generated. >> then I use #include "moc_main.cxx" instead of #include "main.moc" >>

Re: [CMake] How to write CMakeLists.txt for Qt4 when Q_OBJECT in xxx.cpp file

2010-07-31 Thread 1+1=2
On Sat, Jul 31, 2010 at 11:28 PM, John Drescher wrote: > On Sat, Jul 31, 2010 at 9:05 AM, 1+1=2 wrote: >> Thanks for your answer. >> >> when use QT4_WRAP_CPP( Generated_MOC_SRCS main.cpp ),  moc_main.cxx >> will be generated. >> then I use #include "moc_main.cxx" instead of #include "main.moc" >>

Re: [CMake] How to write CMakeLists.txt for Qt4 when Q_OBJECT in xxx.cpp file

2010-07-31 Thread Michael Jackson
On Sat, Jul 31, 2010 at 11:45 AM, 1+1=2 wrote: > On Sat, Jul 31, 2010 at 11:28 PM, John Drescher wrote: >> On Sat, Jul 31, 2010 at 9:05 AM, 1+1=2 wrote: >>> Thanks for your answer. >>> >>> when use QT4_WRAP_CPP( Generated_MOC_SRCS main.cpp ),  moc_main.cxx >>> will be generated. >>> then I use #

Re: [CMake] How to write CMakeLists.txt for Qt4 when Q_OBJECT in xxx.cpp file

2010-07-31 Thread 1+1=2
Thanks for your advice. I just want the project to be able to work under both cmake and qmake. I found an answer, which seems to work now. PROJECT(mytest) CMAKE_MINIMUM_REQUIRED(VERSION 2.6) FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui REQUIRED) INCLUDE(${QT_USE_FILE}) SET(pro_SOURCES main.cpp) QT

Re: [CMake] How to write CMakeLists.txt for Qt4 when Q_OBJECT in xxx.cpp file

2010-07-31 Thread Clinton Stimpson
If you put main.moc in add_executable() then you don't have to use the set_source_files_properties() to manually specify dependencies. Clint On 07/31/2010 10:11 AM, 1+1=2 wrote: Thanks for your advice. I just want the project to be able to work under both cmake and qmake. I found an answer,

Re: [CMake] How to write CMakeLists.txt for Qt4 when Q_OBJECT in xxx.cpp file

2010-08-03 Thread Alexander Neundorf
On Saturday 31 July 2010, Clinton Stimpson wrote: > If you put main.moc in add_executable() then you don't have to use the > set_source_files_properties() to manually specify dependencies. Yes, but main.moc is already #included in main.cpp so it cannout be added to add_executable. In KDE we are

Re: [CMake] How to write CMakeLists.txt for Qt4 when Q_OBJECT in xxx.cpp file

2010-08-03 Thread Clinton Stimpson
On Tuesday, August 03, 2010 02:07:31 pm Alexander Neundorf wrote: > On Saturday 31 July 2010, Clinton Stimpson wrote: > > If you put main.moc in add_executable() then you don't have to use the > > set_source_files_properties() to manually specify dependencies. > > Yes, but main.moc is already #inc

Re: [CMake] How to write CMakeLists.txt for Qt4 when Q_OBJECT in xxx.cpp file

2010-08-03 Thread Kishore
On Wednesday 04 Aug 2010 1:49:36 am Clinton Stimpson wrote: > On Tuesday, August 03, 2010 02:07:31 pm Alexander Neundorf wrote: > > On Saturday 31 July 2010, Clinton Stimpson wrote: > > > If you put main.moc in add_executable() then you don't have to use the > > > set_source_files_properties() to m