Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • CMake CMake
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 4.2k
    • Issues 4.2k
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 11
    • Merge requests 11
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMakeCMake
  • CMakeCMake
  • Issues
  • #19058
Closed
Open
Issue created Mar 18, 2019 by alcroito@alcroitoDeveloper

Automoc doesn't scan for modifications of dependent include headers

Example:

  • Have a foo.cpp file that includes foo.h that includes bar.h
  • Have foo.cpp #include "foo.moc"
  • Have bar.h have a #define MY_FEATURE
  • Have a slot definition my_feature_func() #ifdef'ed behind MY_FEATURE
  • Have automoc enabled.

If you build the project, then comment out the #define in bar.h and rebuild the project, automoc does not rerun moc on foo.cpp, and you end up with a build error:

/.../projects/test_cmake_automoc_scanning/build/myapp_autogen/include/foo.moc:70:21: error: no member named 'my_feature_func' in 'Foo'
        case 0: _t->my_feature_func(); break;

because the generated moc cpp file has a reference to a now non-existing slot.

This happens because automoc does not extract dependencies from the preprocessed foo.cpp file, as mentioned also here #17750 (comment 377396)

Proposal:

Instead of running the preprocessor on the generated foo.moc or foo.cpp a second time, CMake should presumably already know all header dependencies for foo.cpp, because it's a regular cpp file that has to be compiled.

As such, there probably is a mapping from foo.moc to foo.cpp, so we should be able to simply transfer / append the dependencies of foo.cpp to foo.moc, so that AUTOMOC can regenerate foo.moc if it sees that a dependency header has changed.

The same should be possible for the mocs_compilation.cpp aggregate case.

Would such a patch be accepted?

If there are concerns about performance due to having to check the timestamp on many headers each time make is invoked, perhaps we can make this an opt-in option via a new property?

Relevant downstream issue for the Qt CMake port: https://bugreports.qt.io/browse/QTBUG-74521

Sample project attached. Steps to reproduce: 1) Build project, 2) comment out define in bar.h 3) rebuild project Archive.zip

Edited Mar 18, 2019 by alcroito
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking