Skip to content

Commit b7861b9

Browse files
committed
cmake: move host-tool loading from Zephyr-sdk into COMPONENTS
Move loading of Zephyr-sdk host tools cmake file from Zephyr into Zephyr SDK itself. This allows us to cleanup Zephyr CMake code as well as place the responsibility of checking and loading host tools when available. This removes the need for custom printing as CMake find_package() provides this functionality built-in, as well as ensuring uniform message formatting and general package handling. It further remove the confusing message: > -- Found host-tools: zephyr 0.15.0 (/opt/zephyr-sdk-0.15.0) which is printed even when host tools are not installed. Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
1 parent 8c1efa8 commit b7861b9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cmake/modules/FindZephyr-sdk.cmake

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ if(("zephyr" STREQUAL ${ZEPHYR_TOOLCHAIN_VARIANT}) OR
5959
set(ZEPHYR_CURRENT_TOOLCHAIN_VARIANT ${ZEPHYR_TOOLCHAIN_VARIANT})
6060
find_package(Zephyr-sdk ${Zephyr-sdk_FIND_VERSION}
6161
REQUIRED QUIET CONFIG HINTS ${ZEPHYR_SDK_INSTALL_DIR}
62+
COMPONENTS HostTools
6263
)
6364
if(DEFINED ZEPHYR_CURRENT_TOOLCHAIN_VARIANT)
6465
set(ZEPHYR_TOOLCHAIN_VARIANT ${ZEPHYR_CURRENT_TOOLCHAIN_VARIANT})
@@ -71,7 +72,9 @@ if(("zephyr" STREQUAL ${ZEPHYR_TOOLCHAIN_VARIANT}) OR
7172
$ENV{HOME}
7273
$ENV{HOME}/.local
7374
$ENV{HOME}/.local/opt
74-
$ENV{HOME}/bin)
75+
$ENV{HOME}/bin
76+
COMPONENTS HostTools
77+
)
7578
endif()
7679

7780
SET(CMAKE_FIND_PACKAGE_SORT_DIRECTION ${CMAKE_FIND_PACKAGE_SORT_DIRECTION_CURRENT})
@@ -83,7 +86,8 @@ if(DEFINED ZEPHYR_SDK_INSTALL_DIR)
8386
set(ZEPHYR_SDK_INSTALL_DIR ${ZEPHYR_SDK_INSTALL_DIR} CACHE PATH "Zephyr SDK install directory")
8487
endif()
8588

86-
if(Zephyr-sdk_FOUND)
89+
if(Zephyr-sdk_FOUND AND Zephyr-sdk_VERSION VERSION_LESS_EQUAL 0.15.0)
90+
# Older Zephyr SDKs doesn't support COMPONENT HostTools so must manually be loaded.
8791
include(${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr/host-tools.cmake)
8892

8993
message(STATUS "Found host-tools: zephyr ${SDK_VERSION} (${ZEPHYR_SDK_INSTALL_DIR})")

0 commit comments

Comments
 (0)