-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
65 lines (55 loc) · 2.22 KB
/
Copy pathCMakeLists.txt
File metadata and controls
65 lines (55 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
cmake_minimum_required(VERSION 3.25)
project(hpp_proto_tutorial
VERSION 1.0.0
LANGUAGES CXX)
if(PROJECT_IS_TOP_LEVEL)
include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/grpc_check.cmake)
set(HPP_PROTO_GIT_REPOSITORY "https://github.com/huangminghuang/hpp-proto.git" CACHE STRING
"The hpp-proto git repository URL for fetch_content")
set(HPP_PROTO_GIT_TAG "" CACHE STRING "Use find_package(hpp-proto) if empty; otherwise the hpp-proto git tag for fetch_content")
if(HPP_PROTO_GIT_TAG)
include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/CPM.cmake)
# CPM local override is supported via -DCPM_hpp_proto_SOURCE=/path/to/hpp-proto.
CPMAddPackage(
NAME hpp_proto
GIT_REPOSITORY ${HPP_PROTO_GIT_REPOSITORY}
GIT_TAG ${HPP_PROTO_GIT_TAG}
GIT_SHALLOW TRUE
)
else()
find_package(hpp_proto CONFIG REQUIRED)
endif()
function(hpp_proto_register_clang_tidy_input_targets)
endfunction()
elseif(NOT HPP_PROTO_TESTS)
return()
endif()
add_library(addressbook_proto3 INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/addressbook_proto3.proto)
target_compile_features(addressbook_proto3 INTERFACE cxx_std_23)
protobuf_generate_hpp(
TARGET addressbook_proto3
IMPORT_DIRS ${CMAKE_CURRENT_SOURCE_DIR}
)
hpp_proto_register_clang_tidy_input_targets(addressbook_proto3)
add_library(addressbook_proto2 INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/addressbook_proto2.proto)
target_compile_features(addressbook_proto2 INTERFACE cxx_std_23)
protobuf_generate_hpp(
TARGET addressbook_proto2
IMPORT_DIRS ${CMAKE_CURRENT_SOURCE_DIR} # # required when the proto file is not in ${CMAKE_CURRENT_SOURCE_DIR}
)
hpp_proto_register_clang_tidy_input_targets(addressbook_proto2)
add_library(any_demo INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/any_demo.proto)
target_compile_features(any_demo INTERFACE cxx_std_23)
target_link_libraries(any_demo INTERFACE hpp_proto::hpp_proto)
protobuf_generate_hpp(
TARGET any_demo
IMPORT_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
hpp_proto_register_clang_tidy_input_targets(any_demo)
add_subdirectory(regular)
add_subdirectory(non_owning)
add_subdirectory(dynamic_message)
add_subdirectory(compile_time_serialization)
add_subdirectory(pmr)
if (NOT HPP_PROTO_PROTOC STREQUAL "compile")
add_subdirectory(grpc)
endif()