Skip to content

Commit 407b49b

Browse files
tejlmandcarlescufi
authored andcommitted
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: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
1 parent 8829e82 commit 407b49b

File tree

491 files changed

+626
-629
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

491 files changed

+626
-629
lines changed

samples/application_development/code_relocation/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
cmake_minimum_required(VERSION 3.13.1)
44

5-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
5+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
66
project(test_relocation)
77

88
FILE(GLOB app_sources src/*.c)

samples/application_development/external_lib/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(external_lib)
66

77
target_sources(app PRIVATE src/main.c)

samples/application_development/out_of_tree_board/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ set(BOARD_ROOT ${CMAKE_CURRENT_LIST_DIR})
1010
# this board.
1111
set(BOARD nrf52840dk_nrf52840)
1212

13-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
13+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
1414
project(out_of_tree_board)
1515

1616
target_sources(app PRIVATE src/main.c)

samples/application_development/out_of_tree_driver/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ cmake_minimum_required(VERSION 3.13.1)
1313
# be able to find the module's syscalls.
1414
list(APPEND SYSCALL_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/hello_world_module/zephyr)
1515

16-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
16+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
1717
project(NONE)
1818

1919
target_sources(app PRIVATE
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(blink_led)
66

77
target_sources(app PRIVATE src/main.c)

samples/basic/blinky/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(blinky)
66

77
target_sources(app PRIVATE src/main.c)

samples/basic/button/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(button)
66

77
target_sources(app PRIVATE src/main.c)

samples/basic/fade_led/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(fade_led)
66

77
target_sources(app PRIVATE src/main.c)

samples/basic/minimal/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
cmake_minimum_required(VERSION 3.13.1)
44

5-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
5+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
66
project(minimal)
77

88
target_sources(app PRIVATE src/main.c)

samples/basic/rgb_led/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(rgb_led)
66

77
target_sources(app PRIVATE src/main.c)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(servo_motor)
66

77
target_sources(app PRIVATE src/main.c)

samples/basic/threads/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(threads)
66

77
target_sources(app PRIVATE src/main.c)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(beacon)
66

77
target_sources(app PRIVATE src/main.c)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(central)
66

77
target_sources(app PRIVATE
88
src/main.c
99
)
1010

11-
zephyr_library_include_directories($ENV{ZEPHYR_BASE}/samples/bluetooth)
11+
zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(central_hr)
66

77
FILE(GLOB app_sources src/*.c)
88
target_sources(app PRIVATE ${app_sources})
99

10-
zephyr_library_include_directories($ENV{ZEPHYR_BASE}/samples/bluetooth)
10+
zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(eddystone)
66

77
target_sources(app PRIVATE
88
src/main.c
99
)
1010

11-
zephyr_library_include_directories($ENV{ZEPHYR_BASE}/samples/bluetooth)
11+
zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(handsfree)
66

77
FILE(GLOB app_sources src/*.c)
88
target_sources(app PRIVATE ${app_sources})
99

10-
zephyr_library_include_directories($ENV{ZEPHYR_BASE}/samples/bluetooth)
10+
zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(hci_pwr_ctrl)
66

77
target_sources(app PRIVATE src/main.c)

samples/bluetooth/hci_rpmsg/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
cmake_minimum_required(VERSION 3.13.1)
44

5-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
5+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
66
project(hci_rpmsg)
77

88
target_sources(app PRIVATE src/main.c)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(hci_spi)
66

77
FILE(GLOB app_sources src/*.c)
88
target_sources(app PRIVATE ${app_sources})
99

10-
zephyr_library_include_directories($ENV{ZEPHYR_BASE}/samples/bluetooth)
10+
zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth)

samples/bluetooth/hci_uart/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
cmake_minimum_required(VERSION 3.13.1)
44

5-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
5+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
66
project(hci_uart)
77

88
target_sources(app PRIVATE src/main.c)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(hci_usb)
66

77
target_sources(app PRIVATE src/main.c)

samples/bluetooth/ibeacon/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(ibeacon)
66

77
target_sources(app PRIVATE src/main.c)

samples/bluetooth/ipsp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(ipsp)
66

77
target_sources(app PRIVATE

samples/bluetooth/mesh/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if((BOARD STREQUAL nrf51_blenano) OR (BOARD STREQUAL nrf51_ble400))
77
set(CONF_FILE nrf51_qfaa.conf)
88
endif()
99

10-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
10+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
1111
project(mesh)
1212

1313
target_sources(app PRIVATE src/main.c)

samples/bluetooth/mesh_demo/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
cmake_minimum_required(VERSION 3.13.1)
44
set(QEMU_EXTRA_FLAGS -s)
55

6-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
6+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
77
project(mesh_demo)
88

99
target_sources(app PRIVATE src/main.c)
1010
target_sources_ifdef(CONFIG_BOARD_BBC_MICROBIT app PRIVATE src/microbit.c)
1111
zephyr_include_directories_ifdef(CONFIG_BOARD_BBC_MICROBIT
12-
$ENV{ZEPHYR_BASE}/boards/arm/bbc_microbit)
12+
${ZEPHYR_BASE}/boards/arm/bbc_microbit)
1313

1414
if(NODE_ADDR)
1515
zephyr_compile_definitions(NODE_ADDR=${NODE_ADDR})

samples/bluetooth/mesh_provisioner/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
cmake_minimum_required(VERSION 3.13.1)
44
set(QEMU_EXTRA_FLAGS -s)
55

6-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
6+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
77
project(mesh_provisioner)
88

99
target_sources(app PRIVATE src/main.c)

samples/bluetooth/peripheral/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(peripheral)
66

77
target_sources(app PRIVATE
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(peripheral_csc)
66

77
FILE(GLOB app_sources src/*.c)
88
target_sources(app PRIVATE
99
${app_sources}
1010
)
1111

12-
zephyr_library_include_directories($ENV{ZEPHYR_BASE}/samples/bluetooth)
12+
zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(peripheral_dis)
66

77
FILE(GLOB app_sources src/*.c)
88
target_sources(app PRIVATE
99
${app_sources}
1010
)
1111

12-
zephyr_library_include_directories($ENV{ZEPHYR_BASE}/samples/bluetooth)
12+
zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(peripheral_esp)
66

77
target_sources(app PRIVATE
88
src/main.c
99
)
1010

11-
zephyr_library_include_directories($ENV{ZEPHYR_BASE}/samples/bluetooth)
11+
zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth)
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(peripheral_hids)
66

77
FILE(GLOB app_sources src/*.c)
88
target_sources(app PRIVATE
99
${app_sources}
1010
)
11-

samples/bluetooth/peripheral_hr/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
cmake_minimum_required(VERSION 3.13.1)
44

5-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
5+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
66
project(peripheral_hr)
77

88
FILE(GLOB app_sources src/*.c)
99
target_sources(app PRIVATE
1010
${app_sources}
1111
)
1212

13-
zephyr_library_include_directories($ENV{ZEPHYR_BASE}/samples/bluetooth)
13+
zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth)

samples/bluetooth/peripheral_ht/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
cmake_minimum_required(VERSION 3.13.1)
44

5-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
5+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
66
project(peripheral_ht)
77

88
FILE(GLOB app_sources src/*.c)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(peripheral_sc_only)
66

77
target_sources(app PRIVATE
88
src/main.c
99
)
1010

11-
zephyr_library_include_directories($ENV{ZEPHYR_BASE}/samples/bluetooth)
11+
zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
4+
find_package(Zephyr HINTS $ENV{ZEPHYR_BASE})
55
project(scan_adv)
66

77
FILE(GLOB app_sources src/*.c)
88
target_sources(app PRIVATE ${app_sources})
99

10-
zephyr_library_include_directories($ENV{ZEPHYR_BASE}/samples/bluetooth)
10+
zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth)

0 commit comments

Comments
 (0)