Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
CMake
CMake
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,295
    • Issues 3,295
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 7
    • Merge Requests 7
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • External Wiki
    • External Wiki
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMake
  • CMakeCMake
  • Issues
  • #19807

Closed
Open
Created Oct 07, 2019 by Stephen Kelly@steveireDeveloper

`CMAKE_AUTOMOC` creates `_autogen` targets for targets which do not need it

CMAKE_AUTOMOC is provided for convenience to avoid the need to set the AUTOMOC property on all/most targets. Similar for the other Qt generator features.

CMake creates _autogen targets for every target with the AUTOMOC property set. In projects with a mix of Qt-dependent and non-Qt-dependent targets, this means that setting CMAKE_AUTOMOC ON clutters up IDEs with nearly-empty "moc_compilations.cpp" files, and creates extra steps in Ninja projects which do almost nothing (and which do nothing useful).

IIRC, CMake searches for Q_OBJECT etc at build time or at CMake time, so it does not know that a target source files does not use the macros and does not need to have a corresponding _autogen target.

However, CMake does know whether a target depends transitively on Qt5::Core, Qt4::QtCore etc targets. Some projects still use variables instead of imported targets, but a setting or policy could be introduced which would cause CMake to exclude the _autogen targets for targets which do not depend on Qt imported targets.

Edited Oct 07, 2019 by Stephen Kelly
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None