diff --git a/cmake/modules/dts.cmake b/cmake/modules/dts.cmake index fd41904e160..24ec436d41c 100644 --- a/cmake/modules/dts.cmake +++ b/cmake/modules/dts.cmake @@ -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) diff --git a/cmake/modules/generated_file_directories.cmake b/cmake/modules/generated_file_directories.cmake new file mode 100644 index 00000000000..aac3b39a6f9 --- /dev/null +++ b/cmake/modules/generated_file_directories.cmake @@ -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}) diff --git a/cmake/modules/zephyr_default.cmake b/cmake/modules/zephyr_default.cmake index 0e41a253dd1..8d651e0b8fe 100644 --- a/cmake/modules/zephyr_default.cmake +++ b/cmake/modules/zephyr_default.cmake @@ -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)