mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
cmake/nuttx_toolchain.cmake: track preprocessed include deps
Make preprocess-generated outputs depend on included files by emitting depfiles for GNU/Clang Ninja/Makefile builds. This fixes stale generated rc.sysinit and ROMFS images when a board-specific included fragment such as rc.sysinit.ap changes, because the previous custom command only depended on the top-level source file. Signed-off-by: Jerry Ma <shichunma@bestechnic.com>
This commit is contained in:
parent
116a325763
commit
0afb8c7ad5
2 changed files with 28 additions and 4 deletions
|
|
@ -42,6 +42,11 @@ if(POLICY CMP0115)
|
|||
cmake_policy(SET CMP0115 NEW)
|
||||
endif()
|
||||
|
||||
if(POLICY CMP0116)
|
||||
# transform DEPFILE paths correctly for Ninja custom commands
|
||||
cmake_policy(SET CMP0116 NEW)
|
||||
endif()
|
||||
|
||||
# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24:
|
||||
|
||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
|
||||
|
|
|
|||
|
|
@ -91,13 +91,32 @@ if(NOT NUTTX_TOOLCHAIN_PREPROCESS_DEFINED)
|
|||
ARGN
|
||||
${ARGN})
|
||||
|
||||
set(depfile_args)
|
||||
set(preprocess_depflags)
|
||||
|
||||
if((CMAKE_GENERATOR MATCHES "Ninja|Makefiles")
|
||||
AND (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES
|
||||
"Clang"))
|
||||
set(preprocess_depfile ${TARGET_FILE}.d)
|
||||
list(
|
||||
APPEND
|
||||
preprocess_depflags
|
||||
-MMD
|
||||
-MT
|
||||
${TARGET_FILE}
|
||||
-MF
|
||||
${preprocess_depfile})
|
||||
list(APPEND depfile_args DEPFILE ${preprocess_depfile})
|
||||
endif()
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${TARGET_FILE}
|
||||
COMMAND
|
||||
${PREPROCESS} ${DEFINES} -I${CMAKE_BINARY_DIR}/include
|
||||
-I${NUTTX_DIR}/include -I${NUTTX_CHIP_ABS_DIR} ${SOURCE_FILE} >
|
||||
${TARGET_FILE}
|
||||
DEPENDS ${SOURCE_FILE} ${DEPENDS})
|
||||
${PREPROCESS} ${DEFINES} ${preprocess_depflags}
|
||||
-I${CMAKE_BINARY_DIR}/include -I${NUTTX_DIR}/include
|
||||
-I${NUTTX_CHIP_ABS_DIR} ${SOURCE_FILE} > ${TARGET_FILE}
|
||||
DEPENDS ${SOURCE_FILE} ${DEPENDS} ${depfile_args}
|
||||
COMMAND_EXPAND_LISTS)
|
||||
|
||||
endfunction()
|
||||
endif()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue