<commit_before>cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 17)

project(autofdo)

function (config_without_llvm)
  add_subdirectory(third_party/abseil)
  add_subdirectory(third_party/glog)

  include_directories(${LLVM_INCLUDE_DIRS}
    ${CMAKE_HOME_DIRECTORY}
    third_party/glog/src
    third_party/abseil
    third_party/perf_data_converter/src
    third_party/perf_data_converter/src/quipper
    util
    ${PROJECT_BINARY_DIR}
    ${PROJECT_BINARY_DIR}/third_party/glog)

  find_library (LIBELF_LIBRARIES NAMES elf REQUIRED)
  find_library (LIBCRYPTO_LIBRARIES NAMES crypto REQUIRED)

  find_package(Protobuf REQUIRED)
  protobuf_generate_cpp(PERF_DATA_PROTO_CC PERF_DATA_PROTO_HDR third_party/perf_data_converter/src/quipper/perf_data.proto)
  protobuf_generate_cpp(PERF_PARSER_OPTIONS_CC PERF_PARSER_OPTIONS_HDR third_party/perf_data_converter/src/quipper/perf_parser_options.proto)
  protobuf_generate_cpp(PERF_STAT_CC PERF_STAT_HDR third_party/perf_data_converter/src/quipper/perf_stat.proto)
  add_library(perf_data_proto OBJECT ${PERF_DATA_PROTO_CC})
  add_library(perf_parser_options_proto OBJECT ${PERF_PARSER_OPTIONS_CC})
  add_library(perf_stat_proto OBJECT ${PERF_STAT_CC})

  add_library(create_gcov_lib OBJECT
    create_gcov.cc
    gcov.cc
    instruction_map.cc
    legacy_addr2line.cc
    profile.cc
    profile_creator.cc
    profile_writer.cc
    sample_reader.cc
    symbol_map.cc
    util/symbolize/addr2line_inlinestack.cc
    util/symbolize/bytereader.cc
    util/symbolize/functioninfo.cc
    util/symbolize/dwarf2reader.cc
    util/symbolize/dwarf3ranges.cc
    util/symbolize/elf_reader.cc
  )
  add_dependencies(create_gcov_lib perf_data_proto)
  add_dependencies(create_gcov_lib perf_parser_options_proto)
  add_dependencies(create_gcov_lib perf_stat_proto)

  add_library(quipper_perf OBJECT 
    third_party/perf_data_converter/src/quipper/address_mapper.cc
    third_party/perf_data_converter/src/quipper/base/logging.cc
    third_party/perf_data_converter/src/quipper/binary_data_utils.cc
    third_party/perf_data_converter/src/quipper/binary_data_utils.cc
    third_party/perf_data_converter/src/quipper/buffer_reader.cc
    third_party/perf_data_converter/src/quipper/buffer_writer.cc
    third_party/perf_data_converter/src/quipper/compat/log_level.cc
    third_party/perf_data_converter/src/quipper/data_reader.cc
    third_party/perf_data_converter/src/quipper/data_writer.cc
    third_party/perf_data_converter/src/quipper/dso.cc
    third_party/perf_data_converter/src/quipper/file_reader.cc
    third_party/perf_data_converter/src/quipper/file_utils.cc
    third_party/perf_data_converter/src/quipper/huge_page_deducer.cc
    third_party/perf_data_converter/src/quipper/perf_buildid.cc
    third_party/perf_data_converter/src/quipper/perf_data_utils.cc
    third_party/perf_data_converter/src/quipper/perf_serializer.cc
    third_party/perf_data_converter/src/quipper/perf_reader.cc
    third_party/perf_data_converter/src/quipper/perf_parser.cc
    third_party/perf_data_converter/src/quipper/sample_info_reader.cc
    ${PERF_DATA_PROTO_HDR}
    ${PERF_DATA_PROTO_CC}
    ${PERF_PARSER_OPTIONS_HDR}
    ${PERF_PARSER_OPTIONS_CC}
    ${PERF_STAT_CC}
    ${PERF_STAT_HDR})
  target_include_directories(quipper_perf PRIVATE
    third_party/abseil)
  target_include_directories(quipper_perf BEFORE
    PUBLIC
    third_party/perf_data_converter/src
    third_party/perf_data_converter/src/quipper)
  target_link_libraries(quipper_perf ${Protobuf_LIBRARIES} ${LIBELF_LIBRARIES} ${LIBCRYPTO_LIBRARIES})

  add_executable(create_gcov)
  target_link_libraries(create_gcov
    absl::flags
    absl::flags_parse
    create_gcov_lib
    glog
    quipper_perf
  )

  add_library(dump_gcov_lib OBJECT
    dump_gcov.cc
    gcov.cc
    instruction_map.cc
    profile.cc
    profile_reader.cc
    symbol_map.cc
    util/symbolize/elf_reader.cc
  )

  add_executable(dump_gcov)
  target_link_libraries(dump_gcov
    absl::flags
    absl::flags_parse
    dump_gcov_lib
    glog
  )
endfunction ()

function (config_with_llvm)<commit_msg>Fix build dependence issue related with dump_gcov and perf_*.proto.<commit_after>cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 17)

project(autofdo)

function (config_without_llvm)
  add_subdirectory(third_party/abseil)
  add_subdirectory(third_party/glog)

  include_directories(${LLVM_INCLUDE_DIRS}
    ${CMAKE_HOME_DIRECTORY}
    third_party/glog/src
    third_party/abseil
    third_party/perf_data_converter/src
    third_party/perf_data_converter/src/quipper
    util
    ${PROJECT_BINARY_DIR}
    ${PROJECT_BINARY_DIR}/third_party/glog)

  find_library (LIBELF_LIBRARIES NAMES elf REQUIRED)
  find_library (LIBCRYPTO_LIBRARIES NAMES crypto REQUIRED)

  find_package(Protobuf REQUIRED)
  protobuf_generate_cpp(PERF_DATA_PROTO_CC PERF_DATA_PROTO_HDR third_party/perf_data_converter/src/quipper/perf_data.proto)
  protobuf_generate_cpp(PERF_PARSER_OPTIONS_CC PERF_PARSER_OPTIONS_HDR third_party/perf_data_converter/src/quipper/perf_parser_options.proto)
  protobuf_generate_cpp(PERF_STAT_CC PERF_STAT_HDR third_party/perf_data_converter/src/quipper/perf_stat.proto)
  add_library(perf_data_proto OBJECT ${PERF_DATA_PROTO_CC})
  add_library(perf_parser_options_proto OBJECT ${PERF_PARSER_OPTIONS_CC})
  add_library(perf_stat_proto OBJECT ${PERF_STAT_CC})

  add_library(create_gcov_lib OBJECT
    create_gcov.cc
    gcov.cc
    instruction_map.cc
    legacy_addr2line.cc
    profile.cc
    profile_creator.cc
    profile_writer.cc
    sample_reader.cc
    symbol_map.cc
    util/symbolize/addr2line_inlinestack.cc
    util/symbolize/bytereader.cc
    util/symbolize/functioninfo.cc
    util/symbolize/dwarf2reader.cc
    util/symbolize/dwarf3ranges.cc
    util/symbolize/elf_reader.cc
  )
  add_dependencies(create_gcov_lib perf_data_proto)
  add_dependencies(create_gcov_lib perf_parser_options_proto)
  add_dependencies(create_gcov_lib perf_stat_proto)

  add_library(quipper_perf OBJECT 
    third_party/perf_data_converter/src/quipper/address_mapper.cc
    third_party/perf_data_converter/src/quipper/base/logging.cc
    third_party/perf_data_converter/src/quipper/binary_data_utils.cc
    third_party/perf_data_converter/src/quipper/binary_data_utils.cc
    third_party/perf_data_converter/src/quipper/buffer_reader.cc
    third_party/perf_data_converter/src/quipper/buffer_writer.cc
    third_party/perf_data_converter/src/quipper/compat/log_level.cc
    third_party/perf_data_converter/src/quipper/data_reader.cc
    third_party/perf_data_converter/src/quipper/data_writer.cc
    third_party/perf_data_converter/src/quipper/dso.cc
    third_party/perf_data_converter/src/quipper/file_reader.cc
    third_party/perf_data_converter/src/quipper/file_utils.cc
    third_party/perf_data_converter/src/quipper/huge_page_deducer.cc
    third_party/perf_data_converter/src/quipper/perf_buildid.cc
    third_party/perf_data_converter/src/quipper/perf_data_utils.cc
    third_party/perf_data_converter/src/quipper/perf_serializer.cc
    third_party/perf_data_converter/src/quipper/perf_reader.cc
    third_party/perf_data_converter/src/quipper/perf_parser.cc
    third_party/perf_data_converter/src/quipper/sample_info_reader.cc
    ${PERF_DATA_PROTO_HDR}
    ${PERF_DATA_PROTO_CC}
    ${PERF_PARSER_OPTIONS_HDR}
    ${PERF_PARSER_OPTIONS_CC}
    ${PERF_STAT_CC}
    ${PERF_STAT_HDR})
  target_include_directories(quipper_perf PRIVATE
    third_party/abseil)
  target_include_directories(quipper_perf BEFORE
    PUBLIC
    third_party/perf_data_converter/src
    third_party/perf_data_converter/src/quipper)
  target_link_libraries(quipper_perf ${Protobuf_LIBRARIES} ${LIBELF_LIBRARIES} ${LIBCRYPTO_LIBRARIES})

  add_executable(create_gcov)
  target_link_libraries(create_gcov
    absl::flags
    absl::flags_parse
    create_gcov_lib
    glog
    quipper_perf
  )

  add_library(dump_gcov_lib OBJECT
    dump_gcov.cc
    gcov.cc
    instruction_map.cc
    profile.cc
    profile_reader.cc
    symbol_map.cc
    util/symbolize/elf_reader.cc
  )
  add_dependencies(dump_gcov_lib perf_data_proto)
  add_dependencies(dump_gcov_lib perf_parser_options_proto)
  add_dependencies(dump_gcov_lib perf_stat_proto)

  add_executable(dump_gcov)
  target_link_libraries(dump_gcov
    absl::flags
    absl::flags_parse
    dump_gcov_lib
    glog
  )
endfunction ()

function (config_with_llvm)
{'fraction_non_alphanumeric': 0.06984240687679083, 'fraction_numerical': 0.002148997134670487, 'mean_word_length': 5.3510235026535256, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '710665', 'n_tokens_mistral': 3206, 'n_tokens_neox': 3123, 'n_words': 283}