1# Copyright (c) 2022 Google LLC 2# SPDX-License-Identifier: Apache-2.0 3 4cmake_minimum_required(VERSION 3.20.0) 5 6set(KCONFIG_ROOT ${CMAKE_CURRENT_LIST_DIR}/../Kconfig) 7 8# Add the sources 9list(APPEND test_sources src/main.cpp) 10if(CONFIG_ZTEST_FAIL_TEST_ASSERT_AFTER) 11 list(APPEND test_sources src/assert_after.cpp) 12elseif(CONFIG_ZTEST_FAIL_TEST_ASSERT_TEARDOWN) 13 list(APPEND test_sources src/assert_teardown.cpp) 14elseif(CONFIG_ZTEST_FAIL_TEST_ASSUME_AFTER) 15 list(APPEND test_sources src/assume_after.cpp) 16elseif(CONFIG_ZTEST_FAIL_TEST_ASSUME_TEARDOWN) 17 list(APPEND test_sources src/assume_teardown.cpp) 18elseif(CONFIG_ZTEST_FAIL_TEST_PASS_AFTER) 19 list(APPEND test_sources src/pass_after.cpp) 20elseif(CONFIG_ZTEST_FAIL_TEST_PASS_TEARDOWN) 21 list(APPEND test_sources src/pass_teardown.cpp) 22elseif(CONFIG_ZTEST_FAIL_TEST_UNEXPECTED_ASSUME) 23 list(APPEND test_sources src/unexpected_assume.cpp) 24endif() 25 26if(BOARD STREQUAL "unit_testing" OR BOARD STREQUAL "unit_testing/unit_testing") 27 find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) 28 project(base) 29 30 target_sources(testbinary PRIVATE ${test_sources}) 31 target_include_directories(testbinary PRIVATE include) 32 install(TARGETS testbinary) 33else() 34 find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 35 project(base) 36 37 target_sources(app PRIVATE ${test_sources}) 38 target_include_directories(app PRIVATE include) 39 install(FILES ${APPLICATION_BINARY_DIR}/zephyr/${KERNEL_EXE_NAME} 40 DESTINATION bin/ 41 PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ 42 WORLD_EXECUTE WORLD_READ 43 ) 44endif() 45