5
5
6
6
cmake_minimum_required (VERSION 3.19.0 FATAL_ERROR)
7
7
8
+ option (BUILD_GREENTEA_TESTS "Build greentea tests only." OFF )
9
+
10
+ if (BUILD_GREENTEA_TESTS)
11
+ # Usually we rely on the application to set MBED_CONFIG_PATH and include
12
+ # app.cmake. They are both required if we're building an application to run
13
+ # on an mbed-target.
14
+ set (MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE STRING "" )
15
+ # TODO: Remove when https://github.com/ARMmbed/mbed-os/issues/14518 is fixed
16
+ include (${CMAKE_CURRENT_LIST_DIR} /tools/cmake/app.cmake)
17
+ endif ()
18
+
8
19
if (${CMAKE_CROSSCOMPILING} )
9
20
include (${MBED_CONFIG_PATH} /mbed_config.cmake)
10
21
include (mbed_set_linker_script)
@@ -14,17 +25,19 @@ project(mbed-os)
14
25
15
26
# Add all paths to the list files within Mbed OS
16
27
list (APPEND CMAKE_MODULE_PATH
17
- "${mbed-os_SOURCE_DIR}/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/scripts;${mbed-os_SOURCE_DIR}/targets/TARGET_Cypress/scripts;${mbed-os_SOURCE_DIR}/targets/TARGET_NXP/scripts"
28
+ "${mbed-os_SOURCE_DIR}/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/scripts;${mbed-os_SOURCE_DIR}/targets/TARGET_Cypress/scripts;${mbed-os_SOURCE_DIR}/targets/TARGET_NXP/scripts;${mbed-os_SOURCE_DIR}/targets/TARGET_NUVOTON/scripts/ "
18
29
)
19
30
20
31
add_subdirectory (extern)
21
32
22
- option (BUILD_TESTING "Run unit tests only." OFF )
23
-
24
- if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
33
+ if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME )
25
34
include (CTest)
26
- add_definitions (-DUNITTEST)
27
- add_subdirectory (UNITTESTS)
35
+
36
+ if ((NOT BUILD_GREENTEA_TESTS) AND BUILD_TESTING)
37
+ # Building unit tests only.
38
+ add_definitions (-DUNITTEST)
39
+ add_subdirectory (UNITTESTS)
40
+ endif ()
28
41
endif ()
29
42
30
43
add_library (mbed-core INTERFACE )
@@ -94,10 +107,12 @@ if(${CMAKE_CROSSCOMPILING})
94
107
95
108
# Add MBED_TEST_MODE for backward compatibility with Greentea tests written for use with Mbed CLI 1
96
109
if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
97
- target_compile_definitions (${PROJECT_NAME}
98
- INTERFACE
99
- MBED_TEST_MODE
100
- )
110
+ if (NOT BUILD_GREENTEA_TESTS)
111
+ target_compile_definitions (${PROJECT_NAME}
112
+ INTERFACE
113
+ MBED_TEST_MODE
114
+ )
115
+ endif ()
101
116
endif ()
102
117
103
118
# We need to generate a "response file" to pass to the C preprocessor when we preprocess the linker
0 commit comments