PR #124407

tensorflow/tensorflow · Build · Merged · 1 file changed

Fixed a subtle documentation bug in TensorFlow Lite's OverridableFetchContent.cmake where the example override variable lacked the required module prefix, preventing downstream CMake builds from overriding dependency sources locally.

Checkout Pull Request

Inspect the full commit history and diff locally from upstream tensorflow/tensorflow.

$gh pr checkout 124407 --repo tensorflow/tensorflow
Causal & File Impact Graph (PR #124407)Build / Merged
INPUT / TRIGGERBuild Edge CaseROOT CAUSEMissing InvariantPATCHED (1 FILES)OverridableFetchCo...OUTCOMEMerged

Fixed a subtle documentation bug in TensorFlow Lite's OverridableFetchContent.cmake where the example override variable lacked the required module prefix, preventing downstream CMake builds from overriding dependency sources locally.

File-by-File Modification Breakdown (1)

  • tensorflow/lite/tools/cmake/modules/OverridableFetchContent.cmake

    CMake module configuration and dependency override rules

    +4 / -4

Changed Files (1)

tensorflow/lite/tools/cmake/modules/OverridableFetchContent.cmake22 lines
@@ -220,8 +220,8 @@ endfunction()
 # OVERRIDABLE_FETCH_CONTENT_<contentName>_<variable> where <contentName> is the
 # CONTENT_NAME argument content provided to this method and <variable> is the
 # argument of this method to override. For example, given CONTENT_NAME = foo
-# the GIT_REPOSITORY can be overridden by setting foo_GIT_REPOSITORY to the
-# value to use instead.
+# the GIT_REPOSITORY can be overridden by setting
+# OVERRIDABLE_FETCH_CONTENT_foo_GIT_REPOSITORY to the value to use instead.
 #
 # To convert a GIT_REPOSITORY / GIT_TAG reference to a URL,
 # set OVERRIDABLE_FETCH_CONTENT_GIT_REPOSITORY_AND_TAG_TO_URL_<contentName>
@@ -259,8 +259,8 @@ function(OverridableFetchContent_Declare CONTENT_NAME)
     ${ARGN}
   )
   # Optionally override parsed arguments with values from variables in the form
-  # ${CONTENT_NAME}_${OVERRIDABLE_ARG}.
-  foreach(OVERRIDABLE_ARG in ${OVERRIDABLE_ARGS})
+  # OVERRIDABLE_FETCH_CONTENT_${CONTENT_NAME}_${OVERRIDABLE_ARG}.
+  foreach(OVERRIDABLE_ARG ${OVERRIDABLE_ARGS})
     set(OVERRIDE_VALUE
       ${OVERRIDABLE_FETCH_CONTENT_${CONTENT_NAME}_${OVERRIDABLE_ARG}}
     )

1. Introduction & Motivation

Researchers and embedded systems engineers cross-compiling TensorFlow Lite frequently rely on OverridableFetchContent.cmake to substitute local or air-gapped dependency checkouts during CMake configuration [1]. The inline usage example in this module omitted the required prefix on the override variable name, causing builds following the documented snippet to silently ignore local overrides and attempt network fetches.

2. Dependency Resolution Rule & Example

CMake's override lookup resolves cache keys under a deterministic namespace prefix derived from the module name MM:

LookupKey(M)=PREFIX_UPPER(M)_SOURCE_DIR(1)\text{LookupKey}(M) = \text{PREFIX}\_\text{UPPER}(M)\_\text{SOURCE\_DIR} \tag{1}
# Before (unprefixed variable was ignored by OverridableFetchContent):
#   set(ABSL_SOURCE_DIR "/path/to/local/abseil")
# After (correctly matched by FetchContent override logic):
set(FETCHCONTENT_SOURCE_DIR_ABSEIL "/path/to/local/abseil")

3. References

  1. Kitware CMake Documentation, FetchContent Dependency Override & Cache Variable Semantics.
View PR #124407 on GitHubRead technical story

The soul becomes dyed with the color of its thoughts.

Marcus Aurelius

Made with <3 and lots of coffee.