CMakeLists.txt 11.4 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
include_directories (${ORACLE-INSTANTCLIENT_INCLUDE_DIRS})
19

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

25
26
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")

27
set (CATALOGUE_LIB_SRC_FILES
28
  ArchiveFileBuilder.cpp
29
  ArchiveFileRow.cpp
30
  ArchiveFileItor.cpp
31
  ArchiveFileItorImpl.cpp
32
  Catalogue.cpp
33
  CatalogueFactory.cpp
34
  CatalogueFactoryFactory.cpp
35
  CatalogueSchema.cpp
36
  CmdLineTool.cpp
37
  FileSizeMismatch.cpp
38
  InMemoryCatalogue.cpp
39
40
41
42
  InMemoryCatalogueFactory.cpp
  MysqlCatalogue.cpp
  MysqlCatalogueFactory.cpp
  MysqlCatalogueSchema.cpp
43
  OracleCatalogue.cpp
44
  OracleCatalogueFactory.cpp
45
  PostgresCatalogue.cpp
46
  PostgresqlCatalogueFactory.cpp
47
  SqliteCatalogueSchema.cpp
48
  TapeFileWritten.cpp
49
  TapeItemImplementation.cpp
50
  TapePool.cpp
51
  RdbmsCatalogue.cpp
52
  RdbmsCatalogueGetArchiveFilesForRepackItor.cpp
53
  RdbmsCatalogueGetArchiveFilesItor.cpp
54
  SchemaCreatingSqliteCatalogue.cpp
55
  SqliteCatalogue.cpp
56
  SqliteCatalogueFactory.cpp
57
58
  TapeForWriting.cpp
  UserSpecifiedANonEmptyTape.cpp
59
60
  UserSpecifiedANonExistentTape.cpp
  UserSpecifiedAnEmptyStringComment.cpp
61
  UserSpecifiedAnEmptyStringDiskInstanceName.cpp
62
  UserSpecifiedAnEmptyStringLogicalLibraryName.cpp
63
  UserSpecifiedAnEmptyStringMediaType.cpp
64
  UserSpecifiedAnEmptyStringStorageClassName.cpp
65
  UserSpecifiedAnEmptyStringSupply.cpp
66
  UserSpecifiedAnEmptyStringTapePoolName.cpp
67
  UserSpecifiedAnEmptyStringUsername.cpp
68
  UserSpecifiedAnEmptyStringVendor.cpp
69
70
  UserSpecifiedAnEmptyStringVid.cpp
  UserSpecifiedAnEmptyStringVo.cpp
71
  UserSpecifiedAZeroCapacity.cpp
72
  UserSpecifiedAZeroCopyNb.cpp)
73

74
add_library (ctacatalogue SHARED
Michael Davis's avatar
Michael Davis committed
75
   ${CATALOGUE_LIB_SRC_FILES})
76

Michael Davis's avatar
Michael Davis committed
77
78
set_property(TARGET ctacatalogue PROPERTY SOVERSION "${CTA_SOVERSION}")
set_property(TARGET ctacatalogue PROPERTY   VERSION "${CTA_LIBVERSION}")
Steven Murray's avatar
Steven Murray committed
79

80
set_property(TARGET ctacatalogue APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH})
81

82
83
install (TARGETS ctacatalogue DESTINATION usr/${CMAKE_INSTALL_LIBDIR})

84
target_link_libraries (ctacatalogue
85
  ctacommon
86
  ctardbms)
87

88
add_custom_command (OUTPUT sqlite_catalogue_schema.sql mysql_catalogue_schema.sql oracle_catalogue_schema.sql postgres_catalogue_schema.sql
89
90
91
92
  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
93
    | sed 's/NUMERIC\([^\)]*\)/INTEGER/g'
94
    > sqlite_catalogue_schema.sql
Tao Lin's avatar
Tao Lin committed
95
96
97
98
99
  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
    > mysql_catalogue_schema.sql
100
101
102
103
104
105
  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
    | sed 's/VARCHAR/VARCHAR2/g'
    > oracle_catalogue_schema.sql
106
107
108
109
110
  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
    > postgres_catalogue_schema.sql
111
  DEPENDS
112
    ${CMAKE_CURRENT_SOURCE_DIR}/common_catalogue_schema.sql
113
114
    ${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
115
116
    ${CMAKE_CURRENT_SOURCE_DIR}/mysql_catalogue_schema_header.sql
    ${CMAKE_CURRENT_SOURCE_DIR}/mysql_catalogue_schema_trailer.sql
117
118
    ${CMAKE_CURRENT_SOURCE_DIR}/postgres_catalogue_schema_header.sql
    ${CMAKE_CURRENT_SOURCE_DIR}/postgres_catalogue_schema_trailer.sql
119
120
    ${CMAKE_CURRENT_SOURCE_DIR}/oracle_catalogue_schema_header.sql
    ${CMAKE_CURRENT_SOURCE_DIR}/oracle_catalogue_schema_trailer.sql)
121

122
123
add_custom_command(OUTPUT sqlite_catalogue_schema.cpp
  COMMAND sed 's/^/\ \ \"/' sqlite_catalogue_schema.sql | sed 's/$$/\"/' > sqlite_catalogue_schema.cpp
124
  DEPENDS sqlite_catalogue_schema.sql)
125

126
127
128
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)
129

Tao Lin's avatar
Tao Lin committed
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# 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 mysql_catalogue_schema_trigger.cpp
  COMMAND sed 's/^/\ \ \"/' ${CMAKE_CURRENT_SOURCE_DIR}/mysql_catalogue_schema_trigger.sql | sed 's/$$/\"/' > mysql_catalogue_schema_trigger.cpp
  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/mysql_catalogue_schema_trigger.sql)


add_custom_command(OUTPUT MysqlCatalogueSchema.cpp
  COMMAND sed -e '/CTA_SQL_SCHEMA/r mysql_catalogue_schema.cpp' -e '/CTA_SQL_TRIGGER/r mysql_catalogue_schema_trigger.cpp' ${CMAKE_CURRENT_SOURCE_DIR}/MysqlCatalogueSchema.before_SQL.cpp > MysqlCatalogueSchema.cpp
  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/MysqlCatalogueSchema.before_SQL.cpp mysql_catalogue_schema.cpp mysql_catalogue_schema_trigger.cpp)

144
145
146
147
148
149
150
151
152
# 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
153

154
set(IN_MEMORY_CATALOGUE_UNIT_TESTS_LIB_SRC_FILES
155
  CatalogueTest.cpp
Steven Murray's avatar
Steven Murray committed
156
  InMemoryCatalogueTest.cpp
157
  InMemoryVersionOfCatalogueTest.cpp)
158

159
160
add_library (ctainmemorycatalogueunittests SHARED
  ${IN_MEMORY_CATALOGUE_UNIT_TESTS_LIB_SRC_FILES})
Michael Davis's avatar
Michael Davis committed
161
162
set_property(TARGET ctainmemorycatalogueunittests PROPERTY SOVERSION "${CTA_SOVERSION}")
set_property(TARGET ctainmemorycatalogueunittests PROPERTY   VERSION "${CTA_LIBVERSION}")
Steven Murray's avatar
Steven Murray committed
163

164
target_link_libraries (ctainmemorycatalogueunittests
165
  ctacatalogue)
166

167
install (TARGETS ctainmemorycatalogueunittests DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
168

169
set (DBCONFIG_CATALOGUE_UNIT_TESTS_LIB_SRC_FILES
170
  CatalogueTest.cpp
171
  DbConfigVersionOfCatalogueTest.cpp)
172

173
174
175
176
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}")
177

178
target_link_libraries (ctadbconfigcatalogueunittests
179
180
  ctacatalogue)

181
install (TARGETS ctadbconfigcatalogueunittests DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
182

183
install (FILES cta-catalogue.conf.example
184
185
  DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/cta
  PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
186

187
188
189
190
191
192
193
194
195
196
197
198
199
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
200
  SqliteCatalogueSchema.cpp
201
  PostgresCatalogueSchema.cpp
Tao Lin's avatar
Tao Lin committed
202
  MysqlCatalogueSchema.cpp)
203
204

target_link_libraries (cta-catalogue-schema-create
205
  ctacatalogue)
206

207
set_property (TARGET cta-catalogue-schema-create APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH})
208

209
210
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)
211
212
213
214

add_executable(cta-catalogue-schema-drop
  DropSchemaCmd.cpp
  DropSchemaCmdLineArgs.cpp
215
  DropSchemaCmdMain.cpp)
216
217

target_link_libraries (cta-catalogue-schema-drop
218
  ctacatalogue)
219

220
set_property (TARGET cta-catalogue-schema-drop APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH})
221

222
223
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)
224
225
226
227
228
229
230

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

target_link_libraries (cta-database-poll
231
  ctacatalogue)
232

233
set_property (TARGET cta-database-poll APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH})
234

235
236
install (TARGETS cta-database-poll DESTINATION /usr/bin)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cta-database-poll.1cta DESTINATION /usr/share/man/man1)
237
238
239
240
241
242
243

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

target_link_libraries (cta-catalogue-admin-user-create
244
  ctacatalogue)
245

246
set_property (TARGET cta-catalogue-admin-user-create APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH})
247

248
249
250
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)

251
252
253
254
add_executable(cta-catalogue-schema-verify
  VerifySchemaCmd.cpp
  VerifySchemaCmdLineArgs.cpp
  VerifySchemaCmdMain.cpp
255
  CatalogueSchema.cpp
256
257
258
259
260
261
262
263
264
265
266
267
268
269
  OracleCatalogueSchema.cpp
  SqliteCatalogueSchema.cpp
  PostgresCatalogueSchema.cpp
  MysqlCatalogueSchema.cpp)

target_link_libraries (cta-catalogue-schema-verify
  ctacatalogue)

set_property (TARGET cta-catalogue-schema-verify APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH})

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)


270
set (CATALOGUE_CMD_LINE_UNIT_TESTS_LIB_SRC_FILES
271
  CreateAdminUserCmdLineArgs.cpp
272
273
  CreateAdminUserCmdLineArgsTest.cpp
  CreateSchemaCmdLineArgs.cpp
274
  CreateSchemaCmdLineArgsTest.cpp
275
276
  VerifySchemaCmdLineArgs.cpp
  VerifySchemaCmdLineArgsTest.cpp
277
  DropSchemaCmdLineArgs.cpp
278
  DropSchemaCmdLineArgsTest.cpp
279
  PollDatabaseCmdLineArgs.cpp
280
  PollDatabaseCmdLineArgsTest.cpp)
281
282
283

add_library (ctacataloguecmdlineunittests SHARED
  ${CATALOGUE_CMD_LINE_UNIT_TESTS_LIB_SRC_FILES})
Michael Davis's avatar
Michael Davis committed
284
285
286
set_property(TARGET ctacataloguecmdlineunittests PROPERTY SOVERSION "${CTA_SOVERSION}")
set_property(TARGET ctacataloguecmdlineunittests PROPERTY   VERSION "${CTA_LIBVERSION}")

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