-
Notifications
You must be signed in to change notification settings - Fork 15
/
HederaApi.cmake
64 lines (49 loc) · 1.94 KB
/
HederaApi.cmake
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
set(HAPI_VERSION_TAG "v0.55.0" CACHE STRING "Use the configured version tag for the Hedera API protobufs")
if (HAPI_VERSION_TAG STREQUAL "")
set(HAPI_VERSION_TAG "v0.55.0")
endif ()
# Fetch the protobuf definitions
FetchContent_Declare(
HProto
GIT_REPOSITORY https://github.com/hashgraph/hedera-services.git
GIT_TAG ${HAPI_VERSION_TAG}
)
set(FETCHCONTENT_QUIET OFF)
FetchContent_MakeAvailable(HProto)
# Clean and update the protobuf definitions
set(PROTO_SRC ${PROJECT_SOURCE_DIR}/proto)
# Get all .proto files in the specified directory
file(GLOB_RECURSE PROTO_FILES ${PROTO_SRC}/*.proto)
# List of files to exclude from removal
set(EXCLUDE_FILES
"consensus_service.proto"
"mirror_network_service.proto"
"transaction_list.proto"
)
# Create a list to hold files to be removed
set(FILES_TO_REMOVE "")
# Iterate over all found .proto files
foreach(PROTO_FILE ${PROTO_FILES})
# Get the file name without the path
get_filename_component(FILENAME ${PROTO_FILE} NAME)
# Check if the file is in the exclusion list
list(FIND EXCLUDE_FILES ${FILENAME} INDEX)
# If the file is not in the exclusion list, add it to the removal list
if (INDEX EQUAL -1)
list(APPEND FILES_TO_REMOVE ${PROTO_FILE})
endif()
endforeach()
# Remove the files that are not in the exclusion list
if (FILES_TO_REMOVE)
file(REMOVE ${FILES_TO_REMOVE})
endif()
file(INSTALL ${PROJECT_SOURCE_DIR}/proto/service-external-proto/mirror/ DESTINATION ${PROTO_SRC}/mirror)
file(INSTALL ${hproto_SOURCE_DIR}/hapi/hedera-protobufs/services/ DESTINATION ${PROTO_SRC})
file(INSTALL ${PROJECT_SOURCE_DIR}/proto/service-external-proto/sdk/ DESTINATION ${PROTO_SRC})
add_subdirectory(proto)
set(HAPI_ROOT_DIR ${CMAKE_CURRENT_BINARY_DIR}/proto)
if (NOT EXISTS ${HAPI_ROOT_DIR})
message(FATAL_ERROR "Failed to the HAPI_ROOT_DIR at `${HAPI_ROOT_DIR}`")
endif ()
set(HAPI_INCLUDE_DIR ${HAPI_ROOT_DIR})
set(HAPI_LIB_DIR ${HAPI_ROOT_DIR})