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, 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)
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 Sat, Jul 31, 2010 at 11:54 PM, Michael Jackson
<[email protected]> wrote:
On Sat, Jul 31, 2010 at 11:45 AM, 1+1=2<[email protected]> wrote:
On Sat, Jul 31, 2010 at 11:28 PM, John Drescher<[email protected]> wrote:
On Sat, Jul 31, 2010 at 9:05 AM, 1+1=2<[email protected]> 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_EXECUTABLE.
otherwise moc_main.cxx will be compiled too.
You want moc_main.cxx to be compiled otherwise you will have link errors.
No, the file moc_main.cxx has been included in main.cpp through
#include "moc_main.cxx". And this works.
But what I want is: the name of the moc file which is genenrated from
main.cpp is main.moc, just as qmake does
Debao.
John
_why_ do you need to have the output file named main.moc? is there
some IDE or other pre/post processing script that relies on that name?
Or simply because that is how you did it with qmake? Again, _why_ do
you need to #include main.moc instead of just having it compiled
separately? The results are the same and there is NOTHING in main.moc
that you need to be editing as it is auto generated. Most IDEs will
index the main.moc file so code completion will continue to work even
if you do NOT #include main.moc.
Not trying to be difficult here just saying that sometimes moving
build systems requires you to tweak some things. QMake is NOT CMake so
some things may be slightly different but the end results are the
same.
Mike Jackson
_______________________________________________
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
_______________________________________________
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