cmake: Add generated files to zephyr_interface dependency target

Fix race condition in build when creating libraries in application and
depending on zephyr_interface.

lib/CMakeLists.txt:

    add_library(lib STATIC src/lib.c)
    zephyr_append_cmake_library(lib)
    target_link_libraries(lib PUBLIC zephyr_interface)

Gives following error message:

  from path/src/lib.c:6:
  zephyr/include/syscall.h:11:10: fatal error: syscall_list.h: \
  	No such file or directory
     11 | #include <syscall_list.h>
        |          ^~~~~~~~~~~~~~~~
  compilation terminated.
  [13/165] Generating include/generated/syscall_dispatch.c, \
  	include/generated/syscall_list.h

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
Joakim Andersson 2020-08-04 18:31:48 +02:00 committed by Kumar Gala
commit d268f82fd1

View file

@ -571,7 +571,7 @@ add_custom_target(${SYSCALL_LIST_H_TARGET} DEPENDS ${syscall_list_h})
add_custom_target(${PARSE_SYSCALLS_TARGET} add_custom_target(${PARSE_SYSCALLS_TARGET}
DEPENDS DEPENDS
${syscalls_json} ${syscalls_json}
${subsys_jsonstruct_tags_json} ${struct_tags_json}
) )
# 64-bit systems do not require special handling of 64-bit system call # 64-bit systems do not require special handling of 64-bit system call
@ -644,7 +644,7 @@ target_include_directories(${OFFSETS_LIB} PRIVATE
${ARCH_DIR}/${ARCH}/include ${ARCH_DIR}/${ARCH}/include
) )
target_link_libraries(${OFFSETS_LIB} zephyr_interface) target_link_libraries(${OFFSETS_LIB} zephyr_interface)
add_dependencies( ${OFFSETS_LIB} add_dependencies(zephyr_interface
${SYSCALL_LIST_H_TARGET} ${SYSCALL_LIST_H_TARGET}
${DRIVER_VALIDATION_H_TARGET} ${DRIVER_VALIDATION_H_TARGET}
${KOBJ_TYPES_H_TARGET} ${KOBJ_TYPES_H_TARGET}