Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explicit moc includes to sources for moc-covered headers #704

Closed
wants to merge 1 commit into from

Conversation

Montel
Copy link
Contributor

@Montel Montel commented Oct 23, 2023

  • speeds up incremental builds as changes to a header will not always need the full mocs_compilation.cpp for all the target's headers rebuild, while having a moc file sourced into a source file only adds minor extra costs, due to small own code and the used headers usually already covered by the source file, being for the same class/struct
  • seems to not slow down clean builds, due to empty mocs_compilation.cpp resulting in those quickly processed, while the minor extra cost of the sourced moc files does not outweigh that in summary. Measured times actually improved by some percent points. (ideally CMake would just skip empty mocs_compilation.cpp & its object file one day)
  • enables compiler to see all methods of a class in same compilation unit to do some sanity checks
  • potentially more inlining in general, due to more in the compilation unit
  • allows to keep using more forward declarations in the header, as with the moc code being sourced into the cpp file there definitions can be ensured and often are already for the needs of the normal class methods

* speeds up incremental builds as changes to a header will not always
  need the full mocs_compilation.cpp for all the target's headers rebuild,
  while having a moc file sourced into a source file only adds minor
  extra costs, due to small own code and the used headers usually
  already covered by the source file, being for the same class/struct
* seems to not slow down clean builds, due to empty mocs_compilation.cpp
  resulting in those quickly processed, while the minor extra cost of the
  sourced moc files does not outweigh that in summary.
  Measured times actually improved by some percent points.
  (ideally CMake would just skip empty mocs_compilation.cpp & its object
  file one day)
* enables compiler to see all methods of a class in same compilation unit
  to do some sanity checks
* potentially more inlining in general, due to more in the compilation unit
* allows to keep using more forward declarations in the header, as with the
  moc code being sourced into the cpp file there definitions can be ensured
  and often are already for the needs of the normal class methods
@Montel Montel requested a review from ahayzen-kdab October 23, 2023 08:53
@Montel Montel self-assigned this Oct 23, 2023
@@ -20,3 +20,5 @@ MyObject::MyObject(QObject* parent)
, ::rust::cxxqtlib1::CxxQtLocking()
{
}

#include "moc_inheritance.cpp"
Copy link
Collaborator

@ahayzen-kdab ahayzen-kdab Oct 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note these files are just test outputs for the test inputs. Eg the expected C++ output for the given C++ input. (these ones aren't actually compiled)

Should these have explicit moc includes ? As we would then need to add this to the generation phase which then needs to know the resultant file name.

Or should these be added to the cxx-qt-lib sources instead ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I didn't know that it was not compiled.

@LeonMatthesKDAB
Copy link
Collaborator

If I understand the previous discussion correctly, this can be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants