-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
134 lines (116 loc) · 5.54 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
cmake_minimum_required( VERSION 3.19 )
project( xrdcl-pelican )
set( CMAKE_CXX_STANDARD 20 )
find_package( XRootD REQUIRED COMPONENTS UTILS CLIENT )
find_package( CURL REQUIRED )
find_package( Threads REQUIRED )
option( ENABLE_TESTS "Enable unit tests" FALSE )
if( ENABLE_TESTS )
find_package( GTest REQUIRED )
# go-wrk is a simple HTTP load tester, useful for stress testing
# The unit test using go-wrk have a small feature improvement over
# upstream; try installing with:
# $ go install github.com/bbockelm/go-wrk@92dbe19
#
find_program(GoWrk go-wrk HINTS "$ENV{HOME}/go/bin")
enable_testing()
set(BUILD_TESTS TRUE)
else()
set(BUILD_TESTS FALSE)
endif()
add_subdirectory(tests)
if( CMAKE_COMPILER_IS_GNUCXX )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror" )
endif()
if(NOT APPLE)
SET( CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined")
SET( CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined")
endif()
if( NOT XROOTD_EXTERNAL_TINYXML2 )
# This causes tinyxml2 to be downloaded and installed to the binary directory at configure time,
# allowing this copy to be used in the find_package(tinyxml2) below
if( NOT EXISTS "${CMAKE_BINARY_DIR}/tinyxml2/tinyxml2-prefix/lib/cmake/tinyxml2/tinyxml2-config.cmake" )
file( MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/tinyxml2 )
execute_process(
COMMAND ${CMAKE_COMMAND} ${CMAKE_SOURCE_DIR}/cmake/tinyxml2
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tinyxml2
COMMAND_ERROR_IS_FATAL ANY )
execute_process(
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}/tinyxml2
COMMAND_ERROR_IS_FATAL ANY )
endif()
list( APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}/tinyxml2/tinyxml2-prefix/lib/cmake/tinyxml2" )
endif()
find_package(tinyxml2)
if( NOT XROOTD_EXTERNAL_JSON )
if( NOT EXISTS "${CMAKE_BINARY_DIR}/nlohmann_json/nlohmann_json-prefix/share/cmake/nlohmann_json/nlohmann_jsonConfig.cmake" )
file( MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/nlohmann_json )
execute_process(
COMMAND ${CMAKE_COMMAND} ${CMAKE_SOURCE_DIR}/cmake/nlohmann_json
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/nlohmann_json
COMMAND_ERROR_IS_FATAL ANY )
execute_process(
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}/nlohmann_json
COMMAND_ERROR_IS_FATAL ANY )
endif()
list( APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}/nlohmann_json/nlohmann_json-prefix/share/cmake/nlohmann_json" )
endif()
find_package(nlohmann_json)
#
# The `XErrorCode::kXR_TimerExpired` error code was not added until 5.7.0
#
include(CheckSourceCompiles)
set( CMAKE_REQUIRED_INCLUDES "${XRootD_INCLUDE_DIR}" )
CHECK_SOURCE_COMPILES(CXX
"#include <XProtocol/XProtocol.hh>
int main(void) {if (XErrorCode::kXR_TimerExpired) {return 1;} return 0;}"
HAVE_XPROTOCOL_TIMEREXPIRED)
#
# Determine if we're using a 5.x-style or 6.x-style version of the XrdClPlugInInterface
#
CHECK_SOURCE_COMPILES(CXX
"#include <XrdCl/XrdClPlugInInterface.hh>
class File final : public XrdCl::FilePlugIn {
public:
File() {}
virtual ~File() noexcept {}
virtual XrdCl::XRootDStatus Open(const std::string &, XrdCl::OpenFlags::Flags, XrdCl::Access::Mode, XrdCl::ResponseHandler *, time_t) override;
};
int main(void) {return 0;}"
HAVE_XRDCL_IFACE6)
add_library(XrdClPelicanObj OBJECT src/CurlUtil.cc src/CurlUtil.hh src/CurlListdir.cc src/CurlOps.cc src/CurlOps.hh src/PelicanFactory.cc src/PelicanFile.cc src/PelicanFile.hh src/PelicanFilesystem.cc src/PelicanFilesystem.hh src/FedInfo.cc src/FedInfo.hh src/ParseTimeout.cc src/ParseTimeout.hh src/DirectorCache.cc src/DirectorCache.hh)
target_include_directories(XrdClPelicanObj PRIVATE ${XRootD_INCLUDE_DIR})
target_link_libraries(XrdClPelicanObj ${XRootD_UTILS_LIBRARIES} ${XRootD_CLIENT_LIBRARIES} CURL::libcurl tinyxml2::tinyxml2 Threads::Threads nlohmann_json::nlohmann_json)
set_target_properties(XrdClPelicanObj PROPERTIES POSITION_INDEPENDENT_CODE ON)
if (HAVE_XPROTOCOL_TIMEREXPIRED)
target_compile_definitions(XrdClPelicanObj PRIVATE HAVE_XPROTOCOL_TIMEREXPIRED)
endif()
if (HAVE_XRDCL_IFACE6)
target_compile_definitions(XrdClPelicanObj PRIVATE HAVE_XRDCL_IFACE6)
endif()
# The test executables cannot link against the normal library on Linux as we hide the exported symbols
if (ENABLE_TESTS)
add_library(XrdClPelicanTesting SHARED "$<TARGET_OBJECTS:XrdClPelicanObj>")
target_link_libraries(XrdClPelicanTesting XrdClPelicanObj)
endif()
add_library(XrdClPelican MODULE "$<TARGET_OBJECTS:XrdClPelicanObj>")
target_link_libraries(XrdClPelican XrdClPelicanObj)
if(APPLE)
SET(LIBRARY_SUFFIX ".dylib")
set_target_properties(XrdClPelican PROPERTIES OUTPUT_NAME "XrdClPelican-${XRootD_PLUGIN_VERSION}" SUFFIX ${LIBRARY_SUFFIX})
else()
SET(LIBRARY_SUFFIX ".so")
set_target_properties(XrdClPelican PROPERTIES OUTPUT_NAME "XrdClPelican-${XRootD_PLUGIN_VERSION}" SUFFIX ${LIBRARY_SUFFIX} LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/configs/export-lib-symbols")
endif()
SET( SYSCONF_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/etc" CACHE PATH "Install path for configuration files" )
SET( LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Install path for libraries" )
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/configs/pelican-plugin.conf ${CMAKE_CURRENT_BINARY_DIR}/configs/pelican-plugin.conf)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/configs/pelican-plugin-http.conf ${CMAKE_CURRENT_BINARY_DIR}/configs/pelican-plugin-http.conf)
install(
TARGETS XrdClPelican
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/configs/pelican-plugin.conf ${CMAKE_CURRENT_BINARY_DIR}/configs/pelican-plugin-http.conf
DESTINATION ${SYSCONF_INSTALL_DIR}/xrootd/client.plugins.d/
)