0

I create a project with cmake for Visual Studio 10, using Qt5.4 library. Cmake generates moc files for Qt and integrates these files into my solution.

I would like to find a way to prevent Cmake to integrate the moc files into the solution, coz then they are compiled what is useless I think.

Does it exist a solution to do that ?

I am not writing something like set(moc_mymocfile.cpp) into the CMakeLists.txt file, so I don't understand...

Thanks

Quentin Tealrod
  • 309
  • 3
  • 14
  • What do you mean by "solution"? I don't think you can compile QObjects without the corresponding moc files. They are needed for example when you use signal/slots. – Simon Warta Apr 30 '15 at 13:44
  • Yes actually, you are probably right and I was totally wrong. I mean the Visual Studio Solution. But is it possible to hide them into the solution ? They are all in the same location than my "real" source files, and considering I never open them, I would like to "hide" them in Visual Studio... – Quentin Tealrod Apr 30 '15 at 14:08
  • If this is about Visual Studio details, I am out. But usually you have a different source and build directory. When used with qmake, the moc files are in the build directory together with all the compiled objects where they are not disturbing. – Simon Warta Apr 30 '15 at 14:16
  • I think it's exactly what I want to have : sources & moc files in separated filters inside VS. And considering that Cmake is responsible of the creation of solution (VS project), I hope there exist a special command or option, but I don't find it Thanks for your time – Quentin Tealrod Apr 30 '15 at 14:28
  • Which version of cmake do you use? Writing moc files to the build directory should be the default: *Generated moc_*.cpp and *.moc files are placed in the build directory* http://www.cmake.org/cmake/help/v3.0/manual/cmake-qt.7.html#automoc – Simon Warta Apr 30 '15 at 15:43
  • qmake does what you want. – Hamish Moffatt May 01 '15 at 01:50
  • I am using the 3.2.0 rc2 version. I'm ok with the fact that moc files are generated, placed in the build directory and then compiled, but I am looking for a way to hide them in my visual studio solution, because I have a lot of moc files and I'd like not seeing them – Quentin Tealrod May 04 '15 at 14:28
  • 7 years after, still same problem for me ? did you figure out how to fix that ? – Muby Nov 08 '22 at 03:43

0 Answers0