Skip to content

Commit

Permalink
sysbuild: create intermediate file for CMakeCache.txt configuration
Browse files Browse the repository at this point in the history
Using `configure_file()` directly on an image's CMakeCache.txt file
creates a sysbuild CMake configure dependency on the image's cache file.

This means that any change to the CMake cache on any image results in a
CMake re-run on all images.

Create an intermediate file for configure_file() to depend upon.
The aligns sysbuild in nRF Connect SDK behavior with Zephyr wrt. image
CMake cache dependencies.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
  • Loading branch information
tejlmand committed Nov 13, 2023
1 parent 552f89d commit c19ee18
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sysbuild/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ function(configure_cache)

ExternalProject_Get_Property(${CONFIGURE_CACHE_IMAGE} BINARY_DIR)

configure_file("${BINARY_DIR}/CMakeCache.txt" "${BINARY_DIR}/CMakeCache.txt.tmp" @ONLY)
# Copy the cache file to avoid a dependency to the image's cache file.
# A dependency on the image's cache file cause unneccessary CMake re-runs for
# all sysbuild images whenever a setting in the cache changes, even for not
# sysbuild relevant changes.
zephyr_file_copy("${BINARY_DIR}/CMakeCache.txt" "${BINARY_DIR}/CMakeCache.tmp" ONLY_IF_DIFFERENT)
configure_file("${BINARY_DIR}/CMakeCache.tmp" "${BINARY_DIR}/CMakeCache.txt.tmp" @ONLY)
zephyr_file_copy("${BINARY_DIR}/CMakeCache.txt.tmp" "${BINARY_DIR}/CMakeCache.txt" ONLY_IF_DIFFERENT)
endfunction()

Expand Down

0 comments on commit c19ee18

Please sign in to comment.