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 15add_subdirectory(libfuzzer) 16 17add_library(protobuf-mutator 18 binary_format.cc 19 mutator.cc 20 text_format.cc 21 utf8_fix.cc) 22target_link_libraries(protobuf-mutator 23 ${PROTOBUF_LIBRARIES}) 24set_target_properties(protobuf-mutator PROPERTIES 25 COMPILE_FLAGS "${NO_FUZZING_FLAGS}" 26 SOVERSION 0) 27 28if (LIB_PROTO_MUTATOR_TESTING) 29 protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS 30 mutator_test_proto2.proto 31 mutator_test_proto3.proto) 32 33 add_library(mutator-test-proto 34 ${PROTO_SRCS}) 35 36 add_executable(mutator_test 37 mutator_test.cc 38 utf8_fix_test.cc 39 weighted_reservoir_sampler_test.cc) 40 target_link_libraries(mutator_test 41 protobuf-mutator 42 mutator-test-proto 43 ${ZLIB_LIBRARIES} 44 ${GTEST_BOTH_LIBRARIES} 45 ${CMAKE_THREAD_LIBS_INIT}) 46 47 ProcessorCount(CPU_COUNT) 48 math(EXPR TEST_SHARDS_COUNT 2*${CPU_COUNT}) 49 math(EXPR TEST_SHARDS_MAX ${TEST_SHARDS_COUNT}-1) 50 foreach(SHARD RANGE ${TEST_SHARDS_MAX}) 51 add_test(test.protobuf_mutator_test_${SHARD} mutator_test --gtest_color=yes AUTO) 52 set_property( 53 TEST test.protobuf_mutator_test_${SHARD} 54 APPEND PROPERTY ENVIRONMENT 55 GTEST_SHARD_INDEX=${SHARD} 56 GTEST_TOTAL_SHARDS=${TEST_SHARDS_COUNT}) 57 endforeach(SHARD) 58 59 add_dependencies(check mutator_test) 60endif() 61 62install(TARGETS protobuf-mutator 63 EXPORT libprotobuf-mutatorTargets 64 ARCHIVE DESTINATION ${LIB_DIR} 65 LIBRARY DESTINATION ${LIB_DIR} 66 INCLUDES DESTINATION include/libprotobuf-mutator include/libprotobuf-mutator/src) 67