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 17set(dir_pw_third_party_fuzztest "" CACHE PATH 18 "Path to the FuzzTest installation.") 19option(dir_pw_third_party_fuzztest_ADD_SUBDIRECTORY 20 "Whether to add the dir_pw_third_party_fuzztest subdirectory" OFF) 21 22# FuzzTest references RE2, but it is not needed for fuzztest_core. 23# Keep this early in the file to get a better error message when 24# `dir_pw_third_party_fuzztest` is unset. 25add_library(pw_third_party.re2_stub INTERFACE) 26add_library(re2::re2 ALIAS pw_third_party.re2_stub) 27 28if("${dir_pw_third_party_fuzztest}" STREQUAL "") 29 pw_add_error_target(pw_third_party.fuzztest 30 MESSAGE 31 "Attempted to build the pw_third_party.fuzztest without configuring it " 32 "via dir_pw_third_party_fuzztest. " 33 "See https://pigweed.dev/third_party/fuzztest." 34 ) 35 pw_add_error_target(pw_third_party.fuzztest_gtest_main 36 MESSAGE 37 "Attempted to build the pw_third_party.fuzztest_gtest_main without " 38 "configuring it via dir_pw_third_party_fuzztest. " 39 "See https://pigweed.dev/third_party/fuzztest." 40 ) 41 return() 42endif() 43 44if (dir_pw_third_party_fuzztest_ADD_SUBDIRECTORY) 45 # Adapted from @fuzztest//CMakeLists.txt 46 include("${dir_pw_third_party_fuzztest}/cmake/FuzzTestFlagSetup.cmake") 47 include("${dir_pw_third_party_fuzztest}/cmake/FuzzTestHelpers.cmake") 48 49 add_subdirectory("${dir_pw_third_party_fuzztest}/tools" third_party/fuzztest/tools) 50 add_subdirectory("${dir_pw_third_party_fuzztest}/fuzztest" third_party/fuzztest/fuzztest) 51endif() 52 53# See also //pw_fuzzer:fuzztest. 54add_library(pw_third_party.fuzztest INTERFACE) 55target_link_libraries(pw_third_party.fuzztest 56 INTERFACE 57 fuzztest::fuzztest_core 58 pw_unit_test 59 pw_unit_test.googletest 60) 61target_include_directories(pw_third_party.fuzztest 62 INTERFACE 63 "${dir_pw_third_party_fuzztest}" 64) 65 66# See also //target/host/pw_add_test_executable.cmake. 67add_library(pw_third_party.fuzztest_gtest_main INTERFACE) 68target_link_libraries(pw_third_party.fuzztest_gtest_main 69 INTERFACE 70 fuzztest::fuzztest_gtest_main 71) 72