summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorYuval Peress <peress@google.com>2022-11-22 22:23:18 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-11-25 16:00:26 +0000
commite10c75edd1c17eb70f7faf9add22cb7f50e2eee2 (patch)
tree10abfa7117da358eee21e60d5876c0f36d4dd397 /common
parent0fdab007bed8126649b2f29fcdb0a7f26fb1ff16 (diff)
downloadchrome-ec-e10c75edd1c17eb70f7faf9add22cb7f50e2eee2.tar.gz
build: update build cmake files for unit tests
Adding the unittest Zephyr component now updates the CMAKE_C_COMPILER and CMAKE_CXX_COMPILER values. This means that find_package needs to be called prior to any of the test library commands so the right compiler is set for all the libraries. Twister launcher no longer needs to set the compiler as an argument to CMake. zephyr/cmake compiler and toolchain required updates to play nice with posix/unit_testing architectures. These included: 1. Conditionally adding the -fno-PIC flag 2. Setting CMAKE_CXX_COMPILER for clang 3. Adding a unit_testing cross compile target to the llvm and host toolchain BRANCH=none BUG=none TEST=./twister Cq-Depend: chromium:4047569 Signed-off-by: Yuval Peress <peress@google.com> Change-Id: Ib1e8ddcb526a56c05ef925d4d9ab97cb65004038 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4050266 Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Diffstat (limited to 'common')
-rw-r--r--common/spi/flash_reg/CMakeLists.txt8
1 files changed, 3 insertions, 5 deletions
diff --git a/common/spi/flash_reg/CMakeLists.txt b/common/spi/flash_reg/CMakeLists.txt
index fda467d2e4..55708ac57e 100644
--- a/common/spi/flash_reg/CMakeLists.txt
+++ b/common/spi/flash_reg/CMakeLists.txt
@@ -6,6 +6,7 @@ cmake_minimum_required(VERSION 3.20.0)
# Create the library
if(BOARD STREQUAL unit_testing)
+ find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
add_library(spi_flash_reg)
else()
zephyr_library_named(spi_flash_reg)
@@ -45,11 +46,8 @@ target_include_directories(spi_flash_reg PUBLIC public)
if(BOARD STREQUAL unit_testing)
project(flash_reg)
- # Set the sources for the test (must be done before find_package)
- set(SOURCES src/spi_flash_reg_test.c)
-
- # Create the unittest libraries and binary
- find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
+ # Set the sources for the test
+ target_sources(testbinary PRIVATE src/spi_flash_reg_test.c)
# Link the library being tested
target_link_libraries(testbinary PRIVATE spi_flash_reg)