Skip to content
GitLab
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 4,103
    • Issues 4,103
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 14
    • Merge requests 14
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • 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
  • #22096
Closed
Open
Issue created Apr 22, 2021 by Johan Seland@JohanSeland

Post-build events triggers Ninja error for Multi-Config builds

After updating to CMake 3.20.1 the following simple listfile triggers a Ninja error in multi-config builds. This regressed somewhere between 3.19.1 and 3.20.1.

cmake_minimum_required(VERSION 3.19)

project(MultiConfigPostBuildBug)

add_custom_target(customTarget
  COMMAND ${CMAKE_COMMAND} -E echo "I am a custom target"
  COMMENT "I am a comment"
)

# Remove post-build event and customTarget will "build" correctly.
add_custom_command(TARGET customTarget
  POST_BUILD
  COMMAND ${CMAKE_COMMAND} -E echo Post build
)

I have configured the project as follows:

cmake -G"Ninja Multi-Config" -DCMAKE_CONFIGURATION_TYPES=RelWithDebInfo;Debug -DCMAKE_CROSS_CONFIGS=all -DCMAKE_DEFAULT_CONFIGS=all

When running ninja it fails with:

ninja: error: CMakeFiles/impl-RelWithDebInfo.ninja:56: multiple rules generate CMakeFiles/RelWithDebInfo/customTarget.util [-w dupbuild=err]

It can easily be validated that the impl-RelWithDebInfo contains duplicate entries for customTarget.util, which Ninja complains about.

With CMake 3.19 everything works as expected, e.g. nothing happens :)

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