Home | History | Annotate | Download | only in libfuzzer
      1 # Copyright 2017 Google Inc. All rights reserved.
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
      4 # you may not use this file except in compliance with the License.
      5 # You may obtain a copy of the License at
      6 #
      7 #     http://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,
     11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
     14 
     15 add_executable(libfuzzer_example_test
     16                libfuzzer_example_test.cc)
     17 target_link_libraries(libfuzzer_example_test
     18                       ${GTEST_BOTH_LIBRARIES}
     19                       ${CMAKE_THREAD_LIBS_INIT})
     20 add_test(test.libfuzzer_example_test libfuzzer_example_test --gtest_color=yes AUTO)
     21 add_dependencies(check libfuzzer_example_test)
     22 
     23 protobuf_generate_cpp(LIB_FUZZER_EXAMPLE_PROTO_SRCS
     24                       LIB_FUZZER_EXAMPLE_PROTO_HDRS
     25                       libfuzzer_example.proto)
     26 
     27 add_library(fuzzer-example-proto
     28             ${LIB_FUZZER_EXAMPLE_PROTO_SRCS})
     29 set_property(TARGET fuzzer-example-proto
     30              PROPERTY COMPILE_FLAGS ${NO_FUZZING_FLAGS})
     31 
     32 foreach(fuzzer libfuzzer_example libfuzzer_bin_example)
     33   add_executable(${fuzzer} ${fuzzer}.cc)
     34   target_link_libraries(${fuzzer}
     35                         fuzzer-example-proto
     36                         protobuf-mutator-libfuzzer
     37                         ${LIB_PROTO_MUTATOR_FUZZER_LIBRARIES})
     38   set_property(TARGET ${fuzzer}
     39                PROPERTY COMPILE_FLAGS ${FUZZING_FLAGS})
     40   set_property(TARGET ${fuzzer}
     41                PROPERTY LINK_FLAGS ${FUZZING_FLAGS_BINARY})
     42   add_dependencies(libfuzzer_example_test ${fuzzer})
     43 endforeach(fuzzer)
     44