Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • CMake CMake
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,802
    • Issues 3,802
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 18
    • Merge requests 18
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & 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
  • CMake
  • CMakeCMake
  • Issues
  • #20682

Closed
Open
Created May 07, 2020 by Jörg Bornemann@joborDeveloper

AUTOMOC breaks on configuration-dependent source files

The following project

cmake_minimum_required(VERSION 3.17.0)
project(buggetybug)
set(CMAKE_AUTOMOC YES)
find_package(Qt5 COMPONENTS Core)
add_executable(exe main.cpp
    $<$<CONFIG:Debug>:debug_stuff.cpp>
    $<$<CONFIG:Release>:release_stuff.cpp>)

configured with

cmake -G"Ninja Multi-Config" -DCMAKE_PREFIX_PATH=~/Qt/5.14/lib/cmake '-DCMAKE_CONFIGURATION_TYPES=Debug;Release' 

fails with the very surprising error message

CMake Error in CMakeLists.txt:
  Target "exe" has source files which vary by configuration.  This is not
  supported by the "Ninja Multi-Config" generator.

  Config "Debug":

    /home/jobor/dev/personal/multicfgbug/main.cpp
    /home/jobor/dev/personal/multicfgbug/debug_stuff.cpp

  Config "Release":

    /home/jobor/dev/personal/multicfgbug/main.cpp
    /home/jobor/dev/personal/multicfgbug/release_stuff.cpp

The project builds fine if the line

set(CMAKE_AUTOMOC YES)

is removed / commented out.

This apparently happens, because cmQtAutoGenInitializer::InitScanFiles calls cmGeneratorTarget::GetConfigCommonSourceFiles() to gather the target sources, and this function contains a check that yields above error.

Slightly educated guess: Nothing outside of actual generators should call this function, and cmQtAutoGenInitializer must be - somehow - adjusted to gather the source files in some multi-config-compatible way.

I have attached an example project that exhibits the issue: multicfgbug.tar.gz

Edited May 07, 2020 by Brad King
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking