diff --git a/src/test_driver/openiotsdk/unit-tests/CMakeLists.txt b/src/test_driver/openiotsdk/unit-tests/CMakeLists.txt index 887eb43a3703f6..b4b085299f5e82 100644 --- a/src/test_driver/openiotsdk/unit-tests/CMakeLists.txt +++ b/src/test_driver/openiotsdk/unit-tests/CMakeLists.txt @@ -30,18 +30,28 @@ set(CONFIG_CHIP_AUTOMATION_LOGGING YES) set(CONFIG_CHIP_ERROR_LOGGING NO) set(PW_ROOT ${CHIP_ROOT}/third_party/pigweed/repo) -set(pw_unit_test_AUTOMATIC_RUNNER "") -set(pw_sys_io_BACKEND "pw_sys_io_stdio") -set(pw_assert_BACKEND "pw_assert_log") -set(pw_log_BACKEND "pw_log_basic") +# set(pw_unit_test_AUTOMATIC_RUNNER "") +# set(pw_unit_test_MAIN "") +# set(pw_sys_io_BACKEND "pw_sys_io_stdio") +# set(pw_assert_BACKEND "pw_assert_log") +# set(pw_log_BACKEND "pw_log_basic") + # Toolchain files need to exist before first call to project include(toolchain) project(chip-open-iot-sdk-unit-tests LANGUAGES C CXX ASM) -include($ENV{PW_ROOT}/pw_build/pigweed.cmake) -include($ENV{PW_ROOT}/pw_unit_test/test.cmake) +include(${PW_ROOT}/pw_build/pigweed.cmake) +include(${PW_ROOT}/pw_unit_test/test.cmake) +include(${PW_ROOT}/pw_assert/backend.cmake) +include(${PW_ROOT}/pw_log/backend.cmake) +include(${PW_ROOT}/pw_sys_io/backend.cmake) + +pw_set_backend(pw_log pw_log_basic) +pw_set_backend(pw_assert.check pw_assert_log.check_backend) +pw_set_backend(pw_assert.assert pw_assert.assert_compatibility_backend) +pw_set_backend(pw_sys_io pw_sys_io_stdio) include(sdk) include(chip) @@ -51,6 +61,7 @@ add_subdirectory(${OPEN_IOT_SDK_EXAMPLE_COMMON}/app ./app_build) add_subdirectory(${PW_ROOT} pigweed_build) file(STRINGS test_components.txt TEST_NAMES_FROM_FILE) +# TODO [PW_MIGRATION] Remove the following variable once the migration to pw_unit_test is complete. file(STRINGS test_components_nl.txt TEST_NAMES_FROM_FILE_NL) target_compile_definitions(openiotsdk-startup @@ -58,6 +69,7 @@ target_compile_definitions(openiotsdk-startup IOT_SDK_APP_MAIN_STACK_SIZE=20480 ) +# TODO [PW_MIGRATION] Remove the following targets once the migration to pw_unit_test is complete. foreach(TEST_NAME IN LISTS TEST_NAMES_FROM_FILE_NL) set(APP_TARGET ${TEST_NAME}_ns) add_executable(${APP_TARGET}) @@ -90,36 +102,31 @@ endforeach() foreach(TEST_NAME IN LISTS TEST_NAMES_FROM_FILE) set(APP_TARGET ${TEST_NAME}_ns) - # add_executable(${APP_TARGET}) - pw_add_test(${APP_TARGET} - SOURCES - main/main_ns.cpp - PRIVATE_DEPS - openiotsdk-startup - openiotsdk-app - # pw_unit_test - PRIVATE_LINK_OPTIONS - -Wl,--whole-archive "${CMAKE_CURRENT_BINARY_DIR}/chip_build/lib/lib${TEST_NAME}.a" - -Wl,--no-whole-archive - ) - target_include_directories(${APP_TARGET}.bin + add_executable(${APP_TARGET}) + target_include_directories(${APP_TARGET} PRIVATE main/include + ${CHIP_ROOT}/third_party/nlunit-test/repo/src ) - # target_sources(${APP_TARGET} - # PRIVATE - # main/main_ns.cpp - # ) + target_sources(${APP_TARGET} + PRIVATE + main/main_ns.cpp + ) - # target_link_libraries(${APP_TARGET}.bin - # openiotsdk-startup - # openiotsdk-app - # pw_unit_test - # ) + target_link_libraries(${APP_TARGET} PRIVATE + PRIVATE + openiotsdk-startup + openiotsdk-app + pw_unit_test + ) # Link the *whole-archives* to keep the static test objects. + target_link_options(${APP_TARGET} + PUBLIC + -Wl,--whole-archive "${CMAKE_CURRENT_BINARY_DIR}/chip_build/lib/lib${TEST_NAME}.a" + -Wl,--no-whole-archive) - set_target_link(${APP_TARGET}.bin) - sdk_post_build(${APP_TARGET}.bin) + set_target_link(${APP_TARGET}) + sdk_post_build(${APP_TARGET}) endforeach()