Commit 407b49b3 authored by Torsten Rasmussen's avatar Torsten Rasmussen Committed by Carles Cufi
Browse files

cmake: use find_package to locate Zephyr



Using find_package to locate Zephyr.

Old behavior was to use $ENV{ZEPHYR_BASE} for inclusion of boiler plate
code.

Whenever an automatic run of CMake happend by the build system / IDE
then it was required that ZEPHYR_BASE was defined.
Using ZEPHYR_BASE only to locate the Zephyr package allows CMake to
cache the base variable and thus allowing subsequent invocation even
if ZEPHYR_BASE is not set in the environment.

It also removes the risk of strange build results if a user switchs
between different Zephyr based project folders and forgetting to reset
ZEPHYR_BASE before running ninja / make.

Signed-off-by: default avatarTorsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
parent 8829e823
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@

cmake_minimum_required(VERSION 3.13.1)

include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
project(test_relocation)

FILE(GLOB app_sources src/*.c)
+1 −1
Original line number Diff line number Diff line
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.13.1)
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
project(external_lib)

target_sources(app PRIVATE src/main.c)
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ set(BOARD_ROOT ${CMAKE_CURRENT_LIST_DIR})
# this board.
set(BOARD nrf52840dk_nrf52840)

include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
project(out_of_tree_board)

target_sources(app PRIVATE src/main.c)
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ cmake_minimum_required(VERSION 3.13.1)
# be able to find the module's syscalls.
list(APPEND SYSCALL_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/hello_world_module/zephyr)

include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
project(NONE)

target_sources(app PRIVATE
+1 −1
Original line number Diff line number Diff line
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.13.1)
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
project(blink_led)

target_sources(app PRIVATE src/main.c)
Loading