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,297
    • Issues 3,297
    • 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
  • #19946

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

UNITY_BUILD ignores HEADER_FILE_ONLY source file property

If a source file already has the HEADER_FILE_ONLY source property set to true, that source file should be excluded from the unity build. As of CMake 3.16.0-rc3, this is not the case. A simple demonstrator project that verifies the issue:

CMakeLists.txt:

cmake_minimum_required(VERSION 3.16)
project(unitybuild)

set(CMAKE_UNITY_BUILD YES)
add_library(checker ok1.cpp ok2.cpp notOk.cpp)
set_source_files_properties(notOk.cpp PROPERTIES HEADER_FILE_ONLY TRUE)

ok1.cpp

#define ok1_added 1
int ok1() { return 23; }  // Just to ensure there's something to compile, prevents warnings

ok2.cpp

#define ok2_added 1
int ok2() { return 57; }  // Just to ensure there's something to compile, prevents warnings

notOk.cpp

#if defined(ok1_added) || defined(ok2_added)
#error Was not excluded from unity build
#endif
int notOk() { return 3; }  // Just to ensure there's something to compile, prevents warnings
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
3.16.0
Milestone
3.16.0 (Past due)
Assign milestone
Time tracking
None
Due date
None