Fixes: #73831 find_package(Zephyr) should be called before first project() call. Zephyr package will test and force-set the correct toolchain, especially the C compiler. The project() will also set the C compiler, if not set already. If project() is called first, then conflict arises on the C compiler selection and thus the following message is seen: > You have changed variables that require your cache to be deleted. > Configure will be re-run and you may have to reset some variables. > The following variables have changed: > CMAKE_C_COMPILER= /usr/bin/gcc This cache deletion results in other errors, such as a missing BOARD setting. Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
19 lines
457 B
CMake
19 lines
457 B
CMake
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
cmake_minimum_required(VERSION 3.20.0)
|
|
|
|
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
|
|
|
project(util)
|
|
|
|
target_sources(testbinary
|
|
PRIVATE
|
|
main.c
|
|
${ZEPHYR_BASE}/lib/utils/dec.c
|
|
${ZEPHYR_BASE}/lib/utils/utf8.c
|
|
)
|
|
|
|
if(CONFIG_CPP)
|
|
# When testing for C++ force test file C++ compilation
|
|
set_source_files_properties(main.c ${ZEPHYR_BASE}/lib/utils/dec.c PROPERTIES LANGUAGE CXX)
|
|
endif()
|