Skip to content

Commit

Permalink
cmake: ld: Ensure that a linker script change triggers a rebuild
Browse files Browse the repository at this point in the history
This fixes
zephyrproject-rtos#5010. CMake has a
simple parser that can parse C-like files to find header
dependencies. But the parser needs to know what the include
directories are to be able to follow #include pragmas.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
  • Loading branch information
SebastianBoe committed Dec 15, 2017
1 parent 7905e2b commit 0ecd533
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion CMakeLists.txt
Expand Up @@ -517,7 +517,20 @@ add_custom_target(
DEPENDS
linker.cmd
offsets_h
)
)

# Give the 'linker_script' target all of the include directories so
# that cmake can successfully find the linker_script's header
# dependencies.
zephyr_get_include_directories_for_lang(C
ZEPHYR_INCLUDE_DIRS
STRIP_PREFIX # Don't use a -I prefix
)
set_property(TARGET
linker_script
PROPERTY INCLUDE_DIRECTORIES
${ZEPHYR_INCLUDE_DIRS}
)

set(zephyr_lnk
${LINKERFLAGPREFIX},-Map=${PROJECT_BINARY_DIR}/${KERNEL_MAP_NAME}
Expand Down Expand Up @@ -709,6 +722,11 @@ if(GKOF OR GKSF)
linker_pass2.cmd
offsets_h
)
set_property(TARGET
linker_pass2_script
PROPERTY INCLUDE_DIRECTORIES
${ZEPHYR_INCLUDE_DIRS}
)

add_executable( kernel_elf misc/empty_file.c ${GKSF})
target_link_libraries(kernel_elf ${GKOF} -T${PROJECT_BINARY_DIR}/linker_pass2.cmd ${zephyr_lnk})
Expand Down

0 comments on commit 0ecd533

Please sign in to comment.