comparison Resources/CMake/MariaDBConfiguration.cmake @ 0:7cea966b6829

initial commit
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 04 Jul 2018 08:16:29 +0200
parents
children a84b487ccbdc
comparison
equal deleted inserted replaced
-1:000000000000 0:7cea966b6829
1 # Orthanc - A Lightweight, RESTful DICOM Store
2 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
3 # Department, University Hospital of Liege, Belgium
4 # Copyright (C) 2017-2018 Osimis S.A., Belgium
5 #
6 # This program is free software: you can redistribute it and/or
7 # modify it under the terms of the GNU Affero General Public License
8 # as published by the Free Software Foundation, either version 3 of
9 # the License, or (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Affero General Public License for more details.
15 #
16 # You should have received a copy of the GNU Affero General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19
20 if (STATIC_BUILD OR NOT USE_SYSTEM_MYSQL_CLIENT)
21 set(MARIADB_CLIENT_VERSION_MAJOR "10")
22 set(MARIADB_CLIENT_VERSION_MINOR "3")
23 set(MARIADB_CLIENT_VERSION_PATCH "6")
24 set(MARIADB_PACKAGE_VERSION "3.0.5")
25 set(MARIADB_CLIENT_SOURCES_DIR ${CMAKE_BINARY_DIR}/mariadb-connector-c-${MARIADB_PACKAGE_VERSION}-src)
26 set(MARIADB_CLIENT_MD5 "b846584b8b7a39c51a6e83986b57c71c")
27 set(MARIADB_CLIENT_URL "http://www.orthanc-server.com/downloads/third-party/mariadb-connector-c-${MARIADB_PACKAGE_VERSION}-src.tar.gz")
28
29 if (IS_DIRECTORY "${MARIADB_CLIENT_SOURCES_DIR}")
30 set(FirstRun OFF)
31 else()
32 set(FirstRun ON)
33 endif()
34
35 DownloadPackage(${MARIADB_CLIENT_MD5} ${MARIADB_CLIENT_URL} "${MARIADB_CLIENT_SOURCES_DIR}")
36
37 if (FirstRun)
38 execute_process(
39 COMMAND ${PATCH_EXECUTABLE} -p0 -N -i
40 ${CMAKE_CURRENT_LIST_DIR}/../MariaDB/mariadb-connector-c-3.0.5.patch
41 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
42 RESULT_VARIABLE Failure
43 )
44
45 if (Failure)
46 message(FATAL_ERROR "Error while patching a file")
47 endif()
48 endif()
49
50
51 include(${MARIADB_CLIENT_SOURCES_DIR}/cmake/CheckIncludeFiles.cmake)
52 include(${MARIADB_CLIENT_SOURCES_DIR}/cmake/CheckFunctions.cmake)
53 include(${MARIADB_CLIENT_SOURCES_DIR}/cmake/CheckTypes.cmake)
54
55 set(MARIADB_CLIENT_VERSION "${MARIADB_CLIENT_VERSION_MAJOR}.${MARIADB_CLIENT_VERSION_MINOR}.${MARIADB_CLIENT_VERSION_PATCH}")
56 set(MARIADB_BASE_VERSION "mariadb-${MARIADB_CLIENT_VERSION_MAJOR}.${MARIADB_CLIENT_VERSION_MINOR}")
57 math(EXPR MARIADB_VERSION_ID "${MARIADB_CLIENT_VERSION_MAJOR} * 10000 +
58 ${MARIADB_CLIENT_VERSION_MINOR} * 100 +
59 ${MARIADB_CLIENT_VERSION_PATCH}")
60
61 add_definitions(
62 -DHAVE_OPENSSL=1
63 -DHAVE_TLS=1
64 -DHAVE_REMOTEIO=1
65 -DHAVE_COMPRESS=1
66 -DLIBMARIADB
67 -DTHREAD
68 )
69
70 set(HAVE_DLOPEN 1)
71 set(PROTOCOL_VERSION ${MARIADB_CLIENT_VERSION_MAJOR})
72 set(MARIADB_PORT 3306)
73 set(MARIADB_UNIX_ADDR "/var/run/mysqld/mysqld.sock")
74 set(DEFAULT_CHARSET "latin1")
75
76 FOREACH(plugin mysql_native_password mysql_old_password pvio_socket)
77 set(EXTERNAL_PLUGINS "${EXTERNAL_PLUGINS} extern struct st_mysql_client_plugin ${plugin}_client_plugin;\n")
78 set(BUILTIN_PLUGINS "${BUILTIN_PLUGINS} (struct st_mysql_client_plugin *)&${plugin}_client_plugin,\n")
79 ENDFOREACH()
80
81 configure_file(
82 ${MARIADB_CLIENT_SOURCES_DIR}/include/ma_config.h.in
83 ${MARIADB_CLIENT_SOURCES_DIR}/include/ma_config.h
84 )
85
86 configure_file(
87 ${MARIADB_CLIENT_SOURCES_DIR}/include/mariadb_version.h.in
88 ${MARIADB_CLIENT_SOURCES_DIR}/include/mariadb_version.h
89 )
90
91 configure_file(
92 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_client_plugin.c.in
93 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_client_plugin.c
94 )
95
96 include_directories(
97 ${MARIADB_CLIENT_SOURCES_DIR}/include
98 )
99
100 set(MYSQL_CLIENT_SOURCES
101 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_alloc.c
102 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_array.c
103 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_charset.c
104 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_client_plugin.c
105 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_compress.c
106 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_context.c
107 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_default.c
108 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_dtoa.c
109 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_errmsg.c
110 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_hash.c
111 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_init.c
112 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_io.c
113 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_list.c
114 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_ll2str.c
115 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_loaddata.c
116 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_net.c
117 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_password.c
118 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_pvio.c
119 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_sha1.c
120 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_stmt_codec.c
121 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_string.c
122 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_time.c
123 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/ma_tls.c
124 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/mariadb_async.c
125 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/mariadb_charset.c
126 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/mariadb_dyncol.c
127 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/mariadb_lib.c
128 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/mariadb_stmt.c
129 ${MARIADB_CLIENT_SOURCES_DIR}/libmariadb/secure/openssl.c
130 ${MARIADB_CLIENT_SOURCES_DIR}/plugins/auth/my_auth.c
131 ${MARIADB_CLIENT_SOURCES_DIR}/plugins/auth/old_password.c
132 ${MARIADB_CLIENT_SOURCES_DIR}/plugins/pvio/pvio_socket.c
133 )
134
135 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
136 link_libraries(shlwapi)
137 endif()
138
139 else()
140 find_path(MYSQLCLIENT_INCLUDE_DIR mysql.h
141 /usr/local/include/mysql
142 /usr/include/mysql
143 )
144
145 if (MYSQLCLIENT_INCLUDE_DIR)
146 include_directories(${MYSQLCLIENT_INCLUDE_DIR})
147 set(CMAKE_REQUIRED_INCLUDES "${MYSQLCLIENT_INCLUDE_DIR}")
148 endif()
149
150 check_include_file(mysql.h HAVE_MYSQL_CLIENT_H)
151 if (NOT HAVE_MYSQL_CLIENT_H)
152 message(FATAL_ERROR "Please install the libmysqlclient-dev package")
153 endif()
154
155 check_library_exists(mysqlclient mysql_init "" HAVE_MYSQL_CLIENT_LIB)
156 if (NOT HAVE_MYSQL_CLIENT_LIB)
157 message(FATAL_ERROR "Unable to find the mysqlclient library")
158 endif()
159
160 link_libraries(mysqlclient)
161 endif()