1# 2# Copyright (c) 2024, The OpenThread Authors. 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions are met: 7# 1. Redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer. 9# 2. Redistributions in binary form must reproduce the above copyright 10# notice, this list of conditions and the following disclaimer in the 11# documentation and/or other materials provided with the distribution. 12# 3. Neither the name of the copyright holder nor the 13# names of its contributors may be used to endorse or promote products 14# derived from this software without specific prior written permission. 15# 16# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26# POSSIBILITY OF SUCH DAMAGE. 27# 28 29cmake_minimum_required(VERSION 3.14) 30project(openthread-gtest) 31 32# GoogleTest requires at least C++14 33set(CMAKE_CXX_STANDARD 14) 34set(CMAKE_CXX_STANDARD_REQUIRED ON) 35 36include(FetchContent) 37FetchContent_Declare( 38 googletest 39 URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip 40) 41# For Windows: Prevent overriding the parent project's compiler/linker settings 42set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) 43FetchContent_MakeAvailable(googletest) 44 45include(GoogleTest) 46 47add_library(ot-fake-platform 48 fake_platform.cpp 49) 50target_link_libraries(ot-fake-platform 51 ot-config 52) 53 54add_library(ot-fake-ftd INTERFACE) 55target_link_libraries(ot-fake-ftd INTERFACE 56 openthread-ftd 57 ot-fake-platform 58) 59 60add_executable(ot-ftd-gtest 61 dataset_test.cpp 62) 63target_link_libraries(ot-ftd-gtest 64 ot-fake-ftd 65 GTest::gmock_main 66) 67gtest_discover_tests(ot-ftd-gtest) 68 69add_library(ot-fake-rcp 70 fake_coprocessor_platform.cpp 71) 72target_link_libraries(ot-fake-rcp 73 openthread-hdlc 74 openthread-rcp 75 openthread-radio-spinel 76 openthread-radio 77 ot-fake-platform 78) 79 80add_executable(ot-radio-spinel-rcp-gtest 81 radio_spinel_rcp_test.cpp 82) 83target_link_libraries(ot-radio-spinel-rcp-gtest 84 ot-fake-rcp 85 GTest::gmock_main 86) 87 88gtest_discover_tests(ot-radio-spinel-rcp-gtest) 89