|
| 1 | +# |
| 2 | +# cmake configuration file for building the C++ test harness |
| 3 | +# |
| 4 | +# This assumes you have a protobuf source checkout handy, |
| 5 | +# and have used `git submodule update` to obtain all the |
| 6 | +# related source repos. |
| 7 | +# |
| 8 | +# This script uses the protobuf sources to build libprotobuf and |
| 9 | +# statically links it into the test harness executable. |
| 10 | +# (This is probably not necessary; updates to this file to |
| 11 | +# use a better strategy would be appreciated.) |
| 12 | +# |
| 13 | +# Also assumes that you have abseil_cpp and googletest installed |
| 14 | +# locally via e.g., |
| 15 | +# brew install googletest |
| 16 | +# brew install abseil |
| 17 | +# |
| 18 | + |
| 19 | +cmake_minimum_required(VERSION 3.10...3.26) |
| 20 | +set(CMAKE_CXX_STANDARD 17) |
| 21 | +set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 22 | +set(CMAKE_BUILD_TYPE RelWithDebInfo) |
| 23 | + |
| 24 | +project(swiftprotobuf-perf C CXX) |
| 25 | + |
| 26 | +# Update this with the appropriate path to the protobuf source |
| 27 | +# checkout, starting from the directory holding this file. |
| 28 | +# Default here assumes that `protobuf` is checked out beside |
| 29 | +# `swift-protobuf` |
| 30 | +set(protobuf_SOURCE_DIR ${CMAKE_SOURCE_DIR}/../../../protobuf) |
| 31 | +set(protobuf_VERSION "999.999") |
| 32 | + |
| 33 | +# Use protobuf cmake scripts to locate suitable abseil package: |
| 34 | +set(protobuf_ABSL_PROVIDER "package") |
| 35 | +include(${protobuf_SOURCE_DIR}/cmake/abseil-cpp.cmake) |
| 36 | + |
| 37 | +# Use protobuf cmake scripts for building libprotobuf |
| 38 | +include(${protobuf_SOURCE_DIR}/cmake/libprotobuf.cmake) |
| 39 | + |
| 40 | +# Use utf8_range from protobuf checkout |
| 41 | +set(utf8_range_SOURCE_DIR ${protobuf_SOURCE_DIR}/third_party/utf8_range) |
| 42 | +add_subdirectory(${utf8_range_SOURCE_DIR} third_party/utf8_range) |
| 43 | + |
| 44 | +include_directories( |
| 45 | + ${protobuf_SOURCE_DIR}/src |
| 46 | + ${utf8_range_SOURCE_DIR} |
| 47 | +) |
| 48 | + |
| 49 | +add_executable(harness_cpp |
| 50 | + ../main.cc |
| 51 | + ../Harness.cc |
| 52 | + ../_generated/Harness+Generated.cc |
| 53 | + ../_generated/message.pb.cc |
| 54 | +) |
| 55 | + |
| 56 | +target_include_directories(harness_cpp PRIVATE |
| 57 | + ${CMAKE_SOURCE_DIR} |
| 58 | + ${CMAKE_SOURCE_DIR}/.. |
| 59 | + ${ABSL_ROOT_DIR} |
| 60 | + ${utf8_range_SOURCE_DIR} |
| 61 | +) |
| 62 | + |
| 63 | +target_link_libraries(harness_cpp PRIVATE libprotobuf) |
0 commit comments