Re: [CMake] Forcibly run 'moc' on Qt files that are NOT part of the build

2012-03-08 Thread Jean-Christophe Fillion-Robin
Hi Michael,

May be you could have a look at [1], [2] and [3]. It basically illustrates
how to moc a header a file and include at the end of cpp file.

Hth
Jc

[1]
https://github.com/commontk/CTK/blob/master/Libs/Testing/CMake/ctkMacroGenerateMocs.cmake
[2]
https://github.com/commontk/CTK/blob/master/Libs/Widgets/Testing/Cpp/CMakeLists.txt#L120
[3]
https://github.com/commontk/CTK/blob/master/Libs/Widgets/Testing/Cpp/ctkMessageBoxDontShowAgainTest.cpp#L530

On Wed, Mar 7, 2012 at 12:13 PM, Michael Jackson 
mike.jack...@bluequartz.net wrote:


 On Mar 7, 2012, at 12:05 PM, Michael Wild wrote:

  On 03/07/2012 04:10 PM, Michael Jackson wrote:
  In an effort to speed up the build of a project that uses Qt (and moc)
 I tried an alternate approach with the moc files. Normally I use the basic
 idea of gathering the headers that need to be moc'ed and feed those to
 moc with this type of CMake Code:
 
  QT4_WRAP_CPP( FilterWidgets_Generated_MOC_SRCS ${QFilterWidget_HDRS}
 ${FilterWidget_GEN_HDRS})
 
  The in the Add_Executable(...) call include the
 ${FilterWidgets_Generated_MOC_SRCS} variable to the list of sources. In my
 project I have at least 30 auto-generated files which all get moc'ed. That
 gives me an additional 60 compiled files. So I tried the idea of #include
 moc_[some_file.cxx] in each of the auto-generated .cpp files for each
 Widget. This would cut the number of files compiled in half. The issue is
 that since they are being #include'ed in the .cpp files then they do NOT
 need to be compiled themselves so I took the
 ${FilterWidgets_Generated_MOC_SRCS} out of the list of sources in the
 add_executable() call. What happened is that CMake did NOT run moc on those
 headers because there were now NOT included in the build.
 
  So for that version of the cmake code I have something like this:
 
  QT4_WRAP_CPP( FilterWidgets_Generated_MOC_SRCS ${FilterWidget_GEN_HDRS})
  QT4_WRAP_CPP( FilterWidgets_MOC_SRCS ${QFilterWidget_HDRS} )
 
  Is there a way to forcibly run the moc step even if the resulting
 source files are NOT directly included in the add_executable?
 Custom_Command? Add_Depends?
 
  Thanks
 
  You could still add them to the add_executable() call, but set their
  HEADER_FILE_ONLY source file property to TRUE to prevent them from being
  compiled. This way they would still show up in the proper place in
  IDE's, and no need for fiddling around with add_custom_target() and
  add_dependencies(). Of course, you might still want to introduce the
  custom target for convenience so you can trigger moc'ing manually (e.g.
  make moc)...
 
  Michael
 
  --


 Thanks to everyone (Michael and Andreas) for the suggestions. Both
 suggestions have their pros and cons. I am leaning towards the Use the new
 automoc function in CMake 2.8.7 that Andreas suggested. I don't have to
 worry about the CMake version since there are only 2 developers. We can
 upgrade to the latest CMake without a problem.
  Actually NOT having them listed in the IDE is BETTER for me since I tread
 those files as black boxes, ie, I don't really want to know what is in
 them. Or at least on a very rare occasion at which point I can just search
 for the file in the build directory.

 Thanks again Everyone. I'll post in the next few days what I ended up
 doing.
 --
 Mike J.
 --

 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




-- 
+1 919 869 8849
--

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

Re: [CMake] Forcibly run 'moc' on Qt files that are NOT part of the build

2012-03-08 Thread David Cole
On Thu, Mar 8, 2012 at 9:50 AM, Michael Jackson
mike.jack...@bluequartz.net wrote:
 On Mar 7, 2012, at 11:43 AM, Andreas Pakulat wrote:

 On 07.03.12 10:10:27, Michael Jackson wrote:
 In an effort to speed up the build of a project that uses Qt (and moc) I 
 tried an alternate approach with the moc files. Normally I use the basic 
 idea of gathering the headers that need to be moc'ed and feed those to 
 moc with this type of CMake Code:

 QT4_WRAP_CPP( FilterWidgets_Generated_MOC_SRCS ${QFilterWidget_HDRS} 
 ${FilterWidget_GEN_HDRS})

 The in the Add_Executable(...) call include the 
 ${FilterWidgets_Generated_MOC_SRCS} variable to the list of sources. In my 
 project I have at least 30 auto-generated files which all get moc'ed. That 
 gives me an additional 60 compiled files. So I tried the idea of #include 
 moc_[some_file.cxx] in each of the auto-generated .cpp files for each 
 Widget. This would cut the number of files compiled in half. The issue is 
 that since they are being #include'ed in the .cpp files then they do NOT 
 need to be compiled themselves so I took the 
 ${FilterWidgets_Generated_MOC_SRCS} out of the list of sources in the 
 add_executable() call. What happened is that CMake did NOT run moc on those 
 headers because there were now NOT included in the build.

 So for that version of the cmake code I have something like this:

 QT4_WRAP_CPP( FilterWidgets_Generated_MOC_SRCS ${FilterWidget_GEN_HDRS})
 QT4_WRAP_CPP( FilterWidgets_MOC_SRCS ${QFilterWidget_HDRS} )

 Is there a way to forcibly run the moc step even if the resulting source 
 files are NOT directly included in the add_executable? Custom_Command? 
 Add_Depends?

 A few options I can think of:

 - Use the automoc developed as part of KDE (its pure-Qt though)
    https://projects.kde.org/projects/kdesupport/automoc/repository
 - Use the automoc function from FindQt4.cmake
 - Use the new automoc function in CMake 2.8.7

 All of these will help handle the qt4_wrap_cpp stuff for you as long as
 you have the #include. Note that I think there's at least 2 or 3
 differnet filenames for the include depending on which of the above you
 use (foo.moc vs moc_foo.cpp vs. moc_foo.cxx or something like that).

 If none of them is an option for you then I guess using
 add_custom_target and add_dependencies is the way to go.

 Andreas

 I looked into the automoc functionality and after some tinkering around I 
 think there is still a disconnect in my cmake code. When are the 
 source/header files scanned by automoc to determine if they will have moc run 
 on them.
   Currently during cmake time I generate a blank header and source file 
 (well, there is a #error ... in them) which then get over written by a new 
 files during build time. The new files are complete and proper C++ source 
 files/headers with the Q_OBJECT macro in the header and #include moc_*.cpp 
 in the source file. When I compile (using makefiles on OS X currently as a 
 test) I get an error that the moc_*.cpp file can not be found and searching 
 the entire build directory does not reveal the file. If I run CMake again and 
 compile then the auto moc files do appear. From this I think that automoc 
 runs during CMake time. Is this correct?
 --
 Mike J.

 --

 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


Yes, I think that's correct. (Alex will chime in, too, probably if I'm wrong...)

So if you're generating your sources during build time, then you'll
need to run moc yourself and not rely on the CMake AUTOMOC
functionality.
--

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


Re: [CMake] Forcibly run 'moc' on Qt files that are NOT part of the build

2012-03-08 Thread Michael Jackson
On Thu, Mar 8, 2012 at 11:30 AM, Andreas Pakulat ap...@gmx.de wrote:
 On 08.03.12 09:50:55, Michael Jackson wrote:
 On Mar 7, 2012, at 11:43 AM, Andreas Pakulat wrote:

  On 07.03.12 10:10:27, Michael Jackson wrote:
  In an effort to speed up the build of a project that uses Qt (and moc) I 
  tried an alternate approach with the moc files. Normally I use the basic 
  idea of gathering the headers that need to be moc'ed and feed those to 
  moc with this type of CMake Code:
 
  QT4_WRAP_CPP( FilterWidgets_Generated_MOC_SRCS ${QFilterWidget_HDRS} 
  ${FilterWidget_GEN_HDRS})
 
  The in the Add_Executable(...) call include the 
  ${FilterWidgets_Generated_MOC_SRCS} variable to the list of sources. In 
  my project I have at least 30 auto-generated files which all get moc'ed. 
  That gives me an additional 60 compiled files. So I tried the idea of 
  #include moc_[some_file.cxx] in each of the auto-generated .cpp files 
  for each Widget. This would cut the number of files compiled in half. The 
  issue is that since they are being #include'ed in the .cpp files then 
  they do NOT need to be compiled themselves so I took the 
  ${FilterWidgets_Generated_MOC_SRCS} out of the list of sources in the 
  add_executable() call. What happened is that CMake did NOT run moc on 
  those headers because there were now NOT included in the build.
 
  So for that version of the cmake code I have something like this:
 
  QT4_WRAP_CPP( FilterWidgets_Generated_MOC_SRCS ${FilterWidget_GEN_HDRS})
  QT4_WRAP_CPP( FilterWidgets_MOC_SRCS ${QFilterWidget_HDRS} )
 
  Is there a way to forcibly run the moc step even if the resulting source 
  files are NOT directly included in the add_executable? Custom_Command? 
  Add_Depends?
 
  A few options I can think of:
 
  - Use the automoc developed as part of KDE (its pure-Qt though)
     https://projects.kde.org/projects/kdesupport/automoc/repository
  - Use the automoc function from FindQt4.cmake
  - Use the new automoc function in CMake 2.8.7
 
  All of these will help handle the qt4_wrap_cpp stuff for you as long as
  you have the #include. Note that I think there's at least 2 or 3
  differnet filenames for the include depending on which of the above you
  use (foo.moc vs moc_foo.cpp vs. moc_foo.cxx or something like that).
 
  If none of them is an option for you then I guess using
  add_custom_target and add_dependencies is the way to go.
 
  Andreas
 
 I looked into the automoc functionality and after some tinkering around I 
 think there is still a disconnect in my cmake code. When are the 
 source/header files scanned by automoc to determine if they will have moc 
 run on them.
    Currently during cmake time I generate a blank header and source file 
 (well, there is a #error ... in them) which then get over written by a new 
 files during build time. The new files are complete and proper C++ source 
 files/headers with the Q_OBJECT macro in the header and #include moc_*.cpp 
 in the source file. When I compile (using makefiles on OS X currently as a 
 test) I get an error that the moc_*.cpp file can not be found and searching 
 the entire build directory does not reveal the file. If I run CMake again 
 and compile then the auto moc files do appear. From this I think that 
 automoc runs during CMake time. Is this correct?

 Yes, all three automoc's do the header-check during cmake-time. But if
 you already generate the source files during build-time couldn't you add
 another step for running moc there?

 Andreas


I ended up using the hint that Michael gave about setting the source
files properties to HEADER_ONLY. This combination gives the proper
dependencies between my build time generation of the source files and
the need to moc those files. Along with some other techniques recently
brought up on the list I was able to optimize our builds and shave
over 95% of the build time for rebuilds. Thanks to everyone for their
time, patience and explanations.

Thanks
--
Mike J.
--

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] Forcibly run 'moc' on Qt files that are NOT part of the build

2012-03-07 Thread Michael Jackson
In an effort to speed up the build of a project that uses Qt (and moc) I tried 
an alternate approach with the moc files. Normally I use the basic idea of 
gathering the headers that need to be moc'ed and feed those to moc with this 
type of CMake Code:

QT4_WRAP_CPP( FilterWidgets_Generated_MOC_SRCS ${QFilterWidget_HDRS} 
${FilterWidget_GEN_HDRS}) 

The in the Add_Executable(...) call include the 
${FilterWidgets_Generated_MOC_SRCS} variable to the list of sources. In my 
project I have at least 30 auto-generated files which all get moc'ed. That 
gives me an additional 60 compiled files. So I tried the idea of #include 
moc_[some_file.cxx] in each of the auto-generated .cpp files for each Widget. 
This would cut the number of files compiled in half. The issue is that since 
they are being #include'ed in the .cpp files then they do NOT need to be 
compiled themselves so I took the ${FilterWidgets_Generated_MOC_SRCS} out of 
the list of sources in the add_executable() call. What happened is that CMake 
did NOT run moc on those headers because there were now NOT included in the 
build.

 So for that version of the cmake code I have something like this:

QT4_WRAP_CPP( FilterWidgets_Generated_MOC_SRCS ${FilterWidget_GEN_HDRS}) 
QT4_WRAP_CPP( FilterWidgets_MOC_SRCS ${QFilterWidget_HDRS} )

Is there a way to forcibly run the moc step even if the resulting source files 
are NOT directly included in the add_executable? Custom_Command? Add_Depends?

Thanks
___
Mike JacksonPrincipal Software Engineer
BlueQuartz SoftwareDayton, Ohio
mike.jack...@bluequartz.net  www.bluequartz.net

--

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


Re: [CMake] Forcibly run 'moc' on Qt files that are NOT part of the build

2012-03-07 Thread Michael Hertling
On 03/07/2012 04:10 PM, Michael Jackson wrote:
 In an effort to speed up the build of a project that uses Qt (and moc) I 
 tried an alternate approach with the moc files. Normally I use the basic idea 
 of gathering the headers that need to be moc'ed and feed those to moc with 
 this type of CMake Code:
 
 QT4_WRAP_CPP( FilterWidgets_Generated_MOC_SRCS ${QFilterWidget_HDRS} 
 ${FilterWidget_GEN_HDRS}) 
 
 The in the Add_Executable(...) call include the 
 ${FilterWidgets_Generated_MOC_SRCS} variable to the list of sources. In my 
 project I have at least 30 auto-generated files which all get moc'ed. That 
 gives me an additional 60 compiled files. So I tried the idea of #include 
 moc_[some_file.cxx] in each of the auto-generated .cpp files for each 
 Widget. This would cut the number of files compiled in half. The issue is 
 that since they are being #include'ed in the .cpp files then they do NOT need 
 to be compiled themselves so I took the ${FilterWidgets_Generated_MOC_SRCS} 
 out of the list of sources in the add_executable() call. What happened is 
 that CMake did NOT run moc on those headers because there were now NOT 
 included in the build.
 
  So for that version of the cmake code I have something like this:
 
 QT4_WRAP_CPP( FilterWidgets_Generated_MOC_SRCS ${FilterWidget_GEN_HDRS}) 
 QT4_WRAP_CPP( FilterWidgets_MOC_SRCS ${QFilterWidget_HDRS} )
 
 Is there a way to forcibly run the moc step even if the resulting source 
 files are NOT directly included in the add_executable? Custom_Command? 
 Add_Depends?

AFAIK, the QT4_WRAP_CPP() macro is essentially a wrapper around ADD_
CUSTOM_COMMAND() which accumulates the latter's OUTPUT files in the
former's first parameter. Thus, you might try

QT4_WRAP_CPP(not2compile ...)
ADD_CUSTOM_TARGET(mocem DEPENDS ${not2compile})
ADD_DEPENDENCIES(... mocem)

but I haven't tested this.

Regards,

Michael
--

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


Re: [CMake] Forcibly run 'moc' on Qt files that are NOT part of the build

2012-03-07 Thread Michael Jackson

On Mar 7, 2012, at 10:50 AM, Michael Hertling wrote:

 On 03/07/2012 04:10 PM, Michael Jackson wrote:
 In an effort to speed up the build of a project that uses Qt (and moc) I 
 tried an alternate approach with the moc files. Normally I use the basic 
 idea of gathering the headers that need to be moc'ed and feed those to moc 
 with this type of CMake Code:
 
 QT4_WRAP_CPP( FilterWidgets_Generated_MOC_SRCS ${QFilterWidget_HDRS} 
 ${FilterWidget_GEN_HDRS}) 
 
 The in the Add_Executable(...) call include the 
 ${FilterWidgets_Generated_MOC_SRCS} variable to the list of sources. In my 
 project I have at least 30 auto-generated files which all get moc'ed. That 
 gives me an additional 60 compiled files. So I tried the idea of #include 
 moc_[some_file.cxx] in each of the auto-generated .cpp files for each 
 Widget. This would cut the number of files compiled in half. The issue is 
 that since they are being #include'ed in the .cpp files then they do NOT 
 need to be compiled themselves so I took the 
 ${FilterWidgets_Generated_MOC_SRCS} out of the list of sources in the 
 add_executable() call. What happened is that CMake did NOT run moc on those 
 headers because there were now NOT included in the build.
 
 So for that version of the cmake code I have something like this:
 
 QT4_WRAP_CPP( FilterWidgets_Generated_MOC_SRCS ${FilterWidget_GEN_HDRS}) 
 QT4_WRAP_CPP( FilterWidgets_MOC_SRCS ${QFilterWidget_HDRS} )
 
 Is there a way to forcibly run the moc step even if the resulting source 
 files are NOT directly included in the add_executable? Custom_Command? 
 Add_Depends?
 
 AFAIK, the QT4_WRAP_CPP() macro is essentially a wrapper around ADD_
 CUSTOM_COMMAND() which accumulates the latter's OUTPUT files in the
 former's first parameter. Thus, you might try
 
 QT4_WRAP_CPP(not2compile ...)
 ADD_CUSTOM_TARGET(mocem DEPENDS ${not2compile})
 ADD_DEPENDENCIES(... mocem)
 
 but I haven't tested this.
 
 Regards,
 
 Michael
 --

I would have to say that I didn't dig into the QT4_WRAP_CPP macro at all. If I 
had I would have probably answered my own question. I will give you idea a shot 
and report back if it works or not. Thanks for the idea.

--
Mike J. 
--

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


Re: [CMake] Forcibly run 'moc' on Qt files that are NOT part of the build

2012-03-07 Thread John Drescher
 I would have to say that I didn't dig into the QT4_WRAP_CPP macro at all. If 
 I had I would have probably answered my own question. I will give you idea a 
 shot and report back if it works or not. Thanks for the idea.


Please do so. I would be very interested in your findings on this one..

John
--

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


Re: [CMake] Forcibly run 'moc' on Qt files that are NOT part of the build

2012-03-07 Thread Andreas Pakulat
On 07.03.12 10:10:27, Michael Jackson wrote:
 In an effort to speed up the build of a project that uses Qt (and moc) I 
 tried an alternate approach with the moc files. Normally I use the basic idea 
 of gathering the headers that need to be moc'ed and feed those to moc with 
 this type of CMake Code:
 
 QT4_WRAP_CPP( FilterWidgets_Generated_MOC_SRCS ${QFilterWidget_HDRS} 
 ${FilterWidget_GEN_HDRS}) 
 
 The in the Add_Executable(...) call include the 
 ${FilterWidgets_Generated_MOC_SRCS} variable to the list of sources. In my 
 project I have at least 30 auto-generated files which all get moc'ed. That 
 gives me an additional 60 compiled files. So I tried the idea of #include 
 moc_[some_file.cxx] in each of the auto-generated .cpp files for each 
 Widget. This would cut the number of files compiled in half. The issue is 
 that since they are being #include'ed in the .cpp files then they do NOT need 
 to be compiled themselves so I took the ${FilterWidgets_Generated_MOC_SRCS} 
 out of the list of sources in the add_executable() call. What happened is 
 that CMake did NOT run moc on those headers because there were now NOT 
 included in the build.
 
  So for that version of the cmake code I have something like this:
 
 QT4_WRAP_CPP( FilterWidgets_Generated_MOC_SRCS ${FilterWidget_GEN_HDRS}) 
 QT4_WRAP_CPP( FilterWidgets_MOC_SRCS ${QFilterWidget_HDRS} )
 
 Is there a way to forcibly run the moc step even if the resulting source 
 files are NOT directly included in the add_executable? Custom_Command? 
 Add_Depends?

A few options I can think of:

- Use the automoc developed as part of KDE (its pure-Qt though)
https://projects.kde.org/projects/kdesupport/automoc/repository
- Use the automoc function from FindQt4.cmake
- Use the new automoc function in CMake 2.8.7

All of these will help handle the qt4_wrap_cpp stuff for you as long as
you have the #include. Note that I think there's at least 2 or 3
differnet filenames for the include depending on which of the above you
use (foo.moc vs moc_foo.cpp vs. moc_foo.cxx or something like that).

If none of them is an option for you then I guess using
add_custom_target and add_dependencies is the way to go.

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


Re: [CMake] Forcibly run 'moc' on Qt files that are NOT part of the build

2012-03-07 Thread Michael Wild
On 03/07/2012 04:10 PM, Michael Jackson wrote:
 In an effort to speed up the build of a project that uses Qt (and moc) I 
 tried an alternate approach with the moc files. Normally I use the basic idea 
 of gathering the headers that need to be moc'ed and feed those to moc with 
 this type of CMake Code:
 
 QT4_WRAP_CPP( FilterWidgets_Generated_MOC_SRCS ${QFilterWidget_HDRS} 
 ${FilterWidget_GEN_HDRS}) 
 
 The in the Add_Executable(...) call include the 
 ${FilterWidgets_Generated_MOC_SRCS} variable to the list of sources. In my 
 project I have at least 30 auto-generated files which all get moc'ed. That 
 gives me an additional 60 compiled files. So I tried the idea of #include 
 moc_[some_file.cxx] in each of the auto-generated .cpp files for each 
 Widget. This would cut the number of files compiled in half. The issue is 
 that since they are being #include'ed in the .cpp files then they do NOT need 
 to be compiled themselves so I took the ${FilterWidgets_Generated_MOC_SRCS} 
 out of the list of sources in the add_executable() call. What happened is 
 that CMake did NOT run moc on those headers because there were now NOT 
 included in the build.
 
  So for that version of the cmake code I have something like this:
 
 QT4_WRAP_CPP( FilterWidgets_Generated_MOC_SRCS ${FilterWidget_GEN_HDRS}) 
 QT4_WRAP_CPP( FilterWidgets_MOC_SRCS ${QFilterWidget_HDRS} )
 
 Is there a way to forcibly run the moc step even if the resulting source 
 files are NOT directly included in the add_executable? Custom_Command? 
 Add_Depends?
 
 Thanks

You could still add them to the add_executable() call, but set their
HEADER_FILE_ONLY source file property to TRUE to prevent them from being
compiled. This way they would still show up in the proper place in
IDE's, and no need for fiddling around with add_custom_target() and
add_dependencies(). Of course, you might still want to introduce the
custom target for convenience so you can trigger moc'ing manually (e.g.
make moc)...

Michael

--

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


Re: [CMake] Forcibly run 'moc' on Qt files that are NOT part of the build

2012-03-07 Thread Michael Jackson

On Mar 7, 2012, at 12:05 PM, Michael Wild wrote:

 On 03/07/2012 04:10 PM, Michael Jackson wrote:
 In an effort to speed up the build of a project that uses Qt (and moc) I 
 tried an alternate approach with the moc files. Normally I use the basic 
 idea of gathering the headers that need to be moc'ed and feed those to moc 
 with this type of CMake Code:
 
 QT4_WRAP_CPP( FilterWidgets_Generated_MOC_SRCS ${QFilterWidget_HDRS} 
 ${FilterWidget_GEN_HDRS}) 
 
 The in the Add_Executable(...) call include the 
 ${FilterWidgets_Generated_MOC_SRCS} variable to the list of sources. In my 
 project I have at least 30 auto-generated files which all get moc'ed. That 
 gives me an additional 60 compiled files. So I tried the idea of #include 
 moc_[some_file.cxx] in each of the auto-generated .cpp files for each 
 Widget. This would cut the number of files compiled in half. The issue is 
 that since they are being #include'ed in the .cpp files then they do NOT 
 need to be compiled themselves so I took the 
 ${FilterWidgets_Generated_MOC_SRCS} out of the list of sources in the 
 add_executable() call. What happened is that CMake did NOT run moc on those 
 headers because there were now NOT included in the build.
 
 So for that version of the cmake code I have something like this:
 
 QT4_WRAP_CPP( FilterWidgets_Generated_MOC_SRCS ${FilterWidget_GEN_HDRS}) 
 QT4_WRAP_CPP( FilterWidgets_MOC_SRCS ${QFilterWidget_HDRS} )
 
 Is there a way to forcibly run the moc step even if the resulting source 
 files are NOT directly included in the add_executable? Custom_Command? 
 Add_Depends?
 
 Thanks
 
 You could still add them to the add_executable() call, but set their
 HEADER_FILE_ONLY source file property to TRUE to prevent them from being
 compiled. This way they would still show up in the proper place in
 IDE's, and no need for fiddling around with add_custom_target() and
 add_dependencies(). Of course, you might still want to introduce the
 custom target for convenience so you can trigger moc'ing manually (e.g.
 make moc)...
 
 Michael
 
 --


Thanks to everyone (Michael and Andreas) for the suggestions. Both suggestions 
have their pros and cons. I am leaning towards the Use the new automoc 
function in CMake 2.8.7 that Andreas suggested. I don't have to worry about 
the CMake version since there are only 2 developers. We can upgrade to the 
latest CMake without a problem.
  Actually NOT having them listed in the IDE is BETTER for me since I tread 
those files as black boxes, ie, I don't really want to know what is in them. 
Or at least on a very rare occasion at which point I can just search for the 
file in the build directory.

Thanks again Everyone. I'll post in the next few days what I ended up doing.
--
Mike J. 
--

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