Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions cmake/Zephyr-sdkConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,26 @@ set(SDK_MAJOR_MINOR_MICRO ${SDK_VERSION})
get_filename_component(ZEPHYR_SDK_INSTALL_DIR ${CMAKE_CURRENT_LIST_DIR}/.. ABSOLUTE)
set(ZEPHYR_SDK_INSTALL_DIR ${ZEPHYR_SDK_INSTALL_DIR})

if(NOT DEFINED ZEPHYR_TOOLCHAIN_VARIANT)
set(ZEPHYR_TOOLCHAIN_VARIANT "zephyr/gnu")
# Check and see if the user specified a toolchain
if(DEFINED ZEPHYR_TOOLCHAIN_VARIANT)
# Check and see if the specified toolchain includes a compiler
if(ZEPHYR_TOOLCHAIN_VARIANT MATCHES "^([^/])+/([^/]+)$")
# Replace any existing values with the provided components
set(ZEPHYR_TOOLCHAIN_VARIANT "${CMAKE_MATCH_1}" CACHE STRING "toolchain" FORCE)
set(TOOLCHAIN_VARIANT_COMPILER "${CMAKE_MATCH_2}" CACHE STRING "compiler" FORCE)
endif()
else()
set(ZEPHYR_TOOLCHAIN_VARIANT "zephyr")
endif()

# When using the Zephyr SDK, use the gnu compiler by default
if(ZEPHYR_TOOLCHAIN_VARIANT STREQUAL "zephyr" AND NOT DEFINED TOOLCHAIN_VARIANT_COMPILER)
set(TOOLCHAIN_VARIANT_COMPILER "gnu")
endif()

set(ENV{ZEPHYR_TOOLCHAIN_VARIANT} "${ZEPHYR_TOOLCHAIN_VARIANT}")
set(ENV{TOOLCHAIN_VARIANT_COMPILER} "${TOOLCHAIN_VARIANT_COMPILER}")

# Those are CMake package parameters.
set(Zephyr-sdk_FOUND True)
set(Zephyr-sdk_DIR ${ZEPHYR_SDK_INSTALL_DIR})
Loading