CMakeLists.txt 9.26 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
30
  ChecksumTypeMismatch.cpp
  ChecksumValueMismatch.cpp
31
  CmdLineTool.cpp
32
  FileSizeMismatch.cpp
33
  InMemoryCatalogue.cpp
34
  OracleCatalogue.cpp
35
  SqliteCatalogueSchema.cpp
36
  TapeFileWritten.cpp
37
  TapeItemImplementation.cpp
38
  TapePool.cpp
39
  RdbmsArchiveFileItorImpl.cpp
40
  RdbmsCatalogue.cpp
41
  SchemaCreatingSqliteCatalogue.cpp
42
  SqliteCatalogue.cpp
Tao Lin's avatar
Tao Lin committed
43
44
  MysqlCatalogue.cpp
  MysqlCatalogueSchema.cpp
45
46
  TapeForWriting.cpp
  UserSpecifiedANonEmptyTape.cpp
47
48
  UserSpecifiedANonExistentTape.cpp
  UserSpecifiedAnEmptyStringComment.cpp
49
  UserSpecifiedAnEmptyStringDiskInstanceName.cpp
50
  UserSpecifiedAnEmptyStringLogicalLibraryName.cpp
51
  UserSpecifiedAnEmptyStringStorageClassName.cpp
52
  UserSpecifiedAnEmptyStringTapePoolName.cpp
53
  UserSpecifiedAnEmptyStringUsername.cpp
54
55
  UserSpecifiedAnEmptyStringVid.cpp
  UserSpecifiedAnEmptyStringVo.cpp
56
57
  UserSpecifiedAZeroCapacity.cpp
  UserSpecifiedAZeroCopyNb.cpp)
58

59
add_library (ctacatalogue SHARED
Michael Davis's avatar
Michael Davis committed
60
61
62
   ${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
63

64
set_property (TARGET ctacatalogue APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH})
65

66
67
install (TARGETS ctacatalogue DESTINATION usr/${CMAKE_INSTALL_LIBDIR})

68
target_link_libraries (ctacatalogue
69
  ctacommon
70
  ctardbms)
71

Tao Lin's avatar
Tao Lin committed
72
add_custom_command (OUTPUT sqlite_catalogue_schema.sql mysql_catalogue_schema.sql oracle_catalogue_schema.sql
73
74
75
76
77
  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
    > sqlite_catalogue_schema.sql
Tao Lin's avatar
Tao Lin committed
78
79
80
81
82
  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
83
84
85
86
87
88
  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
89
  DEPENDS
90
    ${CMAKE_CURRENT_SOURCE_DIR}/common_catalogue_schema.sql
91
92
    ${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
93
94
    ${CMAKE_CURRENT_SOURCE_DIR}/mysql_catalogue_schema_header.sql
    ${CMAKE_CURRENT_SOURCE_DIR}/mysql_catalogue_schema_trailer.sql
95
96
    ${CMAKE_CURRENT_SOURCE_DIR}/oracle_catalogue_schema_header.sql
    ${CMAKE_CURRENT_SOURCE_DIR}/oracle_catalogue_schema_trailer.sql)
97

98
99
add_custom_command(OUTPUT sqlite_catalogue_schema.cpp
  COMMAND sed 's/^/\ \ \"/' sqlite_catalogue_schema.sql | sed 's/$$/\"/' > sqlite_catalogue_schema.cpp
100
  DEPENDS sqlite_catalogue_schema.sql)
101

102
103
104
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)
105

Tao Lin's avatar
Tao Lin committed
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# 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)


121
set(IN_MEMORY_CATALOGUE_UNIT_TESTS_LIB_SRC_FILES
122
  CatalogueTest.cpp
123
  CatalogueFactoryTest.cpp
Steven Murray's avatar
Steven Murray committed
124
  InMemoryCatalogueTest.cpp
125
  InMemoryVersionOfCatalogueTest.cpp)
126

127
128
add_library (ctainmemorycatalogueunittests SHARED
  ${IN_MEMORY_CATALOGUE_UNIT_TESTS_LIB_SRC_FILES})
Michael Davis's avatar
Michael Davis committed
129
130
set_property(TARGET ctainmemorycatalogueunittests PROPERTY SOVERSION "${CTA_SOVERSION}")
set_property(TARGET ctainmemorycatalogueunittests PROPERTY   VERSION "${CTA_LIBVERSION}")
Steven Murray's avatar
Steven Murray committed
131

132
target_link_libraries (ctainmemorycatalogueunittests
133
  ctacatalogue)
134

135
install (TARGETS ctainmemorycatalogueunittests DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
136

137
set (CATALOGUE_UNIT_TESTS_LIB_SRC_FILES
138
  CatalogueTest.cpp
139
  DbConfigVersionOfCatalogueTest.cpp)
140

141
142
add_library (ctacatalogueunittests SHARED
  ${CATALOGUE_UNIT_TESTS_LIB_SRC_FILES})
Michael Davis's avatar
Michael Davis committed
143
144
set_property(TARGET ctacatalogueunittests PROPERTY SOVERSION "${CTA_SOVERSION}")
set_property(TARGET ctacatalogueunittests PROPERTY   VERSION "${CTA_LIBVERSION}")
145

146
target_link_libraries (ctacatalogueunittests
147
148
  ctacatalogue)

149
install (TARGETS ctacatalogueunittests DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
150

151
install (FILES cta-catalogue.conf.example
152
153
  DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/cta
  PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
154

155
156
157
158
159
160
161
162
163
164
165
166
167
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
168
169
  SqliteCatalogueSchema.cpp
  MysqlCatalogueSchema.cpp)
170
171
172
173

target_link_libraries (cta-catalogue-schema-create
  ctacatalogue)

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

176
177
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)
178
179
180
181

add_executable(cta-catalogue-schema-drop
  DropSchemaCmd.cpp
  DropSchemaCmdLineArgs.cpp
182
  DropSchemaCmdMain.cpp)
183
184
185
186

target_link_libraries (cta-catalogue-schema-drop
  ctacatalogue)

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

189
190
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)
191
192
193
194
195
196
197
198
199

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

target_link_libraries (cta-database-poll
  ctacatalogue)

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

202
203
install (TARGETS cta-database-poll DESTINATION /usr/bin)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cta-database-poll.1cta DESTINATION /usr/share/man/man1)
204
205
206
207
208
209
210
211
212

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

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

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

215
216
217
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)

218
set (CATALOGUE_CMD_LINE_UNIT_TESTS_LIB_SRC_FILES
219
  CreateAdminUserCmdLineArgs.cpp
220
221
  CreateAdminUserCmdLineArgsTest.cpp
  CreateSchemaCmdLineArgs.cpp
222
223
  CreateSchemaCmdLineArgsTest.cpp
  DropSchemaCmdLineArgs.cpp
224
  DropSchemaCmdLineArgsTest.cpp
225
  PollDatabaseCmdLineArgs.cpp
226
  PollDatabaseCmdLineArgsTest.cpp)
227
228
229

add_library (ctacataloguecmdlineunittests SHARED
  ${CATALOGUE_CMD_LINE_UNIT_TESTS_LIB_SRC_FILES})
Michael Davis's avatar
Michael Davis committed
230
231
232
set_property(TARGET ctacataloguecmdlineunittests PROPERTY SOVERSION "${CTA_SOVERSION}")
set_property(TARGET ctacataloguecmdlineunittests PROPERTY   VERSION "${CTA_LIBVERSION}")

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