From e1c1d1dacae484f48ef11d0a2bc56609bf370f0e Mon Sep 17 00:00:00 2001 From: Torsten Rasmussen Date: Fri, 29 May 2020 22:17:26 +0200 Subject: [PATCH] cmake: make find_package(ZephyrUnittest...) REQUIRED This commit is a followup to PR #25808 which updates the tests to ensure the REQUIRED keyword is also used for the ZephyrUnitest package. This provides a better error message when building with CMake and forgetting ZEPHYR_BASE or not registering Zephyr in the CMake package registry. Signed-off-by: Torsten Rasmussen --- cmake/app/boilerplate.cmake | 6 +++--- tests/unit/base64/CMakeLists.txt | 2 +- tests/unit/crc/CMakeLists.txt | 2 +- tests/unit/intmath/CMakeLists.txt | 2 +- tests/unit/list/CMakeLists.txt | 2 +- tests/unit/math_extras/CMakeLists.txt | 2 +- tests/unit/rbtree/CMakeLists.txt | 2 +- tests/unit/timeutil/CMakeLists.txt | 2 +- tests/unit/util/CMakeLists.txt | 2 +- tests/ztest/base/CMakeLists.txt | 2 +- tests/ztest/mock/CMakeLists.txt | 2 +- 11 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cmake/app/boilerplate.cmake b/cmake/app/boilerplate.cmake index 9391b1fe000..a72f325d157 100644 --- a/cmake/app/boilerplate.cmake +++ b/cmake/app/boilerplate.cmake @@ -9,10 +9,10 @@ # one of those lines: # # find_package(Zephyr) -# find_package(Zephyr HINTS $ENV{ZEPHYR_BASE}) +# find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) # -# The `HINTS $ENV{ZEPHYR_BASE}` variant is required for any application inside -# the Zephyr repository. +# The `REQUIRED HINTS $ENV{ZEPHYR_BASE}` variant is required for any application +# inside the Zephyr repository. # # It exists to reduce boilerplate code that Zephyr expects to be in # application CMakeLists.txt code. diff --git a/tests/unit/base64/CMakeLists.txt b/tests/unit/base64/CMakeLists.txt index f13c212d3fc..36919da9f15 100644 --- a/tests/unit/base64/CMakeLists.txt +++ b/tests/unit/base64/CMakeLists.txt @@ -2,4 +2,4 @@ project(base64) set(SOURCES main.c) -find_package(ZephyrUnittest HINTS $ENV{ZEPHYR_BASE}) +find_package(ZephyrUnittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) diff --git a/tests/unit/crc/CMakeLists.txt b/tests/unit/crc/CMakeLists.txt index 70babfa9657..323a57d8ce5 100644 --- a/tests/unit/crc/CMakeLists.txt +++ b/tests/unit/crc/CMakeLists.txt @@ -2,4 +2,4 @@ project(crc) set(SOURCES main.c) -find_package(ZephyrUnittest HINTS $ENV{ZEPHYR_BASE}) +find_package(ZephyrUnittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) diff --git a/tests/unit/intmath/CMakeLists.txt b/tests/unit/intmath/CMakeLists.txt index 88118230c13..a8d4621b262 100644 --- a/tests/unit/intmath/CMakeLists.txt +++ b/tests/unit/intmath/CMakeLists.txt @@ -4,4 +4,4 @@ project(base64) set(SOURCES main.c ) -find_package(ZephyrUnittest HINTS $ENV{ZEPHYR_BASE}) +find_package(ZephyrUnittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) diff --git a/tests/unit/list/CMakeLists.txt b/tests/unit/list/CMakeLists.txt index 11246ff7201..61a1357803a 100644 --- a/tests/unit/list/CMakeLists.txt +++ b/tests/unit/list/CMakeLists.txt @@ -7,4 +7,4 @@ set(SOURCES dlist.c sflist.c ) -find_package(ZephyrUnittest HINTS $ENV{ZEPHYR_BASE}) +find_package(ZephyrUnittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) diff --git a/tests/unit/math_extras/CMakeLists.txt b/tests/unit/math_extras/CMakeLists.txt index 265e822a9a3..5c2fec54398 100644 --- a/tests/unit/math_extras/CMakeLists.txt +++ b/tests/unit/math_extras/CMakeLists.txt @@ -2,4 +2,4 @@ project(math_extras) set(SOURCES main.c portable.c) -find_package(ZephyrUnittest HINTS $ENV{ZEPHYR_BASE}) +find_package(ZephyrUnittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) diff --git a/tests/unit/rbtree/CMakeLists.txt b/tests/unit/rbtree/CMakeLists.txt index 13ff70f7fe5..daeafb18be1 100644 --- a/tests/unit/rbtree/CMakeLists.txt +++ b/tests/unit/rbtree/CMakeLists.txt @@ -2,4 +2,4 @@ project(rbtree) set(SOURCES main.c) -find_package(ZephyrUnittest HINTS $ENV{ZEPHYR_BASE}) +find_package(ZephyrUnittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) diff --git a/tests/unit/timeutil/CMakeLists.txt b/tests/unit/timeutil/CMakeLists.txt index d4478116413..29af778ecc3 100644 --- a/tests/unit/timeutil/CMakeLists.txt +++ b/tests/unit/timeutil/CMakeLists.txt @@ -2,4 +2,4 @@ project(timeutil) set(SOURCES main.c test_gmtime.c test_s32.c test_s64.c) -find_package(ZephyrUnittest HINTS $ENV{ZEPHYR_BASE}) +find_package(ZephyrUnittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) diff --git a/tests/unit/util/CMakeLists.txt b/tests/unit/util/CMakeLists.txt index 03f4dad0cfb..5923450b178 100644 --- a/tests/unit/util/CMakeLists.txt +++ b/tests/unit/util/CMakeLists.txt @@ -2,4 +2,4 @@ project(util) set(SOURCES main.c ../../../lib/os/dec.c) -find_package(ZephyrUnittest HINTS $ENV{ZEPHYR_BASE}) +find_package(ZephyrUnittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) diff --git a/tests/ztest/base/CMakeLists.txt b/tests/ztest/base/CMakeLists.txt index 0290abdf8d7..e83abd518b8 100644 --- a/tests/ztest/base/CMakeLists.txt +++ b/tests/ztest/base/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.13.1) if(BOARD STREQUAL unit_testing) list(APPEND SOURCES src/main.c) - find_package(ZephyrUnittest HINTS $ENV{ZEPHYR_BASE}) + find_package(ZephyrUnittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(base) else() find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) diff --git a/tests/ztest/mock/CMakeLists.txt b/tests/ztest/mock/CMakeLists.txt index 45a13863932..aff3868722c 100644 --- a/tests/ztest/mock/CMakeLists.txt +++ b/tests/ztest/mock/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.13.1) if(BOARD STREQUAL unit_testing) list(APPEND SOURCES src/main.c) - find_package(ZephyrUnittest HINTS $ENV{ZEPHYR_BASE}) + find_package(ZephyrUnittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(mock) else() find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})