1#
2# This is the toplevel CMakeLists.txt that is used to build Couchbase
3#
4CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
5PROJECT("Couchbase")
6
7# RPATH is more or less "broken" on MacOSX in cmake < 3.x
8IF (APPLE)
9   IF (${CMAKE_MAJOR_VERSION} LESS 3)
10      MESSAGE(STATUS "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
11      MESSAGE(STATUS "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
12      MESSAGE(STATUS "@@@ The version of cmake you're using  @@@")
13      MESSAGE(STATUS "@@@ does not properly handle $RPATH    @@@")
14      MESSAGE(STATUS "@@@ RPATH for macosx was introduced in @@@")
15      MESSAGE(STATUS "@@@ cmake 3.0.0                        @@@")
16      MESSAGE(STATUS "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
17      MESSAGE(STATUS "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
18      MESSAGE(FATAL_ERROR "Please upgrade cmake")
19   ENDIF (${CMAKE_MAJOR_VERSION} LESS 3)
20ENDIF(APPLE)
21
22IF (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
23  SET(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/install" CACHE STRING
24      "The install location" FORCE)
25  LIST(APPEND CMAKE_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}")
26ENDIF (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
27
28SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/tlm/cmake/Modules/")
29SET(COUCHBASE_SERVER_BUILD True CACHE BOOL "Indicating this is a server build")
30
31# Try to download the prebuilt 3rd-party dependencies by default
32IF (NOT DEFINED CB_DOWNLOAD_DEPS)
33   SET(CB_DOWNLOAD_DEPS True
34       CACHE BOOL "Download prebuilt dependencies by default")
35ENDIF (NOT DEFINED CB_DOWNLOAD_DEPS)
36
37# Have to add deps first, before any other part of the build tries to
38# FIND anything
39ADD_SUBDIRECTORY(tlm/deps)
40
41INCLUDE(CouchbaseDefaultValues)
42
43IF ("" STREQUAL "${BUILD_ENTERPRISE}")
44   SET(CB_BUILD_TYPE "Community Edition")
45ELSE ("" STREQUAL "${BUILD_ENTERPRISE}")
46   SET(CB_BUILD_TYPE "Enterprise Edition")
47ENDIF ("" STREQUAL "${BUILD_ENTERPRISE}")
48
49MESSAGE(STATUS "Using cmake version: ${CMAKE_VERSION}")
50MESSAGE(STATUS "Installing to ${CMAKE_INSTALL_PREFIX}")
51MESSAGE(STATUS "Build type: ${CMAKE_BUILD_TYPE} (${CB_BUILD_TYPE})")
52
53INCLUDE(CouchbaseMemoryAllocator)
54
55INCLUDE(FindCouchbaseOpenSSL)
56INCLUDE(FindCouchbaseLibevent)
57INCLUDE(FindCouchbaseCurl)
58INCLUDE(FindCouchbaseIcu)
59INCLUDE(FindCouchbaseSnappy)
60INCLUDE(FindCouchbaseV8)
61INCLUDE(FindCouchbaseLua)
62INCLUDE(FindCouchbasePythonInterp)
63INCLUDE(FindCouchbaseErlang)
64INCLUDE(FindCouchbaseDtrace)
65INCLUDE(FindCouchbaseGo)
66INCLUDE(FindCouchbaseBreakpad)
67
68IF (WIN32)
69   SET(COUCHBASE_NETWORK_LIBS "Ws2_32")
70ELSEIF ("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
71   SET(COUCHBASE_NETWORK_LIBS socket nsl)
72ENDIF (WIN32)
73MESSAGE(STATUS "Linking with network libraries: ${COUCHBASE_NETWORK_LIBS}")
74
75IF (NOT WIN32)
76   SET(COUCHBASE_MATH_LIBS m)
77ENDIF(NOT WIN32)
78
79INCLUDE(CouchbaseCompilerOptions)
80INCLUDE(CouchbaseCodeCoverage)
81
82ENABLE_TESTING()
83# When performing memory checking with ctest we need to include the CTest
84# module to ensure CMake variables to define the memory checker
85# (e.g. MEMORYCHECK_COMMAND) are propogated to CTest.
86INCLUDE(CTest)
87
88
89INCLUDE_DIRECTORIES(BEFORE ${CMAKE_BINARY_DIR}/platform/include)
90
91# Add a quick (and safe) way to nuke everything
92ADD_CUSTOM_TARGET(reset
93                  COMMAND repo forall -c "git clean -dfx"
94                  VERBATIM)
95
96ADD_SUBDIRECTORY(platform)
97ADD_SUBDIRECTORY(memcached)
98ADD_SUBDIRECTORY(couchstore)
99ADD_SUBDIRECTORY(ep-engine)
100ADD_SUBDIRECTORY(couchbase-cli)
101ADD_SUBDIRECTORY(couchbase-examples)
102ADD_SUBDIRECTORY(couchbase-python-client)
103ADD_SUBDIRECTORY(sigar)
104ADD_SUBDIRECTORY(moxi)
105ADD_SUBDIRECTORY(couchdb)
106ADD_SUBDIRECTORY(geocouch)
107ADD_SUBDIRECTORY(ns_server ${CMAKE_CURRENT_SOURCE_DIR}/ns_server/build)
108ADD_SUBDIRECTORY(forestdb)
109
110SET (GODEPSDIR "${CMAKE_CURRENT_SOURCE_DIR}/godeps")
111ADD_SUBDIRECTORY(goproj/src/github.com/couchbase/query)
112
113SET (FORESTDB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/forestdb/include")
114GET_PROPERTY (_dir TARGET forestdb PROPERTY LOCATION)
115GET_FILENAME_COMPONENT (FORESTDB_LIBRARY_DIR "${_dir}" PATH)
116SET (FORESTDB_TARGET forestdb)
117ADD_SUBDIRECTORY(goproj/src/github.com/couchbase/indexing)
118ADD_SUBDIRECTORY(goproj/src/github.com/couchbase/goxdcr)
119ADD_SUBDIRECTORY(goproj/src/github.com/couchbase/gometa)
120ADD_SUBDIRECTORY(godeps/src/github.com/couchbase/cbauth)
121