xref: /aosp_15_r20/external/pigweed/pw_fuzzer/CMakeLists.txt (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1# Copyright 2023 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)
16
17################################################################################
18# FuzzTest support
19#
20# Create FuzzTest-style fuzzers by adding a dep on pw_fuzzer.fuzztest
21
22# If a project configure `pw_unit_test_BACKEND` to use FuzzTest, this
23# target pulls in the "real" FuzzTest. Otherwise, it uses a "stub" which
24# converts invocations of `FUZZ_TEST` to disabled empty unit tests.
25if(pw_unit_test_BACKEND STREQUAL "pw_third_party.fuzztest")
26  pw_add_library(pw_fuzzer.fuzztest INTERFACE
27    HEADERS
28      public/pw_fuzzer/fuzztest.h
29      private/pw_fuzzer/internal/fuzztest.h
30    PUBLIC_DEPS
31      pw_containers
32      pw_result
33      pw_status
34      pw_string
35      pw_third_party.fuzztest
36    PUBLIC_INCLUDES
37      public
38      private
39  )
40else()
41  pw_add_library(pw_fuzzer.fuzztest INTERFACE
42    HEADERS
43      public_overrides/fuzztest/fuzztest.h
44      private_overrides/pw_fuzzer/internal/fuzztest.h
45    PUBLIC_DEPS
46      pw_containers
47      pw_result
48      pw_status
49      pw_string
50    PUBLIC_INCLUDES
51      public
52      public_overrides
53      private_overrides
54  )
55endif()
56
57add_subdirectory("examples/fuzztest")
58