Skip to content

Commit 8882ca7

Browse files
mbolivar-nordicSebastianBoe
authored andcommitted
cmake: make ZEPHYR_(INTERFACE_)LIBS target properties
Move them to ZEPHYR_TARGET instead of using globals. Signed-off-by: Marti Bolivar <[email protected]>
1 parent 30527e8 commit 8882ca7

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ May include mmu tables, etc."
9090
set_target_properties(${ZEPHYR_TARGET} PROPERTIES GENERATED_KERNEL_OBJECT_FILES "")
9191

9292

93+
define_property(TARGET PROPERTY ZEPHYR_INTERFACE_LIBS
94+
BRIEF_DOCS "Global list of all Zephyr interface libs that should be linked in."
95+
FULL_DOCS "Global list of all Zephyr interface libs that should be linked in.
96+
zephyr_interface_library_named() appends libs to this list.")
97+
set_target_properties(${ZEPHYR_TARGET} PROPERTIES ZEPHYR_INTERFACE_LIBS "")
98+
9399
zephyr_include_directories(
94100
kernel/include
95101
${ARCH_DIR}/${ARCH}/include
@@ -661,7 +667,7 @@ zephyr_get_include_directories_for_lang(C ZEPHYR_INCLUDES)
661667
add_subdirectory(kernel)
662668

663669
# Read list content
664-
get_property(ZEPHYR_LIBS_PROPERTY GLOBAL PROPERTY ZEPHYR_LIBS)
670+
get_target_property(ZEPHYR_LIBS_PROPERTY ${ZEPHYR_TARGET} ZEPHYR_LIBS)
665671

666672
foreach(zephyr_lib ${ZEPHYR_LIBS_PROPERTY})
667673
# TODO: Could this become an INTERFACE property of zephyr_interface?

cmake/app/boilerplate.cmake

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,6 @@ cmake_policy(SET CMP0002 NEW)
2828
# CMP0079: "target_link_libraries() allows use with targets in other directories"
2929
cmake_policy(SET CMP0079 OLD)
3030

31-
define_property(GLOBAL PROPERTY ZEPHYR_LIBS
32-
BRIEF_DOCS "Global list of all Zephyr CMake libs that should be linked in"
33-
FULL_DOCS "Global list of all Zephyr CMake libs that should be linked in.
34-
zephyr_library() appends libs to this list.")
35-
set_property(GLOBAL PROPERTY ZEPHYR_LIBS "")
36-
37-
define_property(GLOBAL PROPERTY ZEPHYR_INTERFACE_LIBS
38-
BRIEF_DOCS "Global list of all Zephyr interface libs that should be linked in."
39-
FULL_DOCS "Global list of all Zephyr interface libs that should be linked in.
40-
zephyr_interface_library_named() appends libs to this list.")
41-
set_property(GLOBAL PROPERTY ZEPHYR_INTERFACE_LIBS "")
42-
4331
set(APPLICATION_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "Application Source Directory")
4432
set(APPLICATION_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "Application Binary Directory")
4533

@@ -539,7 +527,7 @@ add_subdirectory(${ZEPHYR_BASE} ${__build_dir})
539527
# done after 'add_subdirectory(${ZEPHYR_BASE} ${__build_dir})'
540528
# because interface libraries are defined while processing that
541529
# subdirectory.
542-
get_property(ZEPHYR_INTERFACE_LIBS_PROPERTY GLOBAL PROPERTY ZEPHYR_INTERFACE_LIBS)
530+
get_target_property(ZEPHYR_INTERFACE_LIBS_PROPERTY ${ZEPHYR_TARGET} ZEPHYR_INTERFACE_LIBS)
543531
foreach(boilerplate_lib ${ZEPHYR_INTERFACE_LIBS_PROPERTY})
544532
# Linking 'app' with 'boilerplate_lib' causes 'app' to inherit the INTERFACE
545533
# properties of 'boilerplate_lib'. The most common property is 'include

cmake/extensions.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ endfunction()
441441
# constructor but must called explicitly on CMake libraries that do
442442
# not use a zephyr library constructor.
443443
function(zephyr_append_cmake_library library)
444-
set_property(GLOBAL APPEND PROPERTY ZEPHYR_LIBS ${library})
444+
set_property(TARGET "${ZEPHYR_TARGET}" APPEND PROPERTY ZEPHYR_LIBS ${library})
445445
endfunction()
446446

447447
# Add the imported library 'library_name', located at 'library_path' to the
@@ -482,7 +482,7 @@ endfunction()
482482
# does not have wrappers over the other cmake target functions.
483483
macro(zephyr_interface_library_named name)
484484
add_library(${name} INTERFACE)
485-
set_property(GLOBAL APPEND PROPERTY ZEPHYR_INTERFACE_LIBS ${name})
485+
set_property(TARGET ${ZEPHYR_TARGET} APPEND PROPERTY ZEPHYR_INTERFACE_LIBS ${name})
486486
endmacro()
487487

488488
# 1.3 generate_inc_*

0 commit comments

Comments
 (0)