diff --git a/cta-dcache/CMakeLists.txt b/cta-dcache/CMakeLists.txt index 99784ce9ea7019fbb9b59bf3a23cd190a5488666..6875832b1af78046121fddeb9052bff32ed9c2cd 100644 --- a/cta-dcache/CMakeLists.txt +++ b/cta-dcache/CMakeLists.txt @@ -1,5 +1,5 @@ # @project The CERN Tape Archive (CTA) -# @copyright 2021 DESY +# @copyright Copyright(C) 2021 DESY # @license This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or @@ -15,4 +15,48 @@ cmake_minimum_required (VERSION 2.6) -add_subdirectory(gRPC) +find_package(Protobuf3 REQUIRED) +find_package(GRPC REQUIRED) + +include_directories(${PROTOBUF3_INCLUDE_DIRS}) + +set(PROTOBUF_CTADCACHE_DIR ${PROJECT_SOURCE_DIR}/cta-dcache/grpc-proto/protobuf) +file(GLOB ProtoFilesCtaDcache "${PROTOBUF_CTADCACHE_DIR}/*.proto") + +# depends on CTA_EOS definitions +set(PROTOBUF_EOS_CTA_DIR ${XRD_SSI_PB_DIR}/eos_cta/protobuf) +file(GLOB ProtoFilesEosCta "${PROTOBUF_EOS_CTA_DIR}/*.proto") + +set(PROTOBUF3_INCLUDE_PATH "${PROTOBUF_EOS_CTA_DIR}:${PROTOBUF_CTADCACHE_DIR}:${PROTOBUF3_INCLUDE_DIRS}") +PROTOBUF3_GENERATE_CPP(ProtoSourcesCtaDcache ProtoHeadersCtaDcache ${ProtoFilesCtaDcache}) + +set(GRPC_PROTOBUF_PATH "${CMAKE_BINARY_DIR}/cta-dcache") +set(PROTOBUF3_IMPORT_DIRS "${PROTOBUF_EOS_CTA_DIR}:${PROTOBUF3_INCLUDE_DIRS}") +grpc_generate_cpp(ProtoGrpcSourcesCtaDcache ProtoGrpcHeadersCtaDcache ${GRPC_PROTOBUF_PATH} ${ProtoFilesCtaDcache}) + +set_source_files_properties( + ${ProtoSourcesCtaDcache} ${ProtoHeadersCtaDcache} + ${ProtoGrpcSourcesCtaDcache} ${ProtoGrpcHeadersCtaDcache} + PROPERTIES GENERATED TRUE) + +foreach(PROTO_SRC ${ProtoSourcesCtaDcache} ${ProtoGrpcSourcesCtaDcache}) + set_property(SOURCE ${PROTO_SRC} PROPERTY COMPILE_FLAGS " -Wno-missing-field-initializers -fPIC -Wno-narrowing -Wno-implicit-fallthrough") + # Add -Wno-narrowing -Wno-implicit-fallthrough compiler flags if using gcc version 7 or greater + if(CMAKE_COMPILER_IS_GNUCC) + if(GCC_VERSION VERSION_EQUAL 7 OR GCC_VERSION VERSION_GREATER 7) + set_property(SOURCE ${PROTO_SRC} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-narrowing -Wno-implicit-fallthrough") + endif(GCC_VERSION VERSION_EQUAL 7 OR GCC_VERSION VERSION_GREATER 7) + endif(CMAKE_COMPILER_IS_GNUCC) +endforeach(PROTO_SRC) + +include_directories(${CMAKE_BINARY_DIR}/cta-dcache ${CMAKE_BINARY_DIR}/eos_cta + ${PROTOBUF3_INCLUDE_DIRS}) + +add_executable(cta-dcache FrontendGRpcSvc.cpp ${ProtoSourcesCtaDcache} ${ProtoGrpcSourcesCtaDcache}) + +target_link_libraries(cta-dcache ${PROTOBUF3_LIBRARIES} ${GRPC_GRPC++_LIBRARY} + ctascheduler ctacommon ctaobjectstore ctacatalogue) +set_property(TARGET cta-dcache APPEND PROPERTY INSTALL_RPATH ${PROTOBUF3_RPATH}) + +install(TARGETS cta-dcache DESTINATION usr/bin) +install (FILES cta-dcache.service DESTINATION etc/systemd/system) \ No newline at end of file diff --git a/cta-dcache/gRPC/FrontendGRpcSvc.cpp b/cta-dcache/FrontendGRpcSvc.cpp similarity index 100% rename from cta-dcache/gRPC/FrontendGRpcSvc.cpp rename to cta-dcache/FrontendGRpcSvc.cpp diff --git a/cta-dcache/gRPC/FrontendGRpcSvc.h b/cta-dcache/FrontendGRpcSvc.h similarity index 100% rename from cta-dcache/gRPC/FrontendGRpcSvc.h rename to cta-dcache/FrontendGRpcSvc.h diff --git a/cta-dcache/gRPC/cta-dcache.service b/cta-dcache/cta-dcache.service similarity index 100% rename from cta-dcache/gRPC/cta-dcache.service rename to cta-dcache/cta-dcache.service diff --git a/cta-dcache/gRPC/CMakeLists.txt b/cta-dcache/gRPC/CMakeLists.txt deleted file mode 100644 index 0a5a1242eda75b10855b2e8871e900585054d1e2..0000000000000000000000000000000000000000 --- a/cta-dcache/gRPC/CMakeLists.txt +++ /dev/null @@ -1,62 +0,0 @@ -# @project The CERN Tape Archive (CTA) -# @copyright Copyright(C) 2021 DESY -# @license This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -cmake_minimum_required (VERSION 2.6) - -find_package(Protobuf3 REQUIRED) -find_package(GRPC REQUIRED) - -include_directories(${PROTOBUF3_INCLUDE_DIRS}) - -set(PROTOBUF_CTADCACHE_DIR ${PROJECT_SOURCE_DIR}/cta-dcache/grpc-proto/protobuf) -file(GLOB ProtoFilesCtaDcache "${PROTOBUF_CTADCACHE_DIR}/*.proto") - -# depends on CTA_EOS definitions -set(PROTOBUF_EOS_CTA_DIR ${XRD_SSI_PB_DIR}/eos_cta/protobuf) -file(GLOB ProtoFilesEosCta "${PROTOBUF_EOS_CTA_DIR}/*.proto") - -set(PROTOBUF3_INCLUDE_PATH "${PROTOBUF_EOS_CTA_DIR}:${PROTOBUF_CTADCACHE_DIR}:${PROTOBUF3_INCLUDE_DIRS}") -PROTOBUF3_GENERATE_CPP(ProtoSourcesCtaDcache ProtoHeadersCtaDcache ${ProtoFilesCtaDcache}) - -set(GRPC_PROTOBUF_PATH "${CMAKE_BINARY_DIR}/cta-dcache/gRPC") -set(PROTOBUF3_IMPORT_DIRS "${PROTOBUF_EOS_CTA_DIR}:${PROTOBUF3_INCLUDE_DIRS}") -grpc_generate_cpp(ProtoGrpcSourcesCtaDcache ProtoGrpcHeadersCtaDcache ${GRPC_PROTOBUF_PATH} ${ProtoFilesCtaDcache}) - -set_source_files_properties( - ${ProtoSourcesCtaDcache} ${ProtoHeadersCtaDcache} - ${ProtoGrpcSourcesCtaDcache} ${ProtoGrpcHeadersCtaDcache} - PROPERTIES GENERATED TRUE) - -foreach(PROTO_SRC ${ProtoSourcesCtaDcache} ${ProtoGrpcSourcesCtaDcache}) - set_property(SOURCE ${PROTO_SRC} PROPERTY COMPILE_FLAGS " -Wno-missing-field-initializers -fPIC -Wno-narrowing -Wno-implicit-fallthrough") - # Add -Wno-narrowing -Wno-implicit-fallthrough compiler flags if using gcc version 7 or greater - if(CMAKE_COMPILER_IS_GNUCC) - if(GCC_VERSION VERSION_EQUAL 7 OR GCC_VERSION VERSION_GREATER 7) - set_property(SOURCE ${PROTO_SRC} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-narrowing -Wno-implicit-fallthrough") - endif(GCC_VERSION VERSION_EQUAL 7 OR GCC_VERSION VERSION_GREATER 7) - endif(CMAKE_COMPILER_IS_GNUCC) -endforeach(PROTO_SRC) - -include_directories(${CMAKE_BINARY_DIR}/cta-dcache/gRPC ${CMAKE_BINARY_DIR}/eos_cta - ${PROTOBUF3_INCLUDE_DIRS}) - -add_executable(cta-dcache FrontendGRpcSvc.cpp ${ProtoSourcesCtaDcache} ${ProtoGrpcSourcesCtaDcache}) - -target_link_libraries(cta-dcache ${PROTOBUF3_LIBRARIES} ${GRPC_GRPC++_LIBRARY} - ctascheduler ctacommon ctaobjectstore ctacatalogue) -set_property(TARGET cta-dcache APPEND PROPERTY INSTALL_RPATH ${PROTOBUF3_RPATH}) - -install(TARGETS cta-dcache DESTINATION usr/bin) -install (FILES cta-dcache.service DESTINATION etc/systemd/system) \ No newline at end of file