Description
Motivation
Build Impact Analysis
Today, there is no reliable way to answer: "If I change Foo.h, which CMake targets need to rebuild?"
CMake's File API (codemodel-v2) reports source files associated with each target. However, headers
added via install(FILES ...) or glob-based helpers are invisible to the File API — they exist on disk but have no target association in the build graph.
By using FILE_SET HEADERS (CMake 3.23+), every header becomes a first-class source of its target, queryable through the File API.
Selective Builds
With accurate header-to-target mapping, we can build selective build tooling:
- A PR modifies
velox/core/PlanNode.h
- Query the File API →
PlanNode.h belongs to target velox_core
- Build and test only
velox_core and its dependents, instead of the entire project
This significantly reduces CI time for targeted changes.
Approach
-
HEADERS keyword in velox_add_library() — production targets declare their headers explicitly, wired to FILE_SET HEADERS internally.
-
velox_add_test_headers() — lightweight helper for test/benchmark/fuzzer targets using raw add_library()/add_executable().
-
CI enforcement — a check-header-ownership pre-commit hook verifies every .h file under velox/ is referenced in a CMakeLists.txt. New headers without ownership fail CI.
-
Compatibility — VELOX_MONO_LIBRARY mode fully supported. Existing velox_install_library_headers() kept as fallback. No changes to build output or installed artifacts.
Scope
- ~1,287 headers tracked across ~150 CMakeLists.txt files
- ~65 new INTERFACE targets mirroring BUCK's header-only structure
Future Work
- Build selective build tooling consuming the File API data
Related PR: #16897
cc @kgpai @czentgr @majetideepak
Description
Motivation
Build Impact Analysis
Today, there is no reliable way to answer: "If I change
Foo.h, which CMake targets need to rebuild?"CMake's File API (codemodel-v2) reports source files associated with each target. However, headers
added via
install(FILES ...)or glob-based helpers are invisible to the File API — they exist on disk but have no target association in the build graph.By using
FILE_SET HEADERS(CMake 3.23+), every header becomes a first-class source of its target, queryable through the File API.Selective Builds
With accurate header-to-target mapping, we can build selective build tooling:
velox/core/PlanNode.hPlanNode.hbelongs to targetvelox_corevelox_coreand its dependents, instead of the entire projectThis significantly reduces CI time for targeted changes.
Approach
HEADERSkeyword invelox_add_library()— production targets declare their headers explicitly, wired toFILE_SET HEADERSinternally.velox_add_test_headers()— lightweight helper for test/benchmark/fuzzer targets using rawadd_library()/add_executable().CI enforcement — a
check-header-ownershippre-commit hook verifies every.hfile undervelox/is referenced in aCMakeLists.txt. New headers without ownership fail CI.Compatibility —
VELOX_MONO_LIBRARYmode fully supported. Existingvelox_install_library_headers()kept as fallback. No changes to build output or installed artifacts.Scope
Future Work
Related PR: #16897
cc @kgpai @czentgr @majetideepak