CMakeLists.txt 9.53 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
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")

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

67
add_library (ctacatalogue SHARED
Michael Davis's avatar
Michael Davis committed
68
69
70
   ${CATALOGUE_LIB_SRC_FILES})
set_property(TARGET ctacatalogue PROPERTY SOVERSION "${CTA_SOVERSION}")
set_property(TARGET ctacatalogue PROPERTY   VERSION "${CTA_LIBVERSION}")
Steven Murray's avatar
Steven Murray committed
71

72
set_property (TARGET ctacatalogue APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH})
73

74
75
install (TARGETS ctacatalogue DESTINATION usr/${CMAKE_INSTALL_LIBDIR})

76
target_link_libraries (ctacatalogue
77
  ctacommon
78
  ctardbms)
79

Tao Lin's avatar
Tao Lin committed
80
add_custom_command (OUTPUT sqlite_catalogue_schema.sql mysql_catalogue_schema.sql oracle_catalogue_schema.sql
81
82
83
84
  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
85
    | sed 's/NUMERIC\([^\)]*\)/INTEGER/g'
86
    > sqlite_catalogue_schema.sql
Tao Lin's avatar
Tao Lin committed
87
88
89
90
91
  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
92
93
94
95
96
97
  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
98
  DEPENDS
99
    ${CMAKE_CURRENT_SOURCE_DIR}/common_catalogue_schema.sql
100
101
    ${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
102
103
    ${CMAKE_CURRENT_SOURCE_DIR}/mysql_catalogue_schema_header.sql
    ${CMAKE_CURRENT_SOURCE_DIR}/mysql_catalogue_schema_trailer.sql
104
105
    ${CMAKE_CURRENT_SOURCE_DIR}/oracle_catalogue_schema_header.sql
    ${CMAKE_CURRENT_SOURCE_DIR}/oracle_catalogue_schema_trailer.sql)
106

107
108
add_custom_command(OUTPUT sqlite_catalogue_schema.cpp
  COMMAND sed 's/^/\ \ \"/' sqlite_catalogue_schema.sql | sed 's/$$/\"/' > sqlite_catalogue_schema.cpp
109
  DEPENDS sqlite_catalogue_schema.sql)
110

111
112
113
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)
114

Tao Lin's avatar
Tao Lin committed
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# 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)


130
set(IN_MEMORY_CATALOGUE_UNIT_TESTS_LIB_SRC_FILES
131
  CatalogueTest.cpp
Steven Murray's avatar
Steven Murray committed
132
  InMemoryCatalogueTest.cpp
133
  InMemoryVersionOfCatalogueTest.cpp)
134

135
136
add_library (ctainmemorycatalogueunittests SHARED
  ${IN_MEMORY_CATALOGUE_UNIT_TESTS_LIB_SRC_FILES})
Michael Davis's avatar
Michael Davis committed
137
138
set_property(TARGET ctainmemorycatalogueunittests PROPERTY SOVERSION "${CTA_SOVERSION}")
set_property(TARGET ctainmemorycatalogueunittests PROPERTY   VERSION "${CTA_LIBVERSION}")
Steven Murray's avatar
Steven Murray committed
139

140
target_link_libraries (ctainmemorycatalogueunittests
141
  ctacatalogue)
142

143
install (TARGETS ctainmemorycatalogueunittests DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
144

145
set (CATALOGUE_UNIT_TESTS_LIB_SRC_FILES
146
  CatalogueTest.cpp
147
  DbConfigVersionOfCatalogueTest.cpp)
148

149
150
add_library (ctacatalogueunittests SHARED
  ${CATALOGUE_UNIT_TESTS_LIB_SRC_FILES})
Michael Davis's avatar
Michael Davis committed
151
152
set_property(TARGET ctacatalogueunittests PROPERTY SOVERSION "${CTA_SOVERSION}")
set_property(TARGET ctacatalogueunittests PROPERTY   VERSION "${CTA_LIBVERSION}")
153

154
target_link_libraries (ctacatalogueunittests
155
156
  ctacatalogue)

157
install (TARGETS ctacatalogueunittests DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
158

159
install (FILES cta-catalogue.conf.example
160
161
  DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/cta
  PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
162

163
164
165
166
167
168
169
170
171
172
173
174
175
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
176
177
  SqliteCatalogueSchema.cpp
  MysqlCatalogueSchema.cpp)
178
179
180
181

target_link_libraries (cta-catalogue-schema-create
  ctacatalogue)

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

184
185
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)
186
187
188
189

add_executable(cta-catalogue-schema-drop
  DropSchemaCmd.cpp
  DropSchemaCmdLineArgs.cpp
190
  DropSchemaCmdMain.cpp)
191
192
193
194

target_link_libraries (cta-catalogue-schema-drop
  ctacatalogue)

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

197
198
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)
199
200
201
202
203
204
205
206
207

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

target_link_libraries (cta-database-poll
  ctacatalogue)

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

210
211
install (TARGETS cta-database-poll DESTINATION /usr/bin)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cta-database-poll.1cta DESTINATION /usr/share/man/man1)
212
213
214
215
216
217
218
219
220

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

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

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

223
224
225
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)

226
set (CATALOGUE_CMD_LINE_UNIT_TESTS_LIB_SRC_FILES
227
  CreateAdminUserCmdLineArgs.cpp
228
229
  CreateAdminUserCmdLineArgsTest.cpp
  CreateSchemaCmdLineArgs.cpp
230
231
  CreateSchemaCmdLineArgsTest.cpp
  DropSchemaCmdLineArgs.cpp
232
  DropSchemaCmdLineArgsTest.cpp
233
  PollDatabaseCmdLineArgs.cpp
234
  PollDatabaseCmdLineArgsTest.cpp)
235
236
237

add_library (ctacataloguecmdlineunittests SHARED
  ${CATALOGUE_CMD_LINE_UNIT_TESTS_LIB_SRC_FILES})
Michael Davis's avatar
Michael Davis committed
238
239
240
set_property(TARGET ctacataloguecmdlineunittests PROPERTY SOVERSION "${CTA_SOVERSION}")
set_property(TARGET ctacataloguecmdlineunittests PROPERTY   VERSION "${CTA_LIBVERSION}")

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