Skip to content

Commit a223ce7

Browse files
committed
Create Greentea CMake Macro
1 parent 1833b35 commit a223ce7

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

tools/cmake/mbed_greentea.cmake

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Copyright (c) 2020 ARM Limited. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0# the macro
3+
4+
set(MBED_CONFIG_PATH ${CMAKE_CURRENT_SOURCE_DIR}/.mbedbuild CACHE INTERNAL "")
5+
6+
include(${MBED_PATH}/tools/cmake/app.cmake)
7+
8+
# CMake Macro for generalizing CMake configuration across the greentea test suite with configurable parameters
9+
# Macro args:
10+
# TEST_NAME - Test suite name
11+
# TEST_INCLUDE_DIRS - Test suite include directories for the test
12+
# TEST_SOURCES - Test suite sources
13+
# TEST_REQUIRED_LIBS - Test suite required libraries
14+
#
15+
# calling the macro:
16+
# mbed_greentea_cmake_macro(TEST_NAME mbed-platform-system-reset TEST_INCLUDE_DIRS mbed_store TEST_SOURCES foo.cpp bar.cpp TEST_REQUIRED_LIBS mbed-kvstore mbed-xyz)
17+
18+
macro(mbed_greentea_cmake_macro)
19+
set(options)
20+
set(singleValueArgs TEST_NAME)
21+
set(multipleValueArgs TEST_INCLUDE_DIRS TEST_SOURCES TEST_REQUIRED_LIBS)
22+
cmake_parse_arguments(MBED_GREENTEA "${options}" "${singleValueArgs}"
23+
"${multipleValueArgs}" ${ARGN} )
24+
25+
set(TEST_NAME ${MBED_GREENTEA_TEST_NAME})
26+
27+
add_subdirectory(${MBED_PATH} build)
28+
29+
add_executable(${TEST_NAME})
30+
31+
mbed_configure_app_target(${TEST_NAME})
32+
33+
mbed_set_mbed_target_linker_script(${TEST_NAME})
34+
35+
target_include_directories(${TEST_NAME}
36+
PRIVATE
37+
.
38+
${MBED_GREENTEA_TEST_INCLUDE_DIRS}
39+
)
40+
41+
target_sources(${TEST_NAME}
42+
PRIVATE
43+
main.cpp
44+
${MBED_GREENTEA_TEST_SOURCES}
45+
)
46+
47+
if(MBED_BAREMETAL_GREENTEA_TEST)
48+
list(APPEND MBED_GREENTEA_TEST_REQUIRED_LIBS mbed-baremetal mbed-greentea)
49+
else()
50+
list(APPEND MBED_GREENTEA_TEST_REQUIRED_LIBS mbed-os mbed-greentea)
51+
endif()
52+
53+
target_link_libraries(${TEST_NAME}
54+
PRIVATE
55+
${MBED_GREENTEA_TEST_REQUIRED_LIBS}
56+
)
57+
58+
mbed_set_post_build(${TEST_NAME})
59+
60+
option(VERBOSE_BUILD "Have a verbose build process")
61+
if(VERBOSE_BUILD)
62+
set(CMAKE_VERBOSE_MAKEFILE ON)
63+
endif()
64+
65+
endmacro()

0 commit comments

Comments
 (0)