CMakeLists.txt 12.7 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# The CERN Tape Archive (CTA) project
# Copyright (C) 2015  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)

18
19
find_package(Protobuf3 REQUIRED)

20
include_directories (${ORACLE-INSTANTCLIENT_INCLUDE_DIRS})
21

22
23
24
25
26
#
# Compiled protocol buffers (for ChecksumBlob)
#
include_directories(${CMAKE_BINARY_DIR}/eos_cta ${PROTOBUF3_INCLUDE_DIRS})

27
28
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")

29
set (CATALOGUE_LIB_SRC_FILES
30
  ArchiveFileBuilder.cpp
31
  ArchiveFileRow.cpp
32
  ArchiveFileItor.cpp
33
  ArchiveFileItorImpl.cpp
34
  Catalogue.cpp
35
  CatalogueFactory.cpp
36
  CatalogueFactoryFactory.cpp
37
  CatalogueSchema.cpp
38
  CmdLineTool.cpp
39
  InMemoryCatalogue.cpp
40
41
42
43
  InMemoryCatalogueFactory.cpp
  MysqlCatalogue.cpp
  MysqlCatalogueFactory.cpp
  MysqlCatalogueSchema.cpp
44
  OracleCatalogue.cpp
45
  OracleCatalogueFactory.cpp
46
  PostgresCatalogue.cpp
47
  PostgresqlCatalogueFactory.cpp
48
  SqliteCatalogueSchema.cpp
49
  TapeFileWritten.cpp
50
  TapeItemImplementation.cpp
51
  TapePool.cpp
52
  RdbmsCatalogue.cpp
53
  RdbmsCatalogueGetArchiveFilesForRepackItor.cpp
54
  RdbmsCatalogueGetArchiveFilesItor.cpp
55
  SchemaCreatingSqliteCatalogue.cpp
56
  SqliteCatalogue.cpp
57
  SqliteCatalogueFactory.cpp
58
  TapeForWriting.cpp
59
  UserSpecifiedANonEmptyLogicalLibrary.cpp
60
  UserSpecifiedANonEmptyTape.cpp
61
  UserSpecifiedANonExistentLogicalLibrary.cpp
62
  UserSpecifiedANonExistentTape.cpp
63
64
  UserSpecifiedANonExistentDiskSystem.cpp
  UserSpecifiedANonEmptyDiskSystemAfterDelete.cpp
65
  UserSpecifiedAnEmptyStringComment.cpp
66
  UserSpecifiedAnEmptyStringDiskInstanceName.cpp
67
68
69
70
71
  UserSpecifiedAnEmptyStringDiskSystemName.cpp
  UserSpecifiedAnEmptyStringFileRegexp.cpp
  UserSpecifiedAnEmptyStringFreeSpaceQueryURL.cpp
  UserSpecifiedAZeroRefreshInterval.cpp
  UserSpecifiedAZeroTargetedFreeSpace.cpp
72
  UserSpecifiedAnEmptyStringLogicalLibraryName.cpp
73
  UserSpecifiedAnEmptyStringMediaType.cpp
74
  UserSpecifiedAnEmptyStringStorageClassName.cpp
75
  UserSpecifiedAnEmptyStringSupply.cpp
76
  UserSpecifiedAnEmptyStringTapePoolName.cpp
77
  UserSpecifiedAnEmptyStringUsername.cpp
78
  UserSpecifiedAnEmptyStringVendor.cpp
79
80
  UserSpecifiedAnEmptyStringVid.cpp
  UserSpecifiedAnEmptyStringVo.cpp
81
  UserSpecifiedAnEmptyTapePool.cpp
82
83
  UserSpecifiedStorageClassUsedByArchiveFiles.cpp
  UserSpecifiedStorageClassUsedByArchiveRoutes.cpp
84
85
  UserSpecifiedAZeroCapacity.cpp
  UserSpecifiedAZeroCopyNb.cpp)
86

87
add_library (ctacatalogue SHARED
Michael Davis's avatar
Michael Davis committed
88
   ${CATALOGUE_LIB_SRC_FILES})
89

Michael Davis's avatar
Michael Davis committed
90
91
set_property(TARGET ctacatalogue PROPERTY SOVERSION "${CTA_SOVERSION}")
set_property(TARGET ctacatalogue PROPERTY   VERSION "${CTA_LIBVERSION}")
Steven Murray's avatar
Steven Murray committed
92

93
94
install (TARGETS ctacatalogue DESTINATION usr/${CMAKE_INSTALL_LIBDIR})

95
target_link_libraries (ctacatalogue
96
  ctacommon
97
  ctardbms)
98

99
add_custom_command (OUTPUT sqlite_catalogue_schema.sql mysql_catalogue_schema.sql oracle_catalogue_schema.sql postgres_catalogue_schema.sql
100
101
102
103
  COMMAND cat
    ${CMAKE_CURRENT_SOURCE_DIR}/sqlite_catalogue_schema_header.sql
    ${CMAKE_CURRENT_SOURCE_DIR}/common_catalogue_schema.sql
    ${CMAKE_CURRENT_SOURCE_DIR}/sqlite_catalogue_schema_trailer.sql
Steven Murray's avatar
Steven Murray committed
104
    | sed 's/UINT16TYPE/INTEGER/g'
Steven Murray's avatar
Steven Murray committed
105
    | sed 's/UINT32TYPE/INTEGER/g'
106
    | sed 's/UINT64TYPE/INTEGER/g'
107
    | sed 's/NUMERIC\([^\)]*\)/INTEGER/g'
108
    | sed 's/CHECKSUM_BLOB_TYPE/BLOB\(200\)/g'
109
    > sqlite_catalogue_schema.sql
Tao Lin's avatar
Tao Lin committed
110
111
112
113
  COMMAND cat 
    ${CMAKE_CURRENT_SOURCE_DIR}/mysql_catalogue_schema_header.sql 
    ${CMAKE_CURRENT_SOURCE_DIR}/common_catalogue_schema.sql 
    ${CMAKE_CURRENT_SOURCE_DIR}/mysql_catalogue_schema_trailer.sql
114
115
    | sed 's/UINT16TYPE/SMALLINT UNSIGNED/g'
    | sed 's/UINT32TYPE/INT UNSIGNED/g'
116
    | sed 's/UINT64TYPE/BIGINT UNSIGNED/g'
117
    | sed 's/NUMERIC\([^\)]*\)/BIGINT UNSIGNED/g'
118
    | sed 's/CHECKSUM_BLOB_TYPE/VARBINARY\(200\)/g'
Tao Lin's avatar
Tao Lin committed
119
    > mysql_catalogue_schema.sql
120
121
122
123
  COMMAND cat
    ${CMAKE_CURRENT_SOURCE_DIR}/oracle_catalogue_schema_header.sql
    ${CMAKE_CURRENT_SOURCE_DIR}/common_catalogue_schema.sql
    ${CMAKE_CURRENT_SOURCE_DIR}/oracle_catalogue_schema_trailer.sql
124
125
126
    | sed 's/UINT16TYPE/NUMERIC\(5, 0\)/g'
    | sed 's/UINT32TYPE/NUMERIC\(10, 0\)/g'
    | sed 's/UINT64TYPE/NUMERIC\(20, 0\)/g'
127
    | sed 's/VARCHAR/VARCHAR2/g'
128
    | sed 's/CHECKSUM_BLOB_TYPE/RAW\(200\)/g'
129
    > oracle_catalogue_schema.sql
130
131
132
133
  COMMAND cat
    ${CMAKE_CURRENT_SOURCE_DIR}/postgres_catalogue_schema_header.sql
    ${CMAKE_CURRENT_SOURCE_DIR}/common_catalogue_schema.sql
    ${CMAKE_CURRENT_SOURCE_DIR}/postgres_catalogue_schema_trailer.sql
134
135
136
    | sed 's/UINT16TYPE/NUMERIC\(5, 0\)/g'
    | sed 's/UINT32TYPE/NUMERIC\(10, 0\)/g'
    | sed 's/UINT64TYPE/NUMERIC\(20, 0\)/g'
137
    | sed 's/CHECKSUM_BLOB_TYPE/BYTEA/g'
138
    > postgres_catalogue_schema.sql
139
  DEPENDS
140
    ${CMAKE_CURRENT_SOURCE_DIR}/common_catalogue_schema.sql
141
142
    ${CMAKE_CURRENT_SOURCE_DIR}/sqlite_catalogue_schema_header.sql
    ${CMAKE_CURRENT_SOURCE_DIR}/sqlite_catalogue_schema_trailer.sql
Tao Lin's avatar
Tao Lin committed
143
144
    ${CMAKE_CURRENT_SOURCE_DIR}/mysql_catalogue_schema_header.sql
    ${CMAKE_CURRENT_SOURCE_DIR}/mysql_catalogue_schema_trailer.sql
145
146
    ${CMAKE_CURRENT_SOURCE_DIR}/postgres_catalogue_schema_header.sql
    ${CMAKE_CURRENT_SOURCE_DIR}/postgres_catalogue_schema_trailer.sql
147
148
    ${CMAKE_CURRENT_SOURCE_DIR}/oracle_catalogue_schema_header.sql
    ${CMAKE_CURRENT_SOURCE_DIR}/oracle_catalogue_schema_trailer.sql)
149

150
151
add_custom_command(OUTPUT sqlite_catalogue_schema.cpp
  COMMAND sed 's/^/\ \ \"/' sqlite_catalogue_schema.sql | sed 's/$$/\"/' > sqlite_catalogue_schema.cpp
152
  DEPENDS sqlite_catalogue_schema.sql)
153

154
155
156
add_custom_command(OUTPUT SqliteCatalogueSchema.cpp
  COMMAND sed '/CTA_SQL_SCHEMA/r sqlite_catalogue_schema.cpp' ${CMAKE_CURRENT_SOURCE_DIR}/SqliteCatalogueSchema.before_SQL.cpp > SqliteCatalogueSchema.cpp
  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/SqliteCatalogueSchema.before_SQL.cpp sqlite_catalogue_schema.cpp)
157

Tao Lin's avatar
Tao Lin committed
158
159
160
161
162
163
# For Mysql
add_custom_command(OUTPUT mysql_catalogue_schema.cpp
  COMMAND sed 's/^/\ \ \"/' mysql_catalogue_schema.sql | sed 's/$$/\"/' > mysql_catalogue_schema.cpp
  DEPENDS mysql_catalogue_schema.sql)

add_custom_command(OUTPUT MysqlCatalogueSchema.cpp
164
165
  COMMAND sed -e '/CTA_SQL_SCHEMA/r mysql_catalogue_schema.cpp' ${CMAKE_CURRENT_SOURCE_DIR}/MysqlCatalogueSchema.before_SQL.cpp > MysqlCatalogueSchema.cpp
  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/MysqlCatalogueSchema.before_SQL.cpp mysql_catalogue_schema.cpp)
Tao Lin's avatar
Tao Lin committed
166

167
168
169
170
171
172
173
174
175
# For Postgres
add_custom_command(OUTPUT postgres_catalogue_schema.cpp
  COMMAND sed 's/^/\ \ \"/' postgres_catalogue_schema.sql | sed 's/$$/\"/' > postgres_catalogue_schema.cpp
  DEPENDS postgres_catalogue_schema.sql)

add_custom_command(OUTPUT PostgresCatalogueSchema.cpp
  COMMAND sed -e '/CTA_SQL_SCHEMA/r postgres_catalogue_schema.cpp' ${CMAKE_CURRENT_SOURCE_DIR}/PostgresCatalogueSchema.before_SQL.cpp > PostgresCatalogueSchema.cpp
  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/PostgresCatalogueSchema.before_SQL.cpp postgres_catalogue_schema.cpp)

Tao Lin's avatar
Tao Lin committed
176

177
set(IN_MEMORY_CATALOGUE_UNIT_TESTS_LIB_SRC_FILES
178
  CatalogueTest.cpp
Steven Murray's avatar
Steven Murray committed
179
  InMemoryCatalogueTest.cpp
180
181
  InMemoryVersionOfCatalogueTest.cpp
  TapeItemWrittenPointerTest.cpp)
182

183
184
add_library (ctainmemorycatalogueunittests SHARED
  ${IN_MEMORY_CATALOGUE_UNIT_TESTS_LIB_SRC_FILES})
Michael Davis's avatar
Michael Davis committed
185
186
set_property(TARGET ctainmemorycatalogueunittests PROPERTY SOVERSION "${CTA_SOVERSION}")
set_property(TARGET ctainmemorycatalogueunittests PROPERTY   VERSION "${CTA_LIBVERSION}")
Steven Murray's avatar
Steven Murray committed
187

188
target_link_libraries (ctainmemorycatalogueunittests
189
  ctacatalogue ctadisk)
190

191
install (TARGETS ctainmemorycatalogueunittests DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
192

193
set (DBCONFIG_CATALOGUE_UNIT_TESTS_LIB_SRC_FILES
194
  CatalogueTest.cpp
195
  DbConfigVersionOfCatalogueTest.cpp)
196

197
198
199
200
add_library (ctadbconfigcatalogueunittests SHARED
  ${DBCONFIG_CATALOGUE_UNIT_TESTS_LIB_SRC_FILES})
set_property(TARGET ctadbconfigcatalogueunittests PROPERTY SOVERSION "${CTA_SOVERSION}")
set_property(TARGET ctadbconfigcatalogueunittests PROPERTY   VERSION "${CTA_LIBVERSION}")
201

202
target_link_libraries (ctadbconfigcatalogueunittests
203
204
  ctacatalogue)

205
install (TARGETS ctadbconfigcatalogueunittests DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
206

207
install (FILES cta-catalogue.conf.example
208
209
  DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/cta
  PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
210

211
212
213
214
215
216
217
218
219
220
221
222
223
add_custom_command(OUTPUT oracle_catalogue_schema.cpp
  COMMAND sed 's/^/\ \ \"/' oracle_catalogue_schema.sql | sed 's/$$/\"/' > oracle_catalogue_schema.cpp
  DEPENDS oracle_catalogue_schema.sql)

add_custom_command(OUTPUT OracleCatalogueSchema.cpp
  COMMAND sed '/CTA_SQL_SCHEMA/r oracle_catalogue_schema.cpp' ${CMAKE_CURRENT_SOURCE_DIR}/OracleCatalogueSchema.before_SQL.cpp > OracleCatalogueSchema.cpp
  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/OracleCatalogueSchema.before_SQL.cpp oracle_catalogue_schema.cpp)

add_executable(cta-catalogue-schema-create
  CreateSchemaCmd.cpp
  CreateSchemaCmdLineArgs.cpp
  CreateSchemaCmdMain.cpp
  OracleCatalogueSchema.cpp
Tao Lin's avatar
Tao Lin committed
224
  SqliteCatalogueSchema.cpp
225
  PostgresCatalogueSchema.cpp
Tao Lin's avatar
Tao Lin committed
226
  MysqlCatalogueSchema.cpp)
227

228
229
230
target_link_libraries (cta-catalogue-schema-create ctacatalogue)
set_property(TARGET cta-catalogue-schema-create APPEND PROPERTY INSTALL_RPATH ${PROTOBUF3_RPATH})
set_property(TARGET cta-catalogue-schema-create APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH})
231

232
233
install (TARGETS cta-catalogue-schema-create DESTINATION /usr/bin)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cta-catalogue-schema-create.1cta DESTINATION /usr/share/man/man1)
234
235
236
237

add_executable(cta-catalogue-schema-drop
  DropSchemaCmd.cpp
  DropSchemaCmdLineArgs.cpp
238
  DropSchemaCmdMain.cpp)
239

240
241
242
target_link_libraries (cta-catalogue-schema-drop ctacatalogue)
set_property(TARGET cta-catalogue-schema-drop APPEND PROPERTY INSTALL_RPATH ${PROTOBUF3_RPATH})
set_property(TARGET cta-catalogue-schema-drop APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH})
243

244
245
install (TARGETS cta-catalogue-schema-drop DESTINATION /usr/bin)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cta-catalogue-schema-drop.1cta DESTINATION /usr/share/man/man1)
246
247
248
249
250
251

add_executable(cta-database-poll
  PollDatabaseCmd.cpp
  PollDatabaseCmdLineArgs.cpp
  PollDatabaseCmdMain.cpp)

252
253
254
target_link_libraries (cta-database-poll ctacatalogue)
set_property(TARGET cta-database-poll APPEND PROPERTY INSTALL_RPATH ${PROTOBUF3_RPATH})
set_property(TARGET cta-database-poll APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH})
255

256
257
install (TARGETS cta-database-poll DESTINATION /usr/bin)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cta-database-poll.1cta DESTINATION /usr/share/man/man1)
258
259
260
261
262
263

add_executable(cta-catalogue-admin-user-create
  CreateAdminUserCmd.cpp
  CreateAdminUserCmdLineArgs.cpp
  CreateAdminUserCmdMain.cpp)

264
target_link_libraries(cta-catalogue-admin-user-create ctacatalogue) 
265
set_property(TARGET cta-catalogue-admin-user-create APPEND PROPERTY INSTALL_RPATH ${PROTOBUF3_RPATH})
266
set_property(TARGET cta-catalogue-admin-user-create APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH})
267

268
269
install(TARGETS cta-catalogue-admin-user-create DESTINATION /usr/bin)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cta-catalogue-admin-user-create.1cta DESTINATION /usr/share/man/man1)
270

271
272
273
274
add_executable(cta-catalogue-schema-verify
  VerifySchemaCmd.cpp
  VerifySchemaCmdLineArgs.cpp
  VerifySchemaCmdMain.cpp
275
  CatalogueSchema.cpp
276
277
278
279
280
  OracleCatalogueSchema.cpp
  SqliteCatalogueSchema.cpp
  PostgresCatalogueSchema.cpp
  MysqlCatalogueSchema.cpp)

281
target_link_libraries(cta-catalogue-schema-verify ctacatalogue)
282
set_property(TARGET cta-catalogue-schema-verify APPEND PROPERTY INSTALL_RPATH ${PROTOBUF3_RPATH})
283
set_property(TARGET cta-catalogue-schema-verify APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH})
284
285
286
287
288

install (TARGETS cta-catalogue-schema-verify DESTINATION /usr/bin)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cta-catalogue-schema-verify.1cta DESTINATION /usr/share/man/man1)


289
set (CATALOGUE_CMD_LINE_UNIT_TESTS_LIB_SRC_FILES
290
  CreateAdminUserCmdLineArgs.cpp
291
292
  CreateAdminUserCmdLineArgsTest.cpp
  CreateSchemaCmdLineArgs.cpp
293
  CreateSchemaCmdLineArgsTest.cpp
294
295
  VerifySchemaCmdLineArgs.cpp
  VerifySchemaCmdLineArgsTest.cpp
296
  DropSchemaCmdLineArgs.cpp
297
  DropSchemaCmdLineArgsTest.cpp
298
  PollDatabaseCmdLineArgs.cpp
299
  PollDatabaseCmdLineArgsTest.cpp)
300
301
302

add_library (ctacataloguecmdlineunittests SHARED
  ${CATALOGUE_CMD_LINE_UNIT_TESTS_LIB_SRC_FILES})
Michael Davis's avatar
Michael Davis committed
303
304
305
set_property(TARGET ctacataloguecmdlineunittests PROPERTY SOVERSION "${CTA_SOVERSION}")
set_property(TARGET ctacataloguecmdlineunittests PROPERTY   VERSION "${CTA_LIBVERSION}")

306
install (TARGETS ctacataloguecmdlineunittests DESTINATION usr/${CMAKE_INSTALL_LIBDIR})