@@ -32,6 +32,7 @@ assert(toolchain_is_ok "The toolchain is unable to build a dummy C file. See CMa
3232set (CMAKE_EXECUTABLE_SUFFIX .elf)
3333set (ZEPHYR_PREBUILT_EXECUTABLE zephyr_prebuilt)
3434
35+ # Set some phony targets to collect dependencies
3536set (OFFSETS_H_TARGET offsets_h)
3637set (SYSCALL_MACROS_H_TARGET syscall_macros_h_target)
3738set (SYSCALL_LIST_H_TARGET syscall_list_h_target)
@@ -407,7 +408,7 @@ endif()
407408
408409configure_file (version .h.in ${PROJECT_BINARY_DIR} /include /generated /version .h)
409410
410- function (construct_add_custom_command_for_linker_pass linker_output_name output_variable )
411+ macro (construct_add_custom_command_for_linker_pass linker_output_name )
411412 set (extra_dependencies ${ARGN} )
412413 set (linker_cmd_file_name ${linker_output_name} .cmd)
413414
@@ -439,7 +440,9 @@ function(construct_add_custom_command_for_linker_pass linker_output_name output_
439440 get_filename_component (base_name ${CMAKE_CURRENT_BINARY_DIR} NAME )
440441 get_property (current_defines GLOBAL PROPERTY PROPERTY_LINKER_SCRIPT_DEFINES)
441442
442- set (${output_variable}
443+ # Run $LINKER_SCRIPT through the C preprocessor, producing $linker_cmd_file_name
444+
445+ add_custom_command (
443446 OUTPUT ${linker_cmd_file_name}
444447 DEPENDS
445448 ${LINKER_SCRIPT}
@@ -458,10 +461,8 @@ function(construct_add_custom_command_for_linker_pass linker_output_name output_
458461 -o ${linker_cmd_file_name}
459462 VERBATIM
460463 WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
461-
462- PARENT_SCOPE
463- )
464- endfunction ()
464+ )
465+ endmacro ()
465466
466467# Error-out when the deprecated naming convention is found (until
467468# after 1.14.0 has been released)
@@ -732,15 +733,11 @@ endif() # CONFIG_CODE_DATA_RELOCATION
732733
733734construct_add_custom_command_for_linker_pass(
734735 linker
735- custom_command
736736 ${PRIV_STACK_DEP}
737737 ${APP_SMEM_ALIGNED_DEP}
738738 ${CODE_RELOCATION_DEP}
739739 ${OFFSETS_H_TARGET}
740740 )
741- add_custom_command (
742- ${custom_command}
743- )
744741
745742add_custom_target (
746743 ${LINKER_SCRIPT_TARGET}
@@ -1164,15 +1161,11 @@ if(CONFIG_USERSPACE)
11641161
11651162 construct_add_custom_command_for_linker_pass(
11661163 linker_app_smem_unaligned
1167- custom_command
11681164 ${CODE_RELOCATION_DEP}
11691165 ${APP_SMEM_UNALIGNED_DEP}
11701166 ${APP_SMEM_UNALIGNED_LD}
11711167 ${OFFSETS_H_TARGET}
11721168 )
1173- add_custom_command (
1174- ${custom_command}
1175- )
11761169
11771170 add_custom_target (
11781171 linker_app_smem_unaligned_script
@@ -1212,15 +1205,11 @@ endif()
12121205if (CONFIG_USERSPACE AND CONFIG_ARM)
12131206 construct_add_custom_command_for_linker_pass(
12141207 linker_priv_stacks
1215- custom_command
12161208 ${CODE_RELOCATION_DEP}
12171209 ${APP_SMEM_ALIGNED_DEP}
12181210 ${APP_SMEM_ALIGNED_LD}
12191211 ${OFFSETS_H_TARGET}
12201212 )
1221- add_custom_command (
1222- ${custom_command}
1223- )
12241213
12251214 add_custom_target (
12261215 linker_priv_stacks_script
@@ -1262,15 +1251,11 @@ else()
12621251 # file and preprocessed with the define LINKER_PASS2.
12631252 construct_add_custom_command_for_linker_pass(
12641253 linker_pass_final
1265- custom_command
12661254 ${PRIV_STACK_DEP}
12671255 ${CODE_RELOCATION_DEP}
12681256 ${ZEPHYR_PREBUILT_EXECUTABLE}
12691257 ${OFFSETS_H_TARGET}
12701258 )
1271- add_custom_command (
1272- ${custom_command}
1273- )
12741259
12751260 set (LINKER_PASS_FINAL_SCRIPT_TARGET linker_pass_final_script_target)
12761261 add_custom_target (
0 commit comments