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,289
    • Issues 3,289
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 11
    • Merge Requests 11
  • 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
  • #19947

Closed
Open
Created Nov 08, 2019 by Craig Scott@craig.scottMaintainer

Unity builds don't allow adding the same source file to two or more targets

The internal implementation of the unity build feature sets the HEADER_FILE_ONLY source file property to true for each source file it incorporates into a unity build. If such source files are added to more than one target, only the first target gets the source included and the other targets miss out. A modified version of the same test case as used in #19946 (closed) demonstrates the problem:

cmake_minimum_required(VERSION 3.16)
project(unitybuild)

set(CMAKE_UNITY_BUILD YES)
add_library(checker ok1.cpp ok2.cpp)
add_library(anotherTarget ok1.cpp ok2.cpp)  # This target ends up with no sources

This probably isn't a show-stopper for the CMake 3.16.0 release, but it does highlight a limitation of the current implementation which will affect some projects (e.g. those that build multiple variants of the same source file with different flags set at the target level).

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