mirror of https://github.com/ARMmbed/mbed-os.git
CMake: Add option to enable greentea tests
Add an option to enable the greentea tests independently from the unit tests. We can't just use the typical BUILD_TESTING option to enable greentea tests. BUILD_TESTING enables unit tests and fetches googletest, which are compiled for the host. Greentea tests are cross compiled and require a toolchain file. For this reason we add a new option just to enable greentea tests, preventing build failures triggered by the unit tests and googletest.pull/14892/head
parent
d4b15348a9
commit
7842320ab7
|
@ -5,6 +5,8 @@
|
|||
|
||||
cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR)
|
||||
|
||||
option(BUILD_GREENTEA_TESTS "Build greentea tests only." OFF)
|
||||
|
||||
if(${CMAKE_CROSSCOMPILING})
|
||||
include(${MBED_CONFIG_PATH}/mbed_config.cmake)
|
||||
include(mbed_set_linker_script)
|
||||
|
@ -19,12 +21,14 @@ list(APPEND CMAKE_MODULE_PATH
|
|||
|
||||
add_subdirectory(extern)
|
||||
|
||||
option(BUILD_TESTING "Run unit tests only." OFF)
|
||||
|
||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
||||
include(CTest)
|
||||
add_definitions(-DUNITTEST)
|
||||
add_subdirectory(UNITTESTS)
|
||||
|
||||
if((NOT BUILD_GREENTEA_TESTS) AND BUILD_TESTING)
|
||||
# Building unit tests only.
|
||||
add_definitions(-DUNITTEST)
|
||||
add_subdirectory(UNITTESTS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_library(mbed-core INTERFACE)
|
||||
|
@ -94,10 +98,12 @@ if(${CMAKE_CROSSCOMPILING})
|
|||
|
||||
# Add MBED_TEST_MODE for backward compatibility with Greentea tests written for use with Mbed CLI 1
|
||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||
target_compile_definitions(${PROJECT_NAME}
|
||||
INTERFACE
|
||||
MBED_TEST_MODE
|
||||
)
|
||||
if(NOT BUILD_GREENTEA_TESTS)
|
||||
target_compile_definitions(${PROJECT_NAME}
|
||||
INTERFACE
|
||||
MBED_TEST_MODE
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# We need to generate a "response file" to pass to the C preprocessor when we preprocess the linker
|
||||
|
|
|
@ -2,7 +2,11 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
if(BUILD_GREENTEA_TESTS)
|
||||
# add greentea test
|
||||
else()
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_subdirectory(source/framework)
|
||||
|
|
|
@ -2,7 +2,11 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
if(BUILD_GREENTEA_TESTS)
|
||||
# add greentea test
|
||||
else()
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_subdirectory(lorastack)
|
||||
|
|
|
@ -2,7 +2,11 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
if(BUILD_GREENTEA_TESTS)
|
||||
# add greentea test
|
||||
else()
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# TODO CMake: Perhaps move this/these file(s) into connectivity/drivers/cellular
|
||||
|
|
|
@ -2,7 +2,11 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
if(BUILD_GREENTEA_TESTS)
|
||||
# add greentea test
|
||||
else()
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_include_directories(mbed-core
|
||||
|
|
|
@ -2,8 +2,12 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
else()
|
||||
if(BUILD_GREENTEA_TESTS)
|
||||
# add greentea test
|
||||
else()
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_library(mbed-events INTERFACE)
|
||||
|
||||
|
@ -28,4 +32,3 @@ target_compile_definitions(mbed-events
|
|||
INTERFACE
|
||||
MBED_CONF_EVENTS_PRESENT=1
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -2,7 +2,11 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
if(BUILD_GREENTEA_TESTS)
|
||||
# add greentea test
|
||||
else()
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_subdirectory(TARGET_FLASH_CMSIS_ALGO EXCLUDE_FROM_ALL)
|
||||
|
|
|
@ -2,7 +2,11 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
if(BUILD_GREENTEA_TESTS)
|
||||
# add greentea test
|
||||
else()
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# List of all optional platform libraries available.
|
||||
|
|
|
@ -2,7 +2,11 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
if(BUILD_GREENTEA_TESTS)
|
||||
# add greentea test
|
||||
else()
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_include_directories(mbed-core
|
||||
|
|
|
@ -2,7 +2,11 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
if(BUILD_GREENTEA_TESTS)
|
||||
# add greentea test
|
||||
else()
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if("DATAFLASH" IN_LIST MBED_TARGET_LABELS)
|
||||
|
|
|
@ -2,7 +2,11 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
if(BUILD_GREENTEA_TESTS)
|
||||
# add greentea test
|
||||
else()
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_subdirectory(fat)
|
||||
|
|
|
@ -2,7 +2,11 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
if(BUILD_GREENTEA_TESTS)
|
||||
# add greentea test
|
||||
else()
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_subdirectory(tdbstore)
|
||||
|
|
|
@ -2,7 +2,11 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
if(BUILD_GREENTEA_TESTS)
|
||||
# add greentea test
|
||||
else()
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_include_directories(mbed-storage-filesystemstore
|
||||
|
|
|
@ -2,7 +2,11 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
if(BUILD_GREENTEA_TESTS)
|
||||
# add greentea test
|
||||
else()
|
||||
add_subdirectory(tests/UNITTESTS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_include_directories(mbed-storage-tdbstore
|
||||
|
|
Loading…
Reference in New Issue