forked from songzhen-neu/ADGNN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·88 lines (65 loc) · 2.55 KB
/
CMakeLists.txt
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
cmake_minimum_required(VERSION 3.17)
project(adgnn VERSION 1.0)
# linux cxx environment setting
set(CMAKE_CXX_STANDARD 11)
#set(CMAKE_BUILD_TYPE "Debug")
#set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -ggdb")
#set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
# find protobuf installation, need protobufConfig.cmake
set(protobuf_MODULE_COMPATIBLE TRUE)
find_package(Protobuf CONFIG REQUIRED)
message(STATUS "Using protobuf ${Protobuf_VERSION}")
set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf)
set(_REFLECTION gRPC::grpc++_reflection)
set(_GRPC_GRPCPP grpc++)
set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)
# find grpc, need grpcConfig.cmake
find_package(gRPC CONFIG REQUIRED)
message(STATUS "Using gRPC ${gRPC_VERSION}")
set(_GRPC_GRPCPP gRPC::grpc++)
set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
find_package(Python COMPONENTS Interpreter Development REQUIRED)
# pybind11
set(PYBIND11_CPP_STANDARD -std=c++11)
add_subdirectory(third_party/pybind11)
add_compile_options(-fPIC)
#include_directories(eigen3)
# Proto file
get_filename_component(hw_proto "core/protos/dgnn_test.proto" ABSOLUTE)
get_filename_component(hw_proto_path "${hw_proto}" PATH)
message(STATUS "hw_proto: ${hw_proto}")
message(STATUS "hw_proto_path: ${hw_proto_path}")
# Generated sources
message(STATUS "CURRENT BINARY PATH: ${CMAKE_CURRENT_BINARY_DIR}")
set(hw_proto_srcs "${CMAKE_CURRENT_BINARY_DIR}/dgnn_test.pb.cc")
set(hw_proto_hdrs "${CMAKE_CURRENT_BINARY_DIR}/dgnn_test.pb.h")
set(hw_grpc_srcs "${CMAKE_CURRENT_BINARY_DIR}/dgnn_test.grpc.pb.cc")
set(hw_grpc_hdrs "${CMAKE_CURRENT_BINARY_DIR}/dgnn_test.grpc.pb.h")
message(STATUS "proto_src ${hw_proto_srcs}")
add_custom_command(
OUTPUT "${hw_proto_srcs}" "${hw_proto_hdrs}" "${hw_grpc_srcs}" "${hw_grpc_hdrs}"
COMMAND ${_PROTOBUF_PROTOC}
ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}"
--cpp_out "${CMAKE_CURRENT_BINARY_DIR}"
-I "${hw_proto_path}"
--plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}"
"${hw_proto}"
DEPENDS "${hw_proto}"
)
# Include generated *.pb.h files
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
message(STATUS "${CMAKE_CURRENT_BINARY_DIR}")
add_subdirectory(cpptest)
add_subdirectory(core)
find_package(Threads)
add_library(hw_grpc_proto
${hw_grpc_srcs}
${hw_grpc_hdrs}
${hw_proto_srcs}
${hw_proto_hdrs})
target_link_libraries(hw_grpc_proto
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF})
add_executable(mainTest main.cc)
target_link_libraries(mainTest service util)