Skip to content

Commit

Permalink
cmake: warn the user if a Zephyr library is created in app-mode
Browse files Browse the repository at this point in the history
Fixes: zephyrproject-rtos#19582

When `find_package(Zephyr)` completes then all boilerplate code has been
processed and all Zephyr libraries has been placed inside the
whole archive flags.

Also all libs dependencies has been processed.

This is indicated by the presence of the zephyr_prebuilt target.

Thus, warn the user if `zephyr_library()` / `zephyr_library_named()`
is called in app-mode.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
  • Loading branch information
tejlmand committed Jun 2, 2021
1 parent 1064f6e commit 2ccb172
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmake/extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,15 @@ endfunction()
# constructor but must called explicitly on CMake libraries that do
# not use a zephyr library constructor.
function(zephyr_append_cmake_library library)
if(TARGET zephyr_prebuilt)
message(WARNING
"zephyr_library() or zephyr_library_named() called in Zephyr CMake "
"application mode. `${library}` will not be treated as a Zephyr library."
"To create a Zephyr library in Zephyr CMake kernel mode consider "
"creating a Zephyr module. See more here: "
"https://docs.zephyrproject.org/latest/guides/modules.html"
)
endif()
set_property(GLOBAL APPEND PROPERTY ZEPHYR_LIBS ${library})
endfunction()

Expand Down

0 comments on commit 2ccb172

Please sign in to comment.