forked from irods/irods
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
321 lines (279 loc) · 13 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
cmake_minimum_required(VERSION 3.12.0 FATAL_ERROR)
# target_link_libraries for object targets
# CURL::libcurl target
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
include(RequireOutOfSourceBuild)
option(IRODS_DISABLE_COMPILER_OPTIMIZATIONS "Disables compiler optimizations by setting -O0." OFF)
if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build {Debug, Release}." FORCE)
message(STATUS "Setting unspecified CMAKE_BUILD_TYPE to '${CMAKE_BUILD_TYPE}'. This is the correct setting for normal builds.")
endif()
include(IrodsExternals)
include(IrodsCXXCompiler)
macro(IRODS_MACRO_CHECK_DEPENDENCY_SET_FULLPATH_ADD_TO_IRODS_DEVELOP_DEPENDENCIES_LIST DEPENDENCY_NAME DEPENDENCY_SUBDIRECTORY)
IRODS_MACRO_CHECK_DEPENDENCY_SET_FULLPATH(${DEPENDENCY_NAME} ${DEPENDENCY_SUBDIRECTORY})
list(APPEND IRODS_DEVELOP_DEPENDENCIES_LIST irods-externals-${DEPENDENCY_SUBDIRECTORY})
endmacro()
IRODS_MACRO_CHECK_DEPENDENCY_SET_FULLPATH_ADD_TO_IRODS_PACKAGE_DEPENDENCIES_LIST(ARCHIVE libarchive3.5.2-0)
IRODS_MACRO_CHECK_DEPENDENCY_SET_FULLPATH_ADD_TO_IRODS_PACKAGE_DEPENDENCIES_LIST(AVRO avro1.11.0-1)
IRODS_MACRO_CHECK_DEPENDENCY_SET_FULLPATH_ADD_TO_IRODS_PACKAGE_DEPENDENCIES_LIST(BOOST boost1.78.0-0)
IRODS_MACRO_CHECK_DEPENDENCY_SET_FULLPATH_ADD_TO_IRODS_PACKAGE_DEPENDENCIES_LIST(FMT fmt8.1.1-0)
IRODS_MACRO_CHECK_DEPENDENCY_SET_FULLPATH_ADD_TO_IRODS_PACKAGE_DEPENDENCIES_LIST(NANODBC nanodbc2.13.0-1)
IRODS_MACRO_CHECK_DEPENDENCY_SET_FULLPATH_ADD_TO_IRODS_PACKAGE_DEPENDENCIES_LIST(ZMQ zeromq4-14.1.8-0)
IRODS_MACRO_CHECK_DEPENDENCY_SET_FULLPATH_ADD_TO_IRODS_DEVELOP_DEPENDENCIES_LIST(CATCH2 catch22.13.8-0)
IRODS_MACRO_CHECK_DEPENDENCY_SET_FULLPATH_ADD_TO_IRODS_DEVELOP_DEPENDENCIES_LIST(CPPZMQ cppzmq4.8.1-1)
IRODS_MACRO_CHECK_DEPENDENCY_SET_FULLPATH_ADD_TO_IRODS_DEVELOP_DEPENDENCIES_LIST(JSON json3.10.4-0)
IRODS_MACRO_CHECK_DEPENDENCY_SET_FULLPATH_ADD_TO_IRODS_DEVELOP_DEPENDENCIES_LIST(SPDLOG spdlog1.9.2-1)
string(REPLACE ";" ", " IRODS_PACKAGE_DEPENDENCIES_STRING "${IRODS_PACKAGE_DEPENDENCIES_LIST}")
string(REPLACE ";" ", " IRODS_DEVELOP_DEPENDENCIES_STRING "${IRODS_DEVELOP_DEPENDENCIES_LIST}")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_EXTENSIONS OFF)
set(IRODS_CXX_STANDARD "${CMAKE_CXX_STANDARD}")
# export-dynamic so stacktrace entries from executables have function names
set(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,--export-dynamic -Wl,--enable-new-dtags -Wl,--as-needed -Wl,-z,defs")
set(CMAKE_MODULE_LINKER_FLAGS_INIT "-Wl,--enable-new-dtags -Wl,--as-needed -Wl,-z,defs")
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-Wl,--enable-new-dtags -Wl,--as-needed -Wl,-z,defs")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT "-Wl,--gc-sections -Wl,-z,combreloc")
set(CMAKE_MODULE_LINKER_FLAGS_RELEASE_INIT "-Wl,--gc-sections -Wl,-z,combreloc")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT "-Wl,--gc-sections -Wl,-z,combreloc")
set(IRODS_VERSION_MAJOR "4")
set(IRODS_VERSION_MINOR "3")
set(IRODS_VERSION_PATCH "0")
set(IRODS_VERSION "${IRODS_VERSION_MAJOR}.${IRODS_VERSION_MINOR}.${IRODS_VERSION_PATCH}")
set(IRODS_PACKAGE_REVISION "1")
project(irods
VERSION ${IRODS_VERSION}
LANGUAGES C CXX)
include(ObjectTargetHelpers)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
if (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
set(IRODS_BUILD_WITH_WERROR_DEFAULT ON)
else()
set(IRODS_BUILD_WITH_WERROR_DEFAULT OFF)
endif()
set(IRODS_BUILD_WITH_WERROR ${IRODS_BUILD_WITH_WERROR_DEFAULT} CACHE BOOL "Choose whether to compile with -Werror.")
if (IRODS_BUILD_WITH_WERROR)
add_compile_options(-Werror)
endif()
include(UseLibCXX)
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/InstallDirs.cmake)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_SKIP_INSTALL_RPATH FALSE)
set(CMAKE_SKIP_RPATH FALSE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
if (IRODS_DISABLE_COMPILER_OPTIMIZATIONS)
add_compile_options(-O0)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fpermissive>)
endif()
add_compile_options(-Wall -Wextra)
check_cxx_compiler_flag(-Wno-write-strings can_use_wwrite_strings_cxx)
if (can_use_wwrite_strings_cxx)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-write-strings>)
endif()
check_c_compiler_flag(-Wno-unused-function can_use_wunused_function_c)
check_cxx_compiler_flag(-Wno-unused-function can_use_wunused_function_cxx)
if (can_use_wunused_function_c)
add_compile_options($<$<COMPILE_LANGUAGE:C>:-Wno-unused-function>)
endif()
if (can_use_wunused_function_cxx)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-unused-function>)
endif()
check_c_compiler_flag(-Wno-unused-parameter can_use_wunused_parameter_c)
check_cxx_compiler_flag(-Wno-unused-parameter can_use_wunused_parameter_cxx)
if (can_use_wunused_parameter_c)
add_compile_options($<$<COMPILE_LANGUAGE:C>:-Wno-unused-parameter>)
endif()
if (can_use_wunused_parameter_cxx)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-unused-parameter>)
endif()
check_c_compiler_flag(-Wno-parentheses can_use_wparentheses_c)
check_cxx_compiler_flag(-Wno-parentheses can_use_wparentheses_cxx)
if (can_use_wparentheses_c)
add_compile_options($<$<COMPILE_LANGUAGE:C>:-Wno-parentheses>)
endif()
if (can_use_wparentheses_cxx)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-parentheses>)
endif()
check_cxx_compiler_flag(-Wno-ignored-qualifiers can_use_wignored_qualifiers_cxx)
check_c_compiler_flag(-Wno-ignored-qualifiers can_use_wignored_qualifiers_c)
if (can_use_wignored_qualifiers_c)
add_compile_options($<$<COMPILE_LANGUAGE:C>:-Wno-ignored-qualifiers>)
endif()
if (can_use_wignored_qualifiers_cxx)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-ignored-qualifiers>)
endif()
if (IRODS_BUILD_WITH_WERROR)
check_c_compiler_flag(-Wno-error=unused-variable can_use_wunused_variable_c)
check_cxx_compiler_flag(-Wno-error=unused-variable can_use_wunused_variable_cxx)
if (can_use_wunused_variable_c)
add_compile_options($<$<COMPILE_LANGUAGE:C>:-Wno-error=unused-variable>)
endif()
if (can_use_wunused_variable_cxx)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-error=unused-variable>)
endif()
check_c_compiler_flag(-Wno-error=unused-but-set-variable can_use_wunused_but_set_variable_c)
check_cxx_compiler_flag(-Wno-error=unused-but-set-variable can_use_wunused_but_set_variable_cxx)
if (can_use_wunused_but_set_variable_c)
add_compile_options($<$<COMPILE_LANGUAGE:C>:-Wno-error=unused-but-set-variable>)
endif()
if (can_use_wunused_but_set_variable_cxx)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-error=unused-but-set-variable>)
endif()
# Do not error on definition of implicit copy constructor for classes with a
# user-declared copy assignment operator.
# This is needed because the boost headers throw this warning.
check_cxx_compiler_flag(-Wno-error=deprecated-copy can_use_wdeprecated_copy_cxx)
if (can_use_wdeprecated_copy_cxx)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-error=deprecated-copy>)
endif()
# Do not error when overlapping comparisons always evaluate to false.
# This is needed because the boost headers throw this warning.
check_c_compiler_flag(-Wno-error=tautological-overlap-compare can_use_wtautological_overlap_compare_c)
check_cxx_compiler_flag(-Wno-error=tautological-overlap-compare can_use_wtautological_overlap_compare_cxx)
if (can_use_wtautological_overlap_compare_c)
add_compile_options($<$<COMPILE_LANGUAGE:C>:-Wno-error=tautological-overlap-compare>)
endif()
if (can_use_wtautological_overlap_compare_cxx)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-error=tautological-overlap-compare>)
endif()
endif()
find_package(nlohmann_json "3.6.1" REQUIRED)
if (NOT DEFINED THREADS_PREFER_PTHREAD_FLAG)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
endif()
find_package(Threads REQUIRED)
find_package(CURL REQUIRED)
find_package(OpenSSL REQUIRED COMPONENTS Crypto SSL)
include(IrodsCPackPlatform)
set(IRODS_PLATFORM_STRING linux_platform)
set(
IRODS_COMPILE_DEFINITIONS_PUBLIC
${IRODS_PLATFORM_STRING}
_LARGEFILE_SOURCE
_FILE_OFFSET_BITS=64
_LARGE_FILES
_LARGEFILE64_SOURCE
)
set(
IRODS_COMPILE_DEFINITIONS_PRIVATE
BOOST_SYSTEM_NO_DEPRECATED
BOOST_CHRONO_DONT_PROVIDES_DEPRECATED_IO_SINCE_V2_0_0
BOOST_STACKTRACE_USE_ADDR2LINE
BOOST_ASIO_NO_DEPRECATED
SPDLOG_FMT_EXTERNAL
SPDLOG_NO_TLS
)
# Manually defined because Boost cannot detect that std::result_of has been removed in C++20.
# Verified that Boost 1.77 and Boost 1.78 do not handle this yet. Normally, defining
# BOOST_ASIO_HAS_ macros should be avoided except when absolutely required as a workaround for the
# latest version of a compiler or platform.
# See the following for more information:
# https://www.boost.org/doc/libs/1_77_0/doc/html/boost_asio/using.html
list(APPEND IRODS_COMPILE_DEFINITIONS_PRIVATE "BOOST_ASIO_HAS_STD_INVOKE_RESULT")
# Define our component names here so they're defined everywhere
set(IRODS_PACKAGE_COMPONENT_RUNTIME_NAME "irods-runtime")
set(IRODS_PACKAGE_COMPONENT_SERVER_NAME "irods-server")
set(IRODS_PACKAGE_COMPONENT_DEVELOPMENT_NAME "irods-dev")
set(IRODS_PACKAGE_COMPONENT_POSTGRES_NAME "irods-database-plugin-postgres")
set(IRODS_PACKAGE_COMPONENT_MYSQL_NAME "irods-database-plugin-mysql")
set(IRODS_PACKAGE_COMPONENT_ORACLE_NAME "irods-database-plugin-oracle")
set(CMAKE_IRODS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(CMAKE_IRODS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
include(GetGitRevisionDescription)
get_git_head_revision(IRODS_GIT_REFSPEC IRODS_GIT_SHA1)
configure_file(
"${CMAKE_IRODS_SOURCE_DIR}/version.json.dist.in"
"${CMAKE_IRODS_BINARY_DIR}/version.json.dist"
@ONLY
)
add_subdirectory(lib)
add_subdirectory(server)
add_subdirectory(plugins)
add_subdirectory(test/c_api_test)
add_subdirectory(test/post_install_test)
add_subdirectory(unit_tests)
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/packaging.cmake")
include(CMakePackageConfigHelpers)
configure_package_config_file(
"${CMAKE_IRODS_SOURCE_DIR}/cmake/IRODSConfig.cmake.not_yet_installed.in"
"${CMAKE_IRODS_BINARY_DIR}/IRODSConfig.cmake.not_yet_installed" # suffix prevents cmake's find_package() from using this copy of the file
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/irods/cmake"
PATH_VARS IRODS_INCLUDE_DIRS
)
install(
FILES
"${CMAKE_IRODS_BINARY_DIR}/IRODSConfig.cmake.not_yet_installed"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/irods/cmake"
COMPONENT ${IRODS_PACKAGE_COMPONENT_DEVELOPMENT_NAME}
RENAME IRODSConfig.cmake
)
write_basic_package_version_file(
"${CMAKE_IRODS_BINARY_DIR}/IRODSConfigVersion.cmake"
VERSION ${IRODS_VERSION}
COMPATIBILITY ExactVersion
)
install(
FILES
"${CMAKE_IRODS_BINARY_DIR}/IRODSConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/irods/cmake"
COMPONENT ${IRODS_PACKAGE_COMPONENT_DEVELOPMENT_NAME}
)
install(
FILES
"${CMAKE_IRODS_SOURCE_DIR}/cmake/Modules/RequireOutOfSourceBuild.cmake"
"${CMAKE_IRODS_SOURCE_DIR}/cmake/Modules/GetGitRevisionDescription.cmake"
"${CMAKE_IRODS_SOURCE_DIR}/cmake/Modules/GetGitRevisionDescription.cmake.in"
"${CMAKE_IRODS_SOURCE_DIR}/cmake/Modules/CheckCPPMacroDefinition.cmake"
"${CMAKE_IRODS_SOURCE_DIR}/cmake/Modules/CheckCPPMacroDefinition.c.in"
"${CMAKE_IRODS_SOURCE_DIR}/cmake/Modules/FindLibCXX.cmake"
"${CMAKE_IRODS_SOURCE_DIR}/cmake/Modules/UseLibCXX.cmake"
"${CMAKE_IRODS_SOURCE_DIR}/cmake/Modules/Findnlohmann_json.cmake"
"${CMAKE_IRODS_SOURCE_DIR}/cmake/Modules/IrodsExternals.cmake"
"${CMAKE_IRODS_SOURCE_DIR}/cmake/Modules/IrodsCXXCompiler.cmake"
"${CMAKE_IRODS_SOURCE_DIR}/cmake/Modules/ObjectTargetHelpers.cmake"
"${CMAKE_IRODS_SOURCE_DIR}/cmake/Modules/IrodsCPackPlatform.cmake"
"${CMAKE_IRODS_SOURCE_DIR}/cmake/Modules/IrodsCPackCommon.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/irods/cmake/Modules"
COMPONENT ${IRODS_PACKAGE_COMPONENT_DEVELOPMENT_NAME}
)
install(
EXPORT
IRODSTargets
DESTINATION "${CMAKE_INSTALL_LIBDIR}/irods/cmake"
COMPONENT ${IRODS_PACKAGE_COMPONENT_DEVELOPMENT_NAME}
)
foreach(DATABASE_PLUGIN postgres oracle mysql)
string(TOUPPER ${DATABASE_PLUGIN} DATABASE_PLUGIN_UPPER)
add_custom_target(
non-package-install-${DATABASE_PLUGIN}
COMMAND
"${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=${IRODS_PACKAGE_COMPONENT_SERVER_NAME} -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake"
COMMAND
"${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=${IRODS_PACKAGE_COMPONENT_DEVELOPMENT_NAME} -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake"
COMMAND
"${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=${IRODS_PACKAGE_COMPONENT_RUNTIME_NAME} -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake"
COMMAND
"${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=${IRODS_PACKAGE_COMPONENT_${DATABASE_PLUGIN_UPPER}_NAME} -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake"
)
add_dependencies(
non-package-install-${DATABASE_PLUGIN}
all-lib
all-server
all-plugins_no_database
irods_database_plugin-${DATABASE_PLUGIN}
IRODS_PHONY_TARGET_icatSysTables_${DATABASE_PLUGIN}.sql
irodsTestPutGet
)
if (IRODS_UNIT_TESTS_BUILD)
add_dependencies(
non-package-install-${DATABASE_PLUGIN}
all-unit_tests
)
endif()
endforeach()
include(CPack)