diff --git a/CMakeLists.txt b/CMakeLists.txt index a7290a3b03..f85615fc9c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,14 +13,14 @@ endif() project(mbed-os) # Add all paths to the list files within Mbed OS -list(APPEND CMAKE_MODULE_PATH +list(APPEND CMAKE_MODULE_PATH "${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" ) option(BUILD_TESTING "Run unit tests only." OFF) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) - include(CTest) + include(CTest) add_subdirectory(UNITTESTS) endif() @@ -68,19 +68,19 @@ if(${CMAKE_CROSSCOMPILING}) "Invalid printf library type '${MBED_PRINTF_LIB}'. Possible values:\n ${MBED_PRINTF_LIB_TYPES}" ) endif() - + mbed_set_cpu_core_definitions(mbed-core) if(${MBED_TOOLCHAIN_FILE_USED}) mbed_set_profile_options(mbed-core ${MBED_TOOLCHAIN}) mbed_set_c_lib(mbed-core ${MBED_C_LIB}) mbed_set_printf_lib(mbed-core ${MBED_PRINTF_LIB}) - + target_compile_features(mbed-core INTERFACE c_std_11 cxx_std_14 ) - + endif() target_compile_definitions(mbed-core @@ -98,7 +98,7 @@ if(${CMAKE_CROSSCOMPILING}) endif() # We need to generate a "response file" to pass to the C preprocessor when we preprocess the linker - # script, because of path le ngth limitations on Windows. We set the response file and bind the path + # script, because of path length limitations on Windows. We set the response file and bind the path # to a global property here. The MBED_TARGET being built queries this global property when it sets # the linker script. # @@ -110,7 +110,7 @@ if(${CMAKE_CROSSCOMPILING}) # using response files or global properties. mbed_generate_options_for_linker(mbed-core RESPONSE_FILE_PATH) set_property(GLOBAL PROPERTY COMPILE_DEFS_RESPONSE_FILE ${RESPONSE_FILE_PATH}) - + # Add compile definitions for backward compatibility with the toolchain # supported. New source files should instead check for __GNUC__ and __clang__ # for the GCC_ARM and ARM toolchains respectively. @@ -164,7 +164,7 @@ if(${CMAKE_CROSSCOMPILING}) string(TOLOWER ${MBED_TARGET} MBED_TARGET_CONVERTED) string(REPLACE "_" "-" MBED_TARGET_CONVERTED ${MBED_TARGET_CONVERTED}) string(PREPEND MBED_TARGET_CONVERTED "mbed-") - + target_link_libraries(mbed-core INTERFACE ${MBED_TARGET_CONVERTED}) endif() diff --git a/UNITTESTS/CMakeLists.txt b/UNITTESTS/CMakeLists.txt index 469cb320a6..35e26dbe44 100644 --- a/UNITTESTS/CMakeLists.txt +++ b/UNITTESTS/CMakeLists.txt @@ -19,7 +19,7 @@ include(FetchContent) # Download and unpack googletest FetchContent_Declare(googletest GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG release-1.10.0 + GIT_TAG master ) FetchContent_MakeAvailable(googletest) diff --git a/UNITTESTS/stubs/CMakeLists.txt b/UNITTESTS/stubs/CMakeLists.txt index 942adbcbf8..2a66ebd9cb 100644 --- a/UNITTESTS/stubs/CMakeLists.txt +++ b/UNITTESTS/stubs/CMakeLists.txt @@ -45,13 +45,13 @@ target_include_directories(mbed-headers-base ) target_include_directories(mbed-headers-storage - INTERFACE + INTERFACE ${mbed-os_SOURCE_DIR}/storage/filesystem/fat/include ${mbed-os_SOURCE_DIR}/storage/filesystem/fat/ChaN ${mbed-os_SOURCE_DIR}/storage/filesystem/littlefs ${mbed-os_SOURCE_DIR}/storage/filesystem/littlefs/include ${mbed-os_SOURCE_DIR}/storage/filesystem/littlefsv2/littlefs - ${mbed-os_SOURCE_DIR}/storage/filesystem/littlefsv2/littlefs/bd + ${mbed-os_SOURCE_DIR}/storage/filesystem/littlefsv2/littlefs/bd ${mbed-os_SOURCE_DIR}/storage/filesystem/littlefs/littlefs ${mbed-os_SOURCE_DIR}/storage/blockdevice/include ${mbed-os_SOURCE_DIR}/storage/filesystem/include @@ -91,7 +91,7 @@ target_include_directories(mbed-headers-drivers INTERFACE ${mbed-os_SOURCE_DIR}/drivers ${mbed-os_SOURCE_DIR}/drivers/include - ${mbed-os_SOURCE_DIR}/drivers/include/drivers + ${mbed-os_SOURCE_DIR}/drivers/include/drivers ) target_include_directories(mbed-headers-events @@ -100,7 +100,7 @@ target_include_directories(mbed-headers-events ${mbed-os_SOURCE_DIR}/events/tests/UNITTESTS/target_h/equeue ${mbed-os_SOURCE_DIR}/events/include ${mbed-os_SOURCE_DIR}/events/include/events - ${mbed-os_SOURCE_DIR}/events/include/events/internal + ${mbed-os_SOURCE_DIR}/events/include/events/internal ) target_include_directories(mbed-headers-hal diff --git a/connectivity/cellular/CMakeLists.txt b/connectivity/cellular/CMakeLists.txt index 8455c59b4c..d7ce11f90d 100644 --- a/connectivity/cellular/CMakeLists.txt +++ b/connectivity/cellular/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -if(NOT ${CMAKE_CROSSCOMPILING}) +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) add_subdirectory(tests/UNITTESTS) endif() diff --git a/connectivity/lorawan/CMakeLists.txt b/connectivity/lorawan/CMakeLists.txt index 552a72a6fe..941b01e04e 100644 --- a/connectivity/lorawan/CMakeLists.txt +++ b/connectivity/lorawan/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -if(NOT ${CMAKE_CROSSCOMPILING}) +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) add_subdirectory(tests/UNITTESTS) endif() diff --git a/connectivity/netsocket/CMakeLists.txt b/connectivity/netsocket/CMakeLists.txt index 0ce8a2f466..62bea8cc63 100644 --- a/connectivity/netsocket/CMakeLists.txt +++ b/connectivity/netsocket/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -if(NOT ${CMAKE_CROSSCOMPILING}) +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) add_subdirectory(tests/UNITTESTS) endif() diff --git a/drivers/CMakeLists.txt b/drivers/CMakeLists.txt index 4d26ac6dec..9079d3d75a 100644 --- a/drivers/CMakeLists.txt +++ b/drivers/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -if(NOT ${CMAKE_CROSSCOMPILING}) +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) add_subdirectory(tests/UNITTESTS) endif() diff --git a/events/CMakeLists.txt b/events/CMakeLists.txt index 1cda3156d3..da4d693511 100644 --- a/events/CMakeLists.txt +++ b/events/CMakeLists.txt @@ -1,9 +1,10 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -if(NOT ${CMAKE_CROSSCOMPILING}) +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) add_subdirectory(tests/UNITTESTS) else() + add_library(mbed-events INTERFACE) target_include_directories(mbed-events diff --git a/platform/CMakeLists.txt b/platform/CMakeLists.txt index b79a4a28cb..df83719fc6 100644 --- a/platform/CMakeLists.txt +++ b/platform/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -if(NOT ${CMAKE_CROSSCOMPILING}) +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) add_subdirectory(tests/UNITTESTS) endif() diff --git a/platform/tests/UNITTESTS/ATCmdParser/CMakeLists.txt b/platform/tests/UNITTESTS/ATCmdParser/CMakeLists.txt index d2bc69e55b..eeda6edee1 100644 --- a/platform/tests/UNITTESTS/ATCmdParser/CMakeLists.txt +++ b/platform/tests/UNITTESTS/ATCmdParser/CMakeLists.txt @@ -14,8 +14,8 @@ target_sources(${TEST_NAME} target_link_libraries(${TEST_NAME} PRIVATE mbed-headers - mbed-stubs-headers - mbed-stubs-platform + mbed-stubs-headers + mbed-stubs-platform gmock_main ) diff --git a/storage/blockdevice/CMakeLists.txt b/storage/blockdevice/CMakeLists.txt index cbbb76f0aa..9f847d4360 100644 --- a/storage/blockdevice/CMakeLists.txt +++ b/storage/blockdevice/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -if(NOT ${CMAKE_CROSSCOMPILING}) +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) add_subdirectory(tests/UNITTESTS) endif() diff --git a/storage/kvstore/filesystemstore/CMakeLists.txt b/storage/kvstore/filesystemstore/CMakeLists.txt index aeb8aef191..7289fe8b8d 100644 --- a/storage/kvstore/filesystemstore/CMakeLists.txt +++ b/storage/kvstore/filesystemstore/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -if(NOT ${CMAKE_CROSSCOMPILING}) +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) add_subdirectory(tests/UNITTESTS) endif() diff --git a/storage/kvstore/tdbstore/CMakeLists.txt b/storage/kvstore/tdbstore/CMakeLists.txt index a1cb048ad9..d4f8d92ed5 100644 --- a/storage/kvstore/tdbstore/CMakeLists.txt +++ b/storage/kvstore/tdbstore/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -if(NOT ${CMAKE_CROSSCOMPILING}) +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) add_subdirectory(tests/UNITTESTS) endif()