1# Copyright (c) 2011, Codership Oy <info@codership.com>.
2# Copyright (c) 2013, Monty Program Ab.
3#
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; version 2 of the License.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1335  USA
16
17#
18# Galera library does not compile with windows
19#
20IF (NOT WITHOUT_SERVER)
21IF(UNIX)
22  SET(with_wsrep_default ON)
23ELSE()
24  SET(with_wsrep_default OFF)
25ENDIF()
26
27OPTION(WITH_WSREP "WSREP replication API (to use, e.g. Galera Replication library)" ${with_wsrep_default})
28OPTION(WITH_WSREP_ALL
29  "Build all components of WSREP (unit tests, sample programs)"
30  OFF)
31
32IF(WITH_WSREP)
33  # Set the patch version
34  SET(WSREP_PATCH_VERSION "22")
35
36  IF(NOT EXISTS "${CMAKE_SOURCE_DIR}/wsrep-lib/wsrep-API/v26/wsrep_api.h")
37    MESSAGE(FATAL_ERROR "No MariaDB wsrep-API code! Run
38    ${GIT_EXECUTABLE} submodule update --init --recursive
39Then restart the build.
40")
41  ENDIF()
42  # Obtain wsrep API version
43  FILE(STRINGS "${CMAKE_SOURCE_DIR}/wsrep-lib/wsrep-API/v26/wsrep_api.h" WSREP_API_VERSION
44       LIMIT_COUNT 1 REGEX "WSREP_INTERFACE_VERSION")
45  STRING(REGEX MATCH "([0-9]+)" WSREP_API_VERSION "${WSREP_API_VERSION}")
46
47  SET(WSREP_VERSION "${WSREP_API_VERSION}.${WSREP_PATCH_VERSION}"
48      CACHE INTERNAL "WSREP version")
49
50  SET(WSREP_PROC_INFO ${WITH_WSREP})
51
52  SET(WSREP_PATCH_VERSION "wsrep_${WSREP_VERSION}")
53  if (NOT WITH_WSREP_ALL)
54    SET(WSREP_LIB_WITH_UNIT_TESTS OFF CACHE BOOL
55      "Disable unit tests for wsrep-lib")
56    SET(WSREP_LIB_WITH_DBSIM OFF CACHE BOOL
57      "Disable building dbsim for wsrep-lib")
58  endif()
59  INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/wsrep-lib/include)
60  INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/wsrep-lib/wsrep-API/v26)
61
62  SET(old_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
63  SET(BUILD_SHARED_LIBS OFF)
64  ADD_SUBDIRECTORY(wsrep-lib)
65  SET(BUILD_SHARED_LIBS ${old_BUILD_SHARED_LIBS})
66ENDIF()
67IF (NOT WIN32)
68  ADD_FEATURE_INFO(WSREP WITH_WSREP "WSREP replication API (to use, e.g. Galera Replication library)")
69ENDIF()
70ENDIF(NOT WITHOUT_SERVER)
71