cmake: modules: add generated_file_directories
Due to Hyrum's Law, there are users out in the wild depending on this directory existing to place their own generated files, so it'd break things unnecessarily to not do this if we don't have a DTS, as explained in a source code comment. However, this doesn't really have anything to do with DTS processing, so split it into its own module to separate concerns. This isn't really a CMake module in the usual sense of something that defines functions you can use, and is therefore a form of technical debt. The decision was made to accept this because fixing this is a larger task for the files in cmake/modules/, since there are multiple other examples of this in here. This also paves the way for inserting another module in between the generated_file_directories and dts modules that itself depends on these directories existing. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
parent
977a915c25
commit
53ab5fcf1c
3 changed files with 25 additions and 8 deletions
|
@ -39,14 +39,6 @@ find_package(Dtc 1.4.6)
|
|||
# run the dtc tool if it is found, in order to catch any additional
|
||||
# warnings or errors it generates.
|
||||
|
||||
# We will place some generated include files in here.
|
||||
set(BINARY_DIR_INCLUDE ${PROJECT_BINARY_DIR}/include)
|
||||
set(BINARY_DIR_INCLUDE_GENERATED ${BINARY_DIR_INCLUDE}/generated)
|
||||
# Unconditionally create it, even if we don't have DTS support. This
|
||||
# is a historical artifact, and users expect this directory to exist
|
||||
# to put their own generated content inside.
|
||||
file(MAKE_DIRECTORY ${BINARY_DIR_INCLUDE_GENERATED})
|
||||
|
||||
# The directory containing devicetree related scripts.
|
||||
set(DT_SCRIPTS ${ZEPHYR_BASE}/scripts/dts)
|
||||
|
||||
|
|
24
cmake/modules/generated_file_directories.cmake
Normal file
24
cmake/modules/generated_file_directories.cmake
Normal file
|
@ -0,0 +1,24 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
include_guard(GLOBAL)
|
||||
|
||||
# This file creates locations in the build directory
|
||||
# for placing generated files.
|
||||
#
|
||||
# Outcome:
|
||||
# - BINARY_DIR_INCLUDE is set to ${PROJECT_BINARY_DIR}/include
|
||||
# - BINARY_DIR_INCLUDE_GENERATED is set to ${BINARY_DIR_INCLUDE}/generated
|
||||
# - BINARY_DIR_INCLUDE_GENERATED is a directory
|
||||
#
|
||||
# Required variables:
|
||||
# None
|
||||
#
|
||||
# Optional variables:
|
||||
# None
|
||||
#
|
||||
# Optional environment variables:
|
||||
# None
|
||||
|
||||
set(BINARY_DIR_INCLUDE ${PROJECT_BINARY_DIR}/include/generated)
|
||||
set(BINARY_DIR_INCLUDE_GENERATED ${PROJECT_BINARY_DIR}/include/generated)
|
||||
file(MAKE_DIRECTORY ${BINARY_DIR_INCLUDE_GENERATED})
|
|
@ -84,6 +84,7 @@ list(APPEND zephyr_cmake_modules shields)
|
|||
list(APPEND zephyr_cmake_modules snippets)
|
||||
list(APPEND zephyr_cmake_modules arch)
|
||||
list(APPEND zephyr_cmake_modules configuration_files)
|
||||
list(APPEND zephyr_cmake_modules generated_file_directories)
|
||||
|
||||
# Include board specific device-tree flags before parsing.
|
||||
set(pre_dt_board "\${BOARD_DIR}/pre_dt_board.cmake" OPTIONAL)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue