cmake: remove the use of SOURCES in tests
Setting SOURCES before calling find_package() was deprecated in #51049. Cleanup usage of SOURCES and instead use the proper target_sources() CMake function. Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
parent
b939e720a6
commit
e8e5169f95
11 changed files with 40 additions and 56 deletions
|
@ -2,11 +2,6 @@
|
|||
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
set(SOURCES
|
||||
src/main.c
|
||||
src/test_suite_invalid_inputs.c
|
||||
)
|
||||
|
||||
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
|
||||
|
||||
project(bt_encrypt_be)
|
||||
|
@ -14,4 +9,8 @@ project(bt_encrypt_be)
|
|||
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host host_mocks)
|
||||
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host/crypto mocks)
|
||||
|
||||
target_sources(testbinary PRIVATE
|
||||
src/main.c
|
||||
src/test_suite_invalid_inputs.c
|
||||
)
|
||||
target_link_libraries(testbinary PRIVATE mocks host_mocks)
|
||||
|
|
|
@ -2,11 +2,6 @@
|
|||
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
set(SOURCES
|
||||
src/main.c
|
||||
src/test_suite_invalid_inputs.c
|
||||
)
|
||||
|
||||
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
|
||||
|
||||
project(bt_encrypt_le)
|
||||
|
@ -14,4 +9,8 @@ project(bt_encrypt_le)
|
|||
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host host_mocks)
|
||||
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host/crypto mocks)
|
||||
|
||||
target_sources(testbinary PRIVATE
|
||||
src/main.c
|
||||
src/test_suite_invalid_inputs.c
|
||||
)
|
||||
target_link_libraries(testbinary PRIVATE mocks host_mocks)
|
||||
|
|
|
@ -2,11 +2,6 @@
|
|||
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
set(SOURCES
|
||||
src/main.c
|
||||
src/test_suite_invalid_inputs.c
|
||||
)
|
||||
|
||||
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
|
||||
|
||||
project(bt_rand)
|
||||
|
@ -14,4 +9,8 @@ project(bt_rand)
|
|||
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host host_mocks)
|
||||
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host/crypto mocks)
|
||||
|
||||
target_sources(testbinary PRIVATE
|
||||
src/main.c
|
||||
src/test_suite_invalid_inputs.c
|
||||
)
|
||||
target_link_libraries(testbinary PRIVATE mocks host_mocks)
|
||||
|
|
|
@ -2,11 +2,6 @@
|
|||
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
set(SOURCES
|
||||
src/main.c
|
||||
src/test_suite_invalid_inputs.c
|
||||
)
|
||||
|
||||
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
|
||||
project(prng_init)
|
||||
|
@ -14,4 +9,8 @@ project(prng_init)
|
|||
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host host_mocks)
|
||||
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host/crypto mocks)
|
||||
|
||||
target_sources(testbinary PRIVATE
|
||||
src/main.c
|
||||
src/test_suite_invalid_inputs.c
|
||||
)
|
||||
target_link_libraries(testbinary PRIVATE mocks host_mocks)
|
||||
|
|
|
@ -2,11 +2,6 @@
|
|||
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
set(SOURCES
|
||||
src/main.c
|
||||
src/test_suite_invalid_inputs.c
|
||||
)
|
||||
|
||||
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
|
||||
|
||||
project(bt_dh_key_gen)
|
||||
|
@ -14,4 +9,8 @@ project(bt_dh_key_gen)
|
|||
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host host_mocks)
|
||||
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host/ecc mocks)
|
||||
|
||||
target_sources(testbinary PRIVATE
|
||||
src/main.c
|
||||
src/test_suite_invalid_inputs.c
|
||||
)
|
||||
target_link_libraries(testbinary PRIVATE mocks host_mocks)
|
||||
|
|
|
@ -2,11 +2,6 @@
|
|||
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
set(SOURCES
|
||||
src/main.c
|
||||
src/test_suite_invalid_inputs.c
|
||||
)
|
||||
|
||||
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
|
||||
|
||||
project(bt_pub_key_gen)
|
||||
|
@ -14,4 +9,8 @@ project(bt_pub_key_gen)
|
|||
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host host_mocks)
|
||||
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host/ecc mocks)
|
||||
|
||||
target_sources(testbinary PRIVATE
|
||||
src/main.c
|
||||
src/test_suite_invalid_inputs.c
|
||||
)
|
||||
target_link_libraries(testbinary PRIVATE mocks host_mocks)
|
||||
|
|
|
@ -2,11 +2,6 @@
|
|||
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
set(SOURCES
|
||||
src/main.c
|
||||
src/test_suite_invalid_inputs.c
|
||||
)
|
||||
|
||||
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
|
||||
|
||||
project(bt_pub_key_get)
|
||||
|
@ -14,4 +9,8 @@ project(bt_pub_key_get)
|
|||
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host host_mocks)
|
||||
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host/ecc mocks)
|
||||
|
||||
target_sources(testbinary PRIVATE
|
||||
src/main.c
|
||||
src/test_suite_invalid_inputs.c
|
||||
)
|
||||
target_link_libraries(testbinary PRIVATE mocks host_mocks)
|
||||
|
|
|
@ -2,10 +2,6 @@
|
|||
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
set(SOURCES
|
||||
src/main.c
|
||||
)
|
||||
|
||||
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE})
|
||||
|
||||
project(bt_pub_key_is_debug)
|
||||
|
@ -13,4 +9,5 @@ project(bt_pub_key_is_debug)
|
|||
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host host_mocks)
|
||||
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host/ecc mocks)
|
||||
|
||||
target_sources(testbinary PRIVATE src/main.c)
|
||||
target_link_libraries(testbinary PRIVATE mocks host_mocks)
|
||||
|
|
|
@ -2,11 +2,6 @@
|
|||
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
set(SOURCES
|
||||
src/main.c
|
||||
src/test_suite_invalid_cases.c
|
||||
)
|
||||
|
||||
project(bt_id_set_adv_private_addr)
|
||||
|
||||
# Suppress the format-zero-length error if GNUC is used
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
cmake_minimum_required(VERSION 3.20.0)
|
||||
include(ExternalProject)
|
||||
|
||||
# Add the sources and set up the build for either unit testing or native_sim
|
||||
list(APPEND SOURCES src/main.cpp)
|
||||
if(BOARD STREQUAL unit_testing)
|
||||
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
set(target testbinary)
|
||||
|
@ -22,7 +20,7 @@ endif()
|
|||
|
||||
# Create the project and set the sources for the target
|
||||
project(fail)
|
||||
target_sources(${target} PRIVATE ${SOURCES})
|
||||
target_sources(${target} PRIVATE src/main.cpp)
|
||||
|
||||
# Find which CONFIG_ZTEST_FAIL_TEST_* choice was set so we can pass it to the external project
|
||||
# Once we find the config, we'll need to prepend a '-D' and append '=y' so we can pass it to the
|
||||
|
|
|
@ -6,34 +6,35 @@ cmake_minimum_required(VERSION 3.20.0)
|
|||
set(KCONFIG_ROOT ${CMAKE_CURRENT_LIST_DIR}/../Kconfig)
|
||||
|
||||
# Add the sources
|
||||
list(APPEND SOURCES src/main.cpp)
|
||||
list(APPEND test_sources src/main.cpp)
|
||||
if(CONFIG_ZTEST_FAIL_TEST_ASSERT_AFTER)
|
||||
list(APPEND SOURCES src/assert_after.cpp)
|
||||
list(APPEND test_sources src/assert_after.cpp)
|
||||
elseif(CONFIG_ZTEST_FAIL_TEST_ASSERT_TEARDOWN)
|
||||
list(APPEND SOURCES src/assert_teardown.cpp)
|
||||
list(APPEND test_sources src/assert_teardown.cpp)
|
||||
elseif(CONFIG_ZTEST_FAIL_TEST_ASSUME_AFTER)
|
||||
list(APPEND SOURCES src/assume_after.cpp)
|
||||
list(APPEND test_sources src/assume_after.cpp)
|
||||
elseif(CONFIG_ZTEST_FAIL_TEST_ASSUME_TEARDOWN)
|
||||
list(APPEND SOURCES src/assume_teardown.cpp)
|
||||
list(APPEND test_sources src/assume_teardown.cpp)
|
||||
elseif(CONFIG_ZTEST_FAIL_TEST_PASS_AFTER)
|
||||
list(APPEND SOURCES src/pass_after.cpp)
|
||||
list(APPEND test_sources src/pass_after.cpp)
|
||||
elseif(CONFIG_ZTEST_FAIL_TEST_PASS_TEARDOWN)
|
||||
list(APPEND SOURCES src/pass_teardown.cpp)
|
||||
list(APPEND test_sources src/pass_teardown.cpp)
|
||||
elseif(CONFIG_ZTEST_FAIL_TEST_UNEXPECTED_ASSUME)
|
||||
list(APPEND SOURCES src/unexpected_assume.cpp)
|
||||
list(APPEND test_sources src/unexpected_assume.cpp)
|
||||
endif()
|
||||
|
||||
if(BOARD STREQUAL unit_testing)
|
||||
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(base)
|
||||
|
||||
target_sources(testbinary PRIVATE ${test_sources})
|
||||
target_include_directories(testbinary PRIVATE include)
|
||||
install(TARGETS testbinary)
|
||||
else()
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(base)
|
||||
|
||||
target_sources(app PRIVATE ${SOURCES})
|
||||
target_sources(app PRIVATE ${test_sources})
|
||||
target_include_directories(app PRIVATE include)
|
||||
install(FILES ${APPLICATION_BINARY_DIR}/zephyr/${KERNEL_EXE_NAME}
|
||||
DESTINATION bin/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue