CMake: Greentea test CMakeLists.txt refactoring

- Added the new CMake `MBED_TEST_LINK_LIBRARIES` command-line argument support to receive
  all dependent libraries for the particular greentea test suite.
For example:
- To select mbed-os library, use cmake with -DMBED_TEST_LINK_LIBRARIES=mbed-os
- To select baremetal library, use cmake with -DMBED_TEST_LINK_LIBRARIES=mbed-baremetal
- To select baremetal with external error logging library to the test with -D "MBED_TEST_LINK_LIBRARIES=mbed-baremetal ext-errorlogging"
pull/14247/head
Rajkumar Kanagaraj 2021-02-08 08:58:30 -08:00
parent dd33463518
commit b1c4c446d2
1 changed files with 11 additions and 4 deletions

View File

@ -55,10 +55,17 @@ macro(mbed_greentea_add_test)
${MBED_GREENTEA_TEST_SOURCES}
)
if(MBED_BAREMETAL_GREENTEA_TEST)
list(APPEND MBED_GREENTEA_TEST_REQUIRED_LIBS mbed-baremetal mbed-greentea)
else()
list(APPEND MBED_GREENTEA_TEST_REQUIRED_LIBS mbed-os mbed-greentea)
# The CMake MBED_TEST_LINK_LIBRARIES command-line argument is to get greentea test all dependent libraries.
# For example:
# - To select mbed-os library, use cmake with -DMBED_TEST_LINK_LIBRARIES=mbed-os
# - To select baremetal library, use cmake with -DMBED_TEST_LINK_LIBRARIES=mbed-baremetal
# - To select baremetal with extra external error logging library to the test, use cmake with
# -D "MBED_TEST_LINK_LIBRARIES=mbed-baremetal ext-errorlogging"
if (DEFINED MBED_TEST_LINK_LIBRARIES)
separate_arguments(MBED_TEST_LINK_LIBRARIES)
list(APPEND MBED_GREENTEA_TEST_REQUIRED_LIBS ${MBED_TEST_LINK_LIBRARIES} mbed-greentea)
else()
list(APPEND MBED_GREENTEA_TEST_REQUIRED_LIBS mbed-greentea)
endif()
target_link_libraries(${TEST_NAME}