1*4a64e381SAndroid Build Coastguard Worker# 2*4a64e381SAndroid Build Coastguard Worker# Copyright (c) 2020, The OpenThread Authors. 3*4a64e381SAndroid Build Coastguard Worker# All rights reserved. 4*4a64e381SAndroid Build Coastguard Worker# 5*4a64e381SAndroid Build Coastguard Worker# Redistribution and use in source and binary forms, with or without 6*4a64e381SAndroid Build Coastguard Worker# modification, are permitted provided that the following conditions are met: 7*4a64e381SAndroid Build Coastguard Worker# 1. Redistributions of source code must retain the above copyright 8*4a64e381SAndroid Build Coastguard Worker# notice, this list of conditions and the following disclaimer. 9*4a64e381SAndroid Build Coastguard Worker# 2. Redistributions in binary form must reproduce the above copyright 10*4a64e381SAndroid Build Coastguard Worker# notice, this list of conditions and the following disclaimer in the 11*4a64e381SAndroid Build Coastguard Worker# documentation and/or other materials provided with the distribution. 12*4a64e381SAndroid Build Coastguard Worker# 3. Neither the name of the copyright holder nor the 13*4a64e381SAndroid Build Coastguard Worker# names of its contributors may be used to endorse or promote products 14*4a64e381SAndroid Build Coastguard Worker# derived from this software without specific prior written permission. 15*4a64e381SAndroid Build Coastguard Worker# 16*4a64e381SAndroid Build Coastguard Worker# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17*4a64e381SAndroid Build Coastguard Worker# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18*4a64e381SAndroid Build Coastguard Worker# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19*4a64e381SAndroid Build Coastguard Worker# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20*4a64e381SAndroid Build Coastguard Worker# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21*4a64e381SAndroid Build Coastguard Worker# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22*4a64e381SAndroid Build Coastguard Worker# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23*4a64e381SAndroid Build Coastguard Worker# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24*4a64e381SAndroid Build Coastguard Worker# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25*4a64e381SAndroid Build Coastguard Worker# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26*4a64e381SAndroid Build Coastguard Worker# POSSIBILITY OF SUCH DAMAGE. 27*4a64e381SAndroid Build Coastguard Worker# 28*4a64e381SAndroid Build Coastguard Worker 29*4a64e381SAndroid Build Coastguard Workercmake_minimum_required(VERSION 3.14) 30*4a64e381SAndroid Build Coastguard Workerproject(openthread-br-gtest) 31*4a64e381SAndroid Build Coastguard Worker 32*4a64e381SAndroid Build Coastguard Worker# GoogleTest requires at least C++14 33*4a64e381SAndroid Build Coastguard Workerset(CMAKE_CXX_STANDARD 14) 34*4a64e381SAndroid Build Coastguard Workerset(CMAKE_CXX_STANDARD_REQUIRED ON) 35*4a64e381SAndroid Build Coastguard Worker 36*4a64e381SAndroid Build Coastguard Workerinclude(FetchContent) 37*4a64e381SAndroid Build Coastguard WorkerFetchContent_Declare( 38*4a64e381SAndroid Build Coastguard Worker googletest 39*4a64e381SAndroid Build Coastguard Worker URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip 40*4a64e381SAndroid Build Coastguard Worker) 41*4a64e381SAndroid Build Coastguard Worker# For Windows: Prevent overriding the parent project's compiler/linker settings 42*4a64e381SAndroid Build Coastguard Workerset(gtest_force_shared_crt ON CACHE BOOL "" FORCE) 43*4a64e381SAndroid Build Coastguard WorkerFetchContent_MakeAvailable(googletest) 44*4a64e381SAndroid Build Coastguard Worker 45*4a64e381SAndroid Build Coastguard Workerinclude(GoogleTest) 46*4a64e381SAndroid Build Coastguard Worker 47*4a64e381SAndroid Build Coastguard Workeradd_executable(otbr-gtest-unit 48*4a64e381SAndroid Build Coastguard Worker test_async_task.cpp 49*4a64e381SAndroid Build Coastguard Worker test_common_types.cpp 50*4a64e381SAndroid Build Coastguard Worker test_dns_utils.cpp 51*4a64e381SAndroid Build Coastguard Worker test_logging.cpp 52*4a64e381SAndroid Build Coastguard Worker test_once_callback.cpp 53*4a64e381SAndroid Build Coastguard Worker test_pskc.cpp 54*4a64e381SAndroid Build Coastguard Worker test_task_runner.cpp 55*4a64e381SAndroid Build Coastguard Worker) 56*4a64e381SAndroid Build Coastguard Workertarget_link_libraries(otbr-gtest-unit 57*4a64e381SAndroid Build Coastguard Worker mbedtls 58*4a64e381SAndroid Build Coastguard Worker otbr-common 59*4a64e381SAndroid Build Coastguard Worker otbr-ncp 60*4a64e381SAndroid Build Coastguard Worker otbr-utils 61*4a64e381SAndroid Build Coastguard Worker GTest::gmock_main 62*4a64e381SAndroid Build Coastguard Worker) 63*4a64e381SAndroid Build Coastguard Workergtest_discover_tests(otbr-gtest-unit) 64*4a64e381SAndroid Build Coastguard Worker 65*4a64e381SAndroid Build Coastguard Workerif(OTBR_MDNS) 66*4a64e381SAndroid Build Coastguard Worker add_executable(otbr-gtest-mdns-subscribe 67*4a64e381SAndroid Build Coastguard Worker test_mdns_subscribe.cpp 68*4a64e381SAndroid Build Coastguard Worker ) 69*4a64e381SAndroid Build Coastguard Worker target_link_libraries(otbr-gtest-mdns-subscribe 70*4a64e381SAndroid Build Coastguard Worker otbr-common 71*4a64e381SAndroid Build Coastguard Worker otbr-mdns 72*4a64e381SAndroid Build Coastguard Worker GTest::gmock_main 73*4a64e381SAndroid Build Coastguard Worker ) 74*4a64e381SAndroid Build Coastguard Worker gtest_discover_tests(otbr-gtest-mdns-subscribe) 75*4a64e381SAndroid Build Coastguard Workerendif() 76*4a64e381SAndroid Build Coastguard Worker 77*4a64e381SAndroid Build Coastguard Workeradd_executable(otbr-posix-gtest-unit 78*4a64e381SAndroid Build Coastguard Worker test_netif.cpp 79*4a64e381SAndroid Build Coastguard Worker) 80*4a64e381SAndroid Build Coastguard Workertarget_link_libraries(otbr-posix-gtest-unit 81*4a64e381SAndroid Build Coastguard Worker otbr-posix 82*4a64e381SAndroid Build Coastguard Worker GTest::gmock_main 83*4a64e381SAndroid Build Coastguard Worker) 84*4a64e381SAndroid Build Coastguard Workergtest_discover_tests(otbr-posix-gtest-unit PROPERTIES LABELS "sudo") 85*4a64e381SAndroid Build Coastguard Worker 86*4a64e381SAndroid Build Coastguard Workeradd_executable(otbr-gtest-host-api 87*4a64e381SAndroid Build Coastguard Worker ${OTBR_PROJECT_DIRECTORY}/src/ncp/rcp_host.cpp 88*4a64e381SAndroid Build Coastguard Worker ${OPENTHREAD_PROJECT_DIRECTORY}/tests/gtest/fake_platform.cpp 89*4a64e381SAndroid Build Coastguard Worker fake_posix_platform.cpp 90*4a64e381SAndroid Build Coastguard Worker test_rcp_host_api.cpp 91*4a64e381SAndroid Build Coastguard Worker) 92*4a64e381SAndroid Build Coastguard Workertarget_include_directories(otbr-gtest-host-api 93*4a64e381SAndroid Build Coastguard Worker PRIVATE 94*4a64e381SAndroid Build Coastguard Worker ${OTBR_PROJECT_DIRECTORY}/src 95*4a64e381SAndroid Build Coastguard Worker ${OPENTHREAD_PROJECT_DIRECTORY}/src/core 96*4a64e381SAndroid Build Coastguard Worker ${OPENTHREAD_PROJECT_DIRECTORY}/tests/gtest 97*4a64e381SAndroid Build Coastguard Worker) 98*4a64e381SAndroid Build Coastguard Workertarget_link_libraries(otbr-gtest-host-api 99*4a64e381SAndroid Build Coastguard Worker mbedtls 100*4a64e381SAndroid Build Coastguard Worker otbr-common 101*4a64e381SAndroid Build Coastguard Worker otbr-utils 102*4a64e381SAndroid Build Coastguard Worker GTest::gmock_main 103*4a64e381SAndroid Build Coastguard Worker) 104*4a64e381SAndroid Build Coastguard Workergtest_discover_tests(otbr-gtest-host-api) 105