55
66cmake_minimum_required (VERSION 3.19.0 FATAL_ERROR)
77
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+
819if (${CMAKE_CROSSCOMPILING} )
920 include (${MBED_CONFIG_PATH} /mbed_config.cmake)
1021 include (mbed_set_linker_script)
@@ -14,17 +25,19 @@ project(mbed-os)
1425
1526# Add all paths to the list files within Mbed OS
1627list (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/ "
1829)
1930
2031add_subdirectory (extern)
2132
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 )
2534 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 ()
2841endif ()
2942
3043add_library (mbed-core INTERFACE )
@@ -94,10 +107,12 @@ if(${CMAKE_CROSSCOMPILING})
94107
95108 # Add MBED_TEST_MODE for backward compatibility with Greentea tests written for use with Mbed CLI 1
96109 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 ()
101116 endif ()
102117
103118 # We need to generate a "response file" to pass to the C preprocessor when we preprocess the linker
0 commit comments