mbed-os/platform
Robert Walton a0befae2d4 CMake: Only build unit tests if Mbed OS is the current project
Typically when adding a unit test directory to a CMake project a check
will be used to ensure the subdirectory is added only if the following
are true:

* The BUILD_TESTING option is set to ON.
* The current CMake project is the top-level project.

The reason being, if a downstream project includes our project they
generally don't want to build our unit tests.

In mbed-os, we do correctly specify the above condition before adding
the central UNITTEST subdirectory, which fetches googletest and adds the
"stub" libraries the unit tests depend on. However, we only check if
CMAKE_CROSSCOMPILING is OFF (or undefined) before actually adding the
unit tests. This mismatched logic would lead to unexpected build
failures in various scenarios. One likely case could be: a downstream
project including mbed-os happens to set CMAKE_CROSSCOMPILING to
OFF/undefined for any reason (possibly to build its own unit tests).
mbed-os would go ahead and attempt to build its tests without fetching
googletest or adding the required stub targets.

To fix the issue replace the check for CMAKE_CROSSCOMPILING in the unit
tests with the same BUILD_TESTING idiom we use for adding the central
UNITTESTS subdirectory.
2021-06-10 23:34:14 +01:00
..
FEATURE_EXPERIMENTAL_API psa: Remove outdated macro checks in tests 2021-05-19 11:00:26 +01:00
bare_metal Added missing blockdevice mbed_lib.json 2020-11-02 16:35:26 +00:00
cxxsupport Namespace scope mbed:: added for CriticalSectionLock used in Atomic templates 2021-06-08 22:55:43 +02:00
docs fix(docs): corrects various typos in project documentation 2021-04-23 23:31:11 -05:00
include/platform Update Mbed version block 2021-05-17 12:12:30 +01:00
mbed-trace Trace: Change tr_debug color from gray to bright blue 2021-05-05 12:34:48 -07:00
randlib CMake: Rename CMake targets 2020-11-06 17:25:22 +00:00
source Update GCC except.S to support ARMC6 2021-05-24 13:54:57 +01:00
tests CMake: unit-tests: Remove trailing whitespace 2021-06-10 23:24:43 +01:00
CMakeLists.txt CMake: Only build unit tests if Mbed OS is the current project 2021-06-10 23:34:14 +01:00
mbed_lib.json M2354: Support TF-M 2021-05-26 09:35:02 +08:00