1# Copyright 2022 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15include($ENV{PW_ROOT}/pw_build/pigweed.cmake) 16include($ENV{PW_ROOT}/pw_perf_test/backend.cmake) 17include($ENV{PW_ROOT}/pw_protobuf_compiler/proto.cmake) 18 19pw_add_library(pw_perf_test STATIC 20 PUBLIC_INCLUDES 21 public 22 HEADERS 23 public/pw_perf_test/internal/framework.h 24 public/pw_perf_test/internal/test_info.h 25 public/pw_perf_test/perf_test.h 26 PUBLIC_DEPS 27 pw_perf_test.event_handler 28 pw_perf_test.state 29 pw_perf_test.timer 30 SOURCES 31 framework.cc 32 perf_test.cc 33 test_info.cc 34) 35 36pw_add_library(pw_perf_test.state STATIC 37 PUBLIC_INCLUDES 38 public 39 HEADERS 40 public/pw_perf_test/state.h 41 PUBLIC_DEPS 42 pw_perf_test.timer 43 pw_perf_test.event_handler 44 pw_assert 45 PRIVATE_DEPS 46 pw_log 47 SOURCES 48 state.cc 49) 50 51if(NOT "${pw_perf_test.TIMER_INTERFACE_BACKEND}" STREQUAL "") 52 pw_add_test(pw_perf_test.state_test 53 SOURCES 54 state_test.cc 55 PRIVATE_DEPS 56 pw_assert.assert 57 pw_perf_test 58 GROUPS 59 modules 60 pw_perf_test 61 ) 62endif() 63 64# Event handlers 65 66pw_add_library(pw_perf_test.event_handler INTERFACE 67 HEADERS 68 public/pw_perf_test/event_handler.h 69 PUBLIC_INCLUDES 70 public 71) 72 73pw_add_library(pw_perf_test.logging_event_handler STATIC 74 PUBLIC_INCLUDES 75 public 76 PRIVATE_DEPS 77 pw_log 78 PUBLIC_DEPS 79 pw_perf_test.event_handler 80 pw_perf_test 81 HEADERS 82 public/pw_perf_test/googletest_style_event_handler.h 83 public/pw_perf_test/logging_event_handler.h 84 SOURCES 85 logging_event_handler.cc 86) 87 88pw_add_library(pw_perf_test.logging_main STATIC 89 PUBLIC_DEPS 90 pw_perf_test.logging_event_handler 91 SOURCES 92 logging_main.cc 93) 94 95# Timer facade 96 97pw_add_library(pw_perf_test.duration_unit INTERFACE 98 HEADERS 99 public/pw_perf_test/internal/duration_unit.h 100 PUBLIC_INCLUDES 101 public 102) 103 104pw_add_facade(pw_perf_test.timer INTERFACE 105 BACKEND 106 pw_perf_test.TIMER_INTERFACE_BACKEND 107 HEADERS 108 public/pw_perf_test/internal/timer.h 109 PUBLIC_INCLUDES 110 public 111 PUBLIC_DEPS 112 pw_perf_test.duration_unit 113) 114 115if(NOT "${pw_perf_test.TIMER_INTERFACE_BACKEND}" STREQUAL "") 116 pw_add_test(pw_perf_test.timer_test 117 SOURCES 118 timer_test.cc 119 PRIVATE_DEPS 120 pw_perf_test.timer 121 pw_thread.sleep 122 pw_chrono.system_clock 123 GROUPS 124 modules 125 pw_perf_test 126 ) 127endif() 128 129# Chrono timer facade implementation 130 131pw_add_library(pw_perf_test.chrono_timer INTERFACE 132 HEADERS 133 chrono_public_overrides/pw_perf_test_timer_backend/timer.h 134 public/pw_perf_test/internal/chrono_timer_interface.h 135 PUBLIC_INCLUDES 136 chrono_public_overrides 137 public 138 PUBLIC_DEPS 139 pw_chrono.system_clock 140 pw_perf_test.duration_unit 141) 142 143if(NOT "${pw_perf_test.TIMER_INTERFACE_BACKEND}" 144 STREQUAL "pw_chrono.SYSTEM_CLOCK_BACKEND.NO_BACKEND_SET") 145 pw_add_test(pw_perf_test.chrono_timer_test 146 SOURCES 147 chrono_test.cc 148 PRIVATE_DEPS 149 pw_perf_test.timer 150 pw_thread.sleep 151 pw_chrono.system_clock 152 GROUPS 153 modules 154 pw_perf_test 155 ) 156endif() 157 158# Module-level targets 159 160if(NOT "${pw_perf_test.TIMER_INTERFACE_BACKEND}" 161 STREQUAL "pw_chrono.SYSTEM_CLOCK_BACKEND.NO_BACKEND_SET") 162 add_executable(pw_perf_test.example_perf_test EXCLUDE_FROM_ALL 163 examples/example_perf_test.cc 164 ) 165 166 target_link_libraries(pw_perf_test.example_perf_test 167 pw_perf_test 168 ) 169endif() 170