1

So I have a Q_OBJECT tagged class, which requires pregenerated .moc to be usable.

In my .qbs file, I have a CppApplication item; this seems to be the wrong type of project, as qbs does not call moc ClassName.cpp to generate moc's for me. What should be used instead/tweaked?

-

So I knew about Qt.core dependency, but it wasn't working on my crippled install of Qt; while I was trying to fix it, these facts came up:

  • It was required to detect Qt toolchain (qbs-setup-qt) and call qbs-config-ui
  • Qbs indeed stores the build rules in core.qbs, linked in via Qt/core dependency.
    • it's possible to copy/paste the build rules into my own .qbs file and avoid external dependencies; I'm considering this as a dirty hack for deploying the code on really crippled build systems (now I have a word for Qt support on Gentoo).
Jake Petroules
  • 23,472
  • 35
  • 144
  • 225
kagali-san
  • 2,964
  • 7
  • 48
  • 87

1 Answers1

2

I think you might be missing the dependency of the application on the Qt-modules. The rule for generation of the moc files is part of the Qt.core module. You might add this dependency with:

CppApplication {
    name: "MyApp"
    files: "path_to_source/**"

    Depends { name: "Qt.core" } // Optional
    Depends { name: "Qt.widgets" }
}

As all other Qt modules have an implicit dependency on Qt.core the explicit dependency could on Qt.core could be skipped if there is a dependency on a different Qt-module (Qt.widgets in this example).

More details could be found at http://doc.qt.io/qbs/qt-modules.html

Jake Petroules
  • 23,472
  • 35
  • 144
  • 225
Johannes Matokic
  • 892
  • 8
  • 15
  • Ok, I've thought that the QBS actions are "hardcoded" - e.g. if it knows a C++ profile already and knows how to compile .cpp, why shouldn't it know about .moc,.rcc etc? After examining core.qbs, problem was solved in dirty way (copying rules/transforms to my .qbs), then repaired in "mainstream" way. – kagali-san Aug 11 '14 at 13:44
  • QBS has no hardcoded support for C++ etc. C++ Support is provided by the "cpp" module. The coresponding `Depends { name: "cpp" }` is already included in CppApplication which is a predefined specialization of the more general Application product-type which does not "know" how to compile C++ out of the box. – Johannes Matokic Aug 21 '14 at 09:15
  • The profiles are just used to provide the modules with standard paths, paths to the tools and some information about what those tools are. This is used by the modules to generate the right command line. – Johannes Matokic Aug 21 '14 at 09:16