|
1 | | -# |
2 | | -# Licensed to the Apache Software Foundation (ASF) under one or more |
3 | | -# contributor license agreements. See the NOTICE file distributed with this |
4 | | -# work for additional information regarding copyright ownership. The ASF |
5 | | -# licenses this file to you under the Apache License, Version 2.0 (the |
6 | | -# "License"); you may not use this file except in compliance with the License. |
7 | | -# You may obtain a copy of the License at |
8 | | -# <p> |
9 | | -# http://www.apache.org/licenses/LICENSE-2.0 |
10 | | -# <p> |
11 | | -# Unless required by applicable law or agreed to in writing, software |
12 | | -# distributed under the License is distributed on an "AS IS" BASIS,WITHOUT |
13 | | -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
14 | | -# License for the specific language governing permissions and limitations under |
15 | | -# the License. |
16 | | -# |
17 | | -# cmake build file for C++ failure_injection_service. |
18 | | -# Assumes protobuf and gRPC have been installed using cmake. |
19 | | - |
20 | | -cmake_minimum_required(VERSION 2.8) |
21 | | - |
22 | | -project(FailureInjectionService C CXX) |
23 | | - |
24 | | -set(BASE_DIR ".") |
25 | | -set(FS_DIR "${BASE_DIR}/FileSystem") |
26 | | -set(SRV_DIR "${BASE_DIR}/Service/cpp") |
27 | | - |
28 | | -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fpermissive -Wall") |
29 | | - |
30 | | -# This assumes that gRPC and all its dependencies are already installed |
31 | | -# on this system, so they can be located by find_package(). |
32 | | - |
33 | | -# Find Protobuf installation |
34 | | -# Looks for protobuf-config.cmake file installed by Protobuf's cmake |
35 | | -# installation. |
36 | | -set(protobuf_MODULE_COMPATIBLE TRUE) |
37 | | -find_package(Protobuf CONFIG REQUIRED) |
38 | | -message(STATUS "Using protobuf ${protobuf_VERSION}") |
39 | | - |
40 | | -set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf) |
41 | | -set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>) |
42 | | - |
43 | | -# Find gRPC installation |
44 | | -# Looks for gRPCConfig.cmake file installed by gRPC's cmake installation. |
45 | | -find_package(gRPC CONFIG REQUIRED) |
46 | | -message(STATUS "Using gRPC ${gRPC_VERSION}") |
47 | | - |
48 | | -set(_GRPC_GRPCPP_UNSECURE gRPC::grpc++_unsecure) |
49 | | -set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>) |
50 | | - |
51 | | -# Proto file |
52 | | -get_filename_component(hw_proto |
53 | | - "${BASE_DIR}/Service/protos/failure_injection_service.proto" |
54 | | - ABSOLUTE) |
55 | | -get_filename_component(hw_proto_path "${hw_proto}" PATH) |
56 | | - |
57 | | -# Generated sources |
58 | | -set(hw_proto_srcs |
59 | | - "${CMAKE_CURRENT_BINARY_DIR}/failure_injection_service.pb.cc") |
60 | | -set(hw_proto_hdrs |
61 | | - "${CMAKE_CURRENT_BINARY_DIR}/failure_injection_service.pb.h") |
62 | | -set(hw_grpc_srcs |
63 | | - "${CMAKE_CURRENT_BINARY_DIR}/failure_injection_service.grpc.pb.cc") |
64 | | -set(hw_grpc_hdrs |
65 | | - "${CMAKE_CURRENT_BINARY_DIR}/failure_injection_service.grpc.pb.h") |
66 | | -add_custom_command( |
67 | | - OUTPUT "${hw_proto_srcs}" "${hw_proto_hdrs}" |
68 | | - "${hw_grpc_srcs}" "${hw_grpc_hdrs}" |
69 | | - COMMAND ${_PROTOBUF_PROTOC} |
70 | | - ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}" |
71 | | - --cpp_out "${CMAKE_CURRENT_BINARY_DIR}" |
72 | | - -I "${hw_proto_path}" |
73 | | - --plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}" |
74 | | - "${hw_proto}" |
75 | | - DEPENDS "${hw_proto}") |
76 | | - |
77 | | -# Include generated *.pb.h files |
78 | | -include_directories("${CMAKE_CURRENT_BINARY_DIR}" |
79 | | - "${FS_DIR}" |
80 | | - "${SRV_DIR}") |
81 | | - |
82 | | -#add_compile_options("-fpermissive") |
83 | | - |
84 | | -# Build server |
85 | | -add_executable(failure_injector_svc_server |
86 | | - ${FS_DIR}/failure_injector_fs.cc ${FS_DIR}/failure_injector.cc |
87 | | - ${SRV_DIR}/failure_injector_svc_server.cc ${SRV_DIR}/run_grpc_service.cc |
88 | | - ${hw_proto_srcs} |
89 | | - ${hw_grpc_srcs}) |
90 | | -target_link_libraries(failure_injector_svc_server |
91 | | - ${_GRPC_GRPCPP_UNSECURE} |
92 | | - fuse3 |
93 | | - ${_PROTOBUF_LIBPROTOBUF}) |
94 | | - |
95 | | -# Build client |
96 | | -add_executable(failure_injector_svc_client |
97 | | - "${SRV_DIR}/failure_injector_svc_client.cc" |
98 | | - ${hw_proto_srcs} |
99 | | - ${hw_grpc_srcs}) |
100 | | -target_link_libraries(failure_injector_svc_client |
101 | | - ${_GRPC_GRPCPP_UNSECURE} |
102 | | - ${_PROTOBUF_LIBPROTOBUF}) |
103 | | - |
104 | | -# Build unit tests |
105 | | -set(CPP_UNIT_FUSE cpp_unit) |
106 | | -foreach(_target |
107 | | - TestFilePathFailures |
108 | | - TestFailureInjector) |
109 | | - add_executable(${_target} |
110 | | - "${FS_DIR}/${CPP_UNIT_FUSE}/${_target}.cc" |
111 | | - ${FS_DIR}/failure_injector.cc) |
112 | | - target_link_libraries(${_target} |
113 | | - cppunit) |
114 | | -endforeach() |
| 1 | +# |
| 2 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | +# contributor license agreements. See the NOTICE file distributed with this |
| 4 | +# work for additional information regarding copyright ownership. The ASF |
| 5 | +# licenses this file to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# <p> |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# <p> |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS,WITHOUT |
| 13 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | +# License for the specific language governing permissions and limitations under |
| 15 | +# the License. |
| 16 | +# |
| 17 | +# cmake build file for C++ failure_injection_service. |
| 18 | +# Assumes protobuf and gRPC have been installed using cmake. |
| 19 | + |
| 20 | +cmake_minimum_required(VERSION 2.8) |
| 21 | + |
| 22 | +project(FailureInjectionService C CXX) |
| 23 | + |
| 24 | +set(BASE_DIR ".") |
| 25 | +set(FS_DIR "${BASE_DIR}/FileSystem") |
| 26 | +set(SRV_DIR "${BASE_DIR}/Service/cpp") |
| 27 | + |
| 28 | +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fpermissive -Wall") |
| 29 | + |
| 30 | +# This assumes that gRPC and all its dependencies are already installed |
| 31 | +# on this system, so they can be located by find_package(). |
| 32 | + |
| 33 | +# Find Protobuf installation |
| 34 | +# Looks for protobuf-config.cmake file installed by Protobuf's cmake |
| 35 | +# installation. |
| 36 | +set(protobuf_MODULE_COMPATIBLE TRUE) |
| 37 | +find_package(Protobuf CONFIG REQUIRED) |
| 38 | +message(STATUS "Using protobuf ${protobuf_VERSION}") |
| 39 | + |
| 40 | +set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf) |
| 41 | +set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>) |
| 42 | + |
| 43 | +# Find gRPC installation |
| 44 | +# Looks for gRPCConfig.cmake file installed by gRPC's cmake installation. |
| 45 | +find_package(gRPC CONFIG REQUIRED) |
| 46 | +message(STATUS "Using gRPC ${gRPC_VERSION}") |
| 47 | + |
| 48 | +set(_GRPC_GRPCPP_UNSECURE gRPC::grpc++_unsecure) |
| 49 | +set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>) |
| 50 | + |
| 51 | +# Proto file |
| 52 | +get_filename_component(hw_proto |
| 53 | + "${BASE_DIR}/Service/protos/failure_injection_service.proto" |
| 54 | + ABSOLUTE) |
| 55 | +get_filename_component(hw_proto_path "${hw_proto}" PATH) |
| 56 | + |
| 57 | +# Generated sources |
| 58 | +set(hw_proto_srcs |
| 59 | + "${CMAKE_CURRENT_BINARY_DIR}/failure_injection_service.pb.cc") |
| 60 | +set(hw_proto_hdrs |
| 61 | + "${CMAKE_CURRENT_BINARY_DIR}/failure_injection_service.pb.h") |
| 62 | +set(hw_grpc_srcs |
| 63 | + "${CMAKE_CURRENT_BINARY_DIR}/failure_injection_service.grpc.pb.cc") |
| 64 | +set(hw_grpc_hdrs |
| 65 | + "${CMAKE_CURRENT_BINARY_DIR}/failure_injection_service.grpc.pb.h") |
| 66 | +add_custom_command( |
| 67 | + OUTPUT "${hw_proto_srcs}" "${hw_proto_hdrs}" |
| 68 | + "${hw_grpc_srcs}" "${hw_grpc_hdrs}" |
| 69 | + COMMAND ${_PROTOBUF_PROTOC} |
| 70 | + ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}" |
| 71 | + --cpp_out "${CMAKE_CURRENT_BINARY_DIR}" |
| 72 | + -I "${hw_proto_path}" |
| 73 | + --plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}" |
| 74 | + "${hw_proto}" |
| 75 | + DEPENDS "${hw_proto}") |
| 76 | + |
| 77 | +# Include generated *.pb.h files |
| 78 | +include_directories("${CMAKE_CURRENT_BINARY_DIR}" |
| 79 | + "${FS_DIR}" |
| 80 | + "${SRV_DIR}") |
| 81 | + |
| 82 | +#add_compile_options("-fpermissive") |
| 83 | + |
| 84 | +# Build server |
| 85 | +find_package(Threads) |
| 86 | +add_executable(failure_injector_svc_server |
| 87 | + ${FS_DIR}/failure_injector_fs.cc ${FS_DIR}/failure_injector.cc |
| 88 | + ${SRV_DIR}/failure_injector_svc_server.cc ${SRV_DIR}/run_grpc_service.cc |
| 89 | + ${hw_proto_srcs} |
| 90 | + ${hw_grpc_srcs}) |
| 91 | +target_link_libraries(failure_injector_svc_server |
| 92 | + ${_GRPC_GRPCPP_UNSECURE} |
| 93 | + fuse3 |
| 94 | + ${_PROTOBUF_LIBPROTOBUF}) |
| 95 | + |
| 96 | +# Build client |
| 97 | +add_executable(failure_injector_svc_client |
| 98 | + "${SRV_DIR}/failure_injector_svc_client.cc" |
| 99 | + ${hw_proto_srcs} |
| 100 | + ${hw_grpc_srcs}) |
| 101 | +target_link_libraries(failure_injector_svc_client |
| 102 | + ${_GRPC_GRPCPP_UNSECURE} |
| 103 | + ${_PROTOBUF_LIBPROTOBUF}) |
| 104 | + |
| 105 | +# Build unit tests |
| 106 | +set(CPP_UNIT_FUSE cpp_unit) |
| 107 | +foreach(_target |
| 108 | + TestFilePathFailures |
| 109 | + TestFailureInjector) |
| 110 | + add_executable(${_target} |
| 111 | + "${FS_DIR}/${CPP_UNIT_FUSE}/${_target}.cc" |
| 112 | + ${FS_DIR}/failure_injector.cc) |
| 113 | + target_link_libraries(${_target} |
| 114 | + cppunit) |
| 115 | +endforeach() |
0 commit comments