diff --git a/CMakeLists.txt b/CMakeLists.txt index 484f385133e58fec216eca15b24b7e0794824a5d..90610648bba1e2173af518841c4df0bf6b1dcc32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,7 +102,6 @@ ELSE(DEFINED PackageOnly) set(CMAKE_DISABLE_SOURCE_CHANGES ON) set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) - list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/xrootd-ssi-protobuf-interface/cmake) list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) include(GNUInstallDirs) set(CMAKE_INSTALL_PREFIX "/") @@ -131,9 +130,9 @@ ELSE(DEFINED PackageOnly) # # Location of git submodule containing the XRootD SSI Protocol Buffer bindings # - set(XRD_SSI_PB_DIR xrootd-ssi-protobuf-interface) + set(XRD_SSI_PB_DIR ${PROJECT_SOURCE_DIR}/xrootd-ssi-protobuf-interface) - add_subdirectory(xrootd-ssi-protobuf-interface) + add_subdirectory(eos_cta) add_subdirectory(cmdline) add_subdirectory(xroot_plugins) diff --git a/cmake/FindProtobuf3.cmake b/cmake/FindProtobuf3.cmake new file mode 100644 index 0000000000000000000000000000000000000000..2f794ebd04ec81b8f449d76bb6796b7aa68149ab --- /dev/null +++ b/cmake/FindProtobuf3.cmake @@ -0,0 +1,75 @@ +# From, https://raw.githubusercontent.com/Kitware/CMake/master/Modules/FindProtobuf.cmake +# cut down to solve our problem and nothing more +#============================================================================= +# Copyright 2009 Kitware, Inc. +# Copyright 2009-2011 Philip Lowman <philip@yhbt.com> +# Copyright 2008 Esben Mose Hansen, Ange Optimization ApS +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +set(PROTOBUF3_RPATH /usr/lib64/protobuf3) +message(STATUS "PROTOBUF3_RPATH=${PROTOBUF3_RPATH}") + +set(PROTOBUF3_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +find_program(PROTOBUF3_PROTOC3_EXECUTABLE + NAMES protoc3 + DOC "Version 3 of The Google Protocol Buffers Compiler" +) +message(STATUS "protoc3 is at ${PROTOBUF3_PROTOC3_EXECUTABLE} ") + +find_path(PROTOBUF3_INCLUDE_DIRS + google/protobuf/message.h + PATHS /usr/include/protobuf3 + NO_DEFAULT_PATH) +message(STATUS "PROTOBUF3_INCLUDE_DIRS=${PROTOBUF3_INCLUDE_DIRS}") + +find_library(PROTOBUF3_LIBRARIES + NAME protobuf + PATHS ${PROTOBUF3_RPATH} + NO_DEFAULT_PATH) +message(STATUS "PROTOBUF3_LIBRARIES=${PROTOBUF3_LIBRARIES}") + +function(PROTOBUF3_GENERATE_CPP SRCS HDRS) + if(NOT ARGN) + message(SEND_ERROR "Error: PROTOBUF3_GENERATE_CPP() called without any proto files") + return() + endif() + + set(_protobuf_include_path -I ${PROTOBUF3_INCLUDE_PATH}) + + set(${SRCS}) + set(${HDRS}) + foreach(FIL ${ARGN}) + get_filename_component(ABS_FIL ${FIL} ABSOLUTE) + get_filename_component(FIL_WE ${FIL} NAME_WE) + + list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc") + list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h") + + add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc" + "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h" + COMMAND ${PROTOBUF3_PROTOC3_EXECUTABLE} + ARGS --cpp_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL} + DEPENDS ${ABS_FIL} + COMMENT "Running C++ protocol buffer compiler on ${FIL}" + VERBATIM ) + endforeach() + + set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE) + set(${SRCS} ${${SRCS}} PARENT_SCOPE) + set(${HDRS} ${${HDRS}} PARENT_SCOPE) +endfunction() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Protobuf3 DEFAULT_MSG + PROTOBUF3_INCLUDE_DIRS PROTOBUF3_LIBRARIES PROTOBUF3_RPATH) diff --git a/cmake/Findxrootd.cmake b/cmake/Findxrootd.cmake new file mode 100644 index 0000000000000000000000000000000000000000..4674d2df11013bf99530a8fc90b048bf3f439feb --- /dev/null +++ b/cmake/Findxrootd.cmake @@ -0,0 +1,50 @@ +# - Find xroot +# Finds the header files of xrootd-devel by searching for XrdVersion.hh +# Finds the header files of xrootd-private-devel by searching for XrdOssApi.hh +# +# XROOTD_FOUND - true if xrootd has been found +# XROOTD_INCLUDE_DIR - location of the xrootd-devel header files +# XROOTD_PRIVATE_INCLUDE_DIR - location of the private xrootd files, in other +# words the header files that do not contribute to +# the xrootd ABI. +# XROOTD_XRDCL_LIB - location of the XrdCl library +# XROOTD_XRDCLIENT_LIB - location of the XrdClient library +# XROOTD_XRDSERVER_LIB - location of the XrdServer library +# XROOTD_XRDUTILS_LIB - location of the XrdUtils library +# XROOTD_XRDPOSIX_LIB - location of the XrdPosix library + +# Be silent if XROOTD_INCLUDE_DIR is already cached +if (XROOTD_INCLUDE_DIR) + set(XROOTD_FIND_QUIETLY TRUE) +endif (XROOTD_INCLUDE_DIR) + +find_path (XROOTD_INCLUDE_DIR XrdVersion.hh + PATH_SUFFIXES include/xrootd +) + +find_path (XROOTD_PRIVATE_INCLUDE_DIR XrdOss/XrdOssApi.hh + PATH_SUFFIXES include/xrootd/private +) + +find_library (XROOTD_XRDCL_LIB XrdCl) +find_library (XROOTD_XRDCLIENT_LIB XrdClient) +find_library (XROOTD_XRDSERVER_LIB XrdServer) +find_library (XROOTD_XRDUTILS_LIB XrdUtils) +find_library (XROOTD_XRDPOSIX_LIB XrdPosixPreload) + +message (STATUS "XROOTD_INCLUDE_DIR = ${XROOTD_INCLUDE_DIR}") +message (STATUS "XROOTD_PRIVATE_INCLUDE_DIR = ${XROOTD_PRIVATE_INCLUDE_DIR}") +message (STATUS "XROOTD_XRDCL_LIB = ${XROOTD_XRDCL_LIB}") +message (STATUS "XROOTD_XRDCLIENT_LIB = ${XROOTD_XRDCLIENT_LIB}") +message (STATUS "XROOTD_XRDSERVER_LIB = ${XROOTD_XRDSERVER_LIB}") +message (STATUS "XROOTD_XRDPOSIX_LIB = ${XROOTD_XRDPOSIX_LIB}") + +include (FindPackageHandleStandardArgs) +find_package_handle_standard_args (xrootd DEFAULT_MSG + XROOTD_INCLUDE_DIR + XROOTD_PRIVATE_INCLUDE_DIR + XROOTD_XRDCL_LIB + XROOTD_XRDCLIENT_LIB + XROOTD_XRDSERVER_LIB + XROOTD_XRDUTILS_LIB + XROOTD_XRDPOSIX_LIB) \ No newline at end of file diff --git a/cmake/Findxrootdclient.cmake b/cmake/Findxrootdclient.cmake new file mode 100644 index 0000000000000000000000000000000000000000..fd46dab2c38d9165e4288e0d763bf36a615d2d78 --- /dev/null +++ b/cmake/Findxrootdclient.cmake @@ -0,0 +1,31 @@ +# - Find xrootclient +# Finds the header files of xrootd-devel by searching for XrdVersion.hh +# +# XROOTD_FOUND - true if xrootd has been found +# XROOTD_INCLUDE_DIR - location of the xrootd-devel header files +# words the header files that do not contribute to +# the xrootd ABI. +# XROOTD_XRDCL_LIB - location of the XrdCl library +# XROOTD_XRDCLIENT_LIB - location of the XrdClient library + +# Be silent if XROOTD_INCLUDE_DIR is already cached +if (XROOTD_INCLUDE_DIR) + set(XROOTD_FIND_QUIETLY TRUE) +endif (XROOTD_INCLUDE_DIR) + +find_path (XROOTD_INCLUDE_DIR XrdVersion.hh + PATH_SUFFIXES include/xrootd +) + +find_library (XROOTD_XRDCL_LIB XrdCl) +find_library (XROOTD_XRDCLIENT_LIB XrdClient) + +message (STATUS "XROOTD_INCLUDE_DIR = ${XROOTD_INCLUDE_DIR}") +message (STATUS "XROOTD_XRDCL_LIB = ${XROOTD_XRDCL_LIB}") +message (STATUS "XROOTD_XRDCLIENT_LIB = ${XROOTD_XRDCLIENT_LIB}") + +include (FindPackageHandleStandardArgs) +find_package_handle_standard_args (xrootd DEFAULT_MSG + XROOTD_INCLUDE_DIR + XROOTD_XRDCL_LIB + XROOTD_XRDCLIENT_LIB) diff --git a/cmdline/CMakeLists.txt b/cmdline/CMakeLists.txt index 7ef68e46b5e061c2fe16c5694fbe5453da268fe8..ba6bdddc409bd3b0568e0f12943077c779367c1e 100644 --- a/cmdline/CMakeLists.txt +++ b/cmdline/CMakeLists.txt @@ -30,12 +30,12 @@ include_directories(${XROOTD_INCLUDE_DIR} ${XROOTD_INCLUDE_DIR}/private) # # XRootD SSI Protocol Buffer bindings # -include_directories(${CMAKE_SOURCE_DIR}/${XRD_SSI_PB_DIR}/include ${CMAKE_SOURCE_DIR}/${XRD_SSI_PB_DIR}/eos_cta/include) +include_directories(${XRD_SSI_PB_DIR}/include ${XRD_SSI_PB_DIR}/eos_cta/include) # # Compiled protocol buffers # -include_directories(${CMAKE_BINARY_DIR}/${XRD_SSI_PB_DIR}/eos_cta/protobuf ${PROTOBUF3_INCLUDE_DIRS}) +include_directories(${CMAKE_BINARY_DIR}/eos_cta ${PROTOBUF3_INCLUDE_DIRS}) # # eoscta_stub is a drop-in replacement for "cta archive|retrieve|delete" diff --git a/eos_cta/CMakeLists.txt b/eos_cta/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..3dfe6ff0b8e6ff18ec15a7d42da749ae4d65214f --- /dev/null +++ b/eos_cta/CMakeLists.txt @@ -0,0 +1,43 @@ +# The CERN Tape Archive (CTA) project +# Copyright 2018 CERN +# +# 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) +set(PROTOBUF3_INCLUDE_PATH ${XRD_SSI_PB_DIR}/eos_cta/protobuf/) +file(GLOB ProtoFiles "${PROTOBUF3_INCLUDE_PATH}/*.proto") + +PROTOBUF3_GENERATE_CPP(ProtoSources ProtoHeaders ${ProtoFiles}) + +set_source_files_properties( + ${ProtoSources} ${ProtoHeaders} + PROPERTIES GENERATED 1) + +foreach(PROTO_SRC ${ProtoSources}) + 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) +set(CTA_FRONT_END_MESSAGES_SRC_FILES ${ProtoSources}) + +include_directories(${PROTOBUF3_INCLUDE_DIRS}) +add_library(XrdSsiPbEosCta ${CTA_FRONT_END_MESSAGES_SRC_FILES}) +set_target_properties(XrdSsiPbEosCta PROPERTIES LINKER_LANGUAGE CXX) +target_link_libraries(XrdSsiPbEosCta ${PROTOBUF3_LIBRARIES}) diff --git a/xroot_plugins/CMakeLists.txt b/xroot_plugins/CMakeLists.txt index aa5022442a9a24ae9395c391b7184821a380b070..00f3d03843ae9b2baa2c6c5ef9fc78b63e0a44a8 100644 --- a/xroot_plugins/CMakeLists.txt +++ b/xroot_plugins/CMakeLists.txt @@ -25,12 +25,12 @@ include_directories(${CMAKE_SOURCE_DIR}/tapeserver) # # XRootD SSI Protocol Buffer bindings # -include_directories(${CMAKE_SOURCE_DIR}/${XRD_SSI_PB_DIR}/include ${CMAKE_SOURCE_DIR}/${XRD_SSI_PB_DIR}/eos_cta/include) +include_directories(${XRD_SSI_PB_DIR}/include ${XRD_SSI_PB_DIR}/eos_cta/include) # # Compiled protocol buffers # -include_directories(${CMAKE_BINARY_DIR}/${XRD_SSI_PB_DIR}/eos_cta/protobuf ${PROTOBUF3_INCLUDE_DIRS}) +include_directories(${CMAKE_BINARY_DIR}/eos_cta ${PROTOBUF3_INCLUDE_DIRS}) # # XRootD SSI plugin for CTA Frontend diff --git a/xrootd-ssi-protobuf-interface b/xrootd-ssi-protobuf-interface index d0edce3d03d584b2a52c577aa4fc681c69d2fe4c..d36f5a1848a4164b9a1182f21614e36e854f3785 160000 --- a/xrootd-ssi-protobuf-interface +++ b/xrootd-ssi-protobuf-interface @@ -1 +1 @@ -Subproject commit d0edce3d03d584b2a52c577aa4fc681c69d2fe4c +Subproject commit d36f5a1848a4164b9a1182f21614e36e854f3785