Skip to content
Permalink
Browse files

CMakeLists.txt: fix misleading logical_target_for_zephyr_elf comment

The comment for:

  set_target_properties(${logical_target_for_zephyr_elf} PROPERTIES
     OUTPUT_NAME ${KERNEL_NAME})

was completely off-topic and making something relatively simple
incredibly puzzling and time-consuming to understand.

Re-order the if(GKSF OR GKOF) clauses so the two initializations of
logical_target_for_zephyr_elf are close to each other and so the very
short clause is not buried at the bottom of the long one.

Other minor logical_target_for_zephyr_elf comment fixes.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
  • Loading branch information...
marc-hb authored and galak committed Apr 17, 2019
1 parent d6d7a80 commit 498b49469a6ca56eeaaa7d403ee8350bb9e71e3d
Showing with 14 additions and 8 deletions.
  1. +14 −8 CMakeLists.txt
@@ -1298,7 +1298,12 @@ set_property(TARGET ${ZEPHYR_PREBUILT_EXECUTABLE} PROPERTY LINK_DEPENDS ${PROJ
add_dependencies( ${ZEPHYR_PREBUILT_EXECUTABLE} ${ALIGN_SIZING_DEP} ${PRIV_STACK_DEP} ${LINKER_SCRIPT_TARGET} ${OFFSETS_LIB})


if(GKOF OR GKSF)
set(generated_kernel_files ${GKSF} ${GKOF})
if(NOT generated_kernel_files)
# Use the prebuilt elf as the final elf since we don't have a
# generation stage.
set(logical_target_for_zephyr_elf ${ZEPHYR_PREBUILT_EXECUTABLE})
else()
set(KERNEL_ELF kernel_elf)
set(logical_target_for_zephyr_elf ${KERNEL_ELF})

@@ -1334,18 +1339,16 @@ if(GKOF OR GKSF)
target_link_libraries(${KERNEL_ELF} ${GKOF} ${TOPT} ${PROJECT_BINARY_DIR}/linker_pass_final.cmd ${zephyr_lnk} ${CODE_RELOCATION_DEP})
set_property(TARGET ${KERNEL_ELF} PROPERTY LINK_DEPENDS ${PROJECT_BINARY_DIR}/linker_pass_final.cmd)
add_dependencies( ${KERNEL_ELF} ${ALIGN_SIZING_DEP} ${PRIV_STACK_DEP} ${LINKER_PASS_FINAL_SCRIPT_TARGET})
else()
set(logical_target_for_zephyr_elf ${ZEPHYR_PREBUILT_EXECUTABLE})
# Use the prebuilt elf as the final elf since we don't have a
# generation stage.
endif()

# Export the variable to the application's scope to allow the
# application to know what the name of the final elf target is.
set(logical_target_for_zephyr_elf ${logical_target_for_zephyr_elf} PARENT_SCOPE)

# To avoid having the same logical target name for the zephyr lib and
# the zephyr elf, we set the kernel_elf file name to zephyr.elf.
# Override the base name of final .elf so:
# 1. it doesn't depend on the number of passes above and the
# post_build_commands below can always find it no matter which is it;
# 2. it can be defined in Kconfig
set_target_properties(${logical_target_for_zephyr_elf} PROPERTIES OUTPUT_NAME ${KERNEL_NAME})

set(post_build_commands "")
@@ -1412,11 +1415,14 @@ list(APPEND
${extra_post_build_commands}
)

# Add post_build_commands to post-process the final .elf file produced by
# either the ZEPHYR_PREBUILT_EXECUTABLE or the KERNEL_ELF executable
# targets above.
add_custom_command(
TARGET ${logical_target_for_zephyr_elf}
POST_BUILD
${post_build_commands}
COMMENT "Generating files from zephyr.elf for board: ${BOARD}"
COMMENT "Generating files from ${KERNEL_ELF_NAME} for board: ${BOARD}"
# NB: COMMENT only works for some CMake-Generators
)

0 comments on commit 498b494

Please sign in to comment.
You can’t perform that action at this time.