xref: /5.5.2/tlm/deps/packages/CMakeLists.txt (revision 5cb731ee)
1# Project for building the third-party dependencies for Couchbase Server.
2#
3# Note that this project is not intended to be run as part of a
4# Couchbase Server build. It is included in the Couchbase Server
5# source code for reference (as these are the steps taken to produce
6# the pre-packaged dependencies which are downloaded as part of the
7# Couchbase Server build) as well as to make it easier to build
8# Couchbase Server on novel platforms.
9
10#
11# The following are the variables set by this script:
12# HOST_ARCH
13# PLATFORM
14
15PROJECT (cbdeps_packages)
16
17CMAKE_MINIMUM_REQUIRED (VERSION 2.8)
18
19LIST (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/../../cmake/Modules")
20INCLUDE (PlatformIntrospection)
21INCLUDE (CBDownloadDeps)
22
23_DETERMINE_PLATFORM (cbcache_platform)
24_DETERMINE_ARCH (cbcache_arch)
25
26MESSAGE (STATUS "Set platform to ${cbcache_platform} for dependency downloads")
27MESSAGE (STATUS "Set arch to ${cbcache_arch} for dependency downloads")
28
29# Generate a .md5 file
30MACRO (_ADD_MD5_FILE_STEP sourcefile md5file package)
31  ExternalProject_Add_Step (${package} md5
32    COMMAND "${CMAKE_COMMAND}"
33    -D "FILE=${sourcefile}"
34    -D "MD5FILE=${md5file}"
35    -P "${PROJECT_SOURCE_DIR}/util/GenMD5.cmake"
36    DEPENDEES package)
37ENDMACRO (_ADD_MD5_FILE_STEP)
38
39
40# Macro intended to be called by package sub-projects to provide
41# the ExternalPackage "package" step.
42MACRO (_ADD_PACKAGE_STEP)
43  ExternalProject_Add_Step(${_dep_package} package
44    COMMAND ${CMAKE_COMMAND} -E make_directory ${_output_dir}
45    COMMAND ${CMAKE_COMMAND} -E tar czf ${_output_file}.tgz .
46    COMMENT "Performing packaging step for '${_dep_package}' - writing artifacts to ${_output_dir}"
47    DEPENDEES install
48    WORKING_DIRECTORY <INSTALL_DIR>
49    )
50  _ADD_MD5_FILE_STEP(${_output_file}.tgz ${_output_file}.md5 ${_dep_package})
51
52  if (CB_DOWNLOAD_DEPS_CACHE)
53    SET(_cached_file "${CB_DOWNLOAD_DEPS_CACHE}/${_output_file_name}.tgz")
54    SET(_cached_md5 "${_cached_file}.md5")
55    SET(_target build-and-cache-${_dep_package})
56
57    _CHECK_CACHED_DEP_FILE("${_cached_file}" "${_cached_md5}" _dep_found)
58    if (_dep_found)
59      ADD_CUSTOM_TARGET(${_target}
60        COMMAND ${CMAKE_COMMAND} -E echo "Seems like you already have ${_cached_file}"
61        COMMAND ${CMAKE_COMMAND} -E echo "If that is not the case please regenerate cmake files"
62        COMMAND ${CMAKE_COMMAND} -E echo "If you want to rebuild the dependency, just delete the file")
63    else ()
64      ADD_CUSTOM_TARGET(${_target}
65        COMMAND ${CMAKE_COMMAND} -E copy "${_output_file}.tgz" "${_cached_file}"
66        COMMAND ${CMAKE_COMMAND} -E copy "${_output_file}.md5" "${_cached_md5}"
67        DEPENDS ${_dep_package})
68    endif ()
69
70    ADD_DEPENDENCIES(build-and-cache-all ${_target})
71  endif ()
72ENDMACRO (_ADD_PACKAGE_STEP)
73
74# Macro to standardize several steps in sub-projects.
75# Args:
76#   package - name of the third-party package. It is expected that a
77#     a subdirectory of the current directory exists with this name,
78#     containing a CMakeLists which defines an ExternalProject of
79#     the same name. The ExternalProject must have all steps up to
80#     and including "install" fully defined, and then call
81#     _ADD_PACKAGE_STEP() to complete the packaging.
82#   upstream_ver - the version of the upstream project to build. This
83#     is strictly a label; it will be used to determine the resulting
84#     cbdeps package name.
85#   cb_branch - all source will be retrieved from
86#      github.com/couchbasedeps/<package>. This parameter determines
87#      the branch / tag / SHA to check out.
88#   cb_release - a numeric index, which should be advanced whenever we
89#      need to re-package a given dependency while maintaining the same
90#      upstream_ver.
91# If the CMake variable 'PACKAGE' is defined but not equal to package,
92# this macro will do nothing. This allows incremental building of packages
93# on a new platform.
94#
95MACRO (_ADD_DEP_PACKAGE package upstream_ver cb_branch cb_release)
96  IF (NOT DEFINED PACKAGE OR "${PACKAGE}" STREQUAL "${package}")
97    SET (_output_file_name "${package}-${PLATFORM}-${HOST_ARCH}-${upstream_ver}-cb${cb_release}")
98    SET (_output_dir "${CMAKE_BINARY_DIR}/deps/${package}/${upstream_ver}-cb${cb_release}")
99    SET (_output_file "${_output_dir}/${_output_file_name}")
100    SET (_git_repo "git://github.com/couchbasedeps/${package}.git")
101    SET (_git_rev ${cb_branch})
102    SET (_dep_package ${package})
103    SET (_dep_version ${upstream_ver})
104    ADD_SUBDIRECTORY (${package})
105  ENDIF (NOT DEFINED PACKAGE OR "${PACKAGE}" STREQUAL "${package}")
106ENDMACRO (_ADD_DEP_PACKAGE)
107
108
109#
110# Standard code run on include to perform common checks and setup useful vars
111#
112_DETERMINE_ARCH(HOST_ARCH)
113_DETERMINE_PLATFORM(PLATFORM)
114
115#
116# Check for autotools stuff, as many of the deps require them.
117#
118IF (NOT WIN32)
119   FIND_PROGRAM(AUTOMAKE automake)
120   IF (NOT AUTOMAKE)
121      MESSAGE(WARNING "Building many packages requires automake")
122   ENDIF (NOT AUTOMAKE)
123   FIND_PROGRAM(AUTOCONF autoconf)
124   IF (NOT AUTOCONF)
125       MESSAGE(WARNING "Building many packages requires autoconf")
126   ENDIF (NOT AUTOCONF)
127   FIND_PROGRAM(LIBTOOLIZE libtoolize)
128   IF (NOT LIBTOOLIZE)
129       FIND_PROGRAM(GLIBTOOLIZE glibtoolize)
130       IF (GLIBTOOLIZE)
131           MESSAGE(FATAL_ERROR "No libtoolize found, but there is a glibtoolize. You should try to create a symbolic link")
132       ENDIF (GLIBTOOLIZE)
133       MESSAGE(WARNING "Building many packages requires libtoolize")
134   ENDIF (NOT LIBTOOLIZE)
135   FIND_PROGRAM(AUTORECONF autoreconf)
136   IF (NOT AUTORECONF)
137       MESSAGE(WARNING "Building many packages requires autoreconf")
138   ENDIF (NOT AUTORECONF)
139ENDIF (NOT WIN32)
140
141# msbuild uses a different names for architecture (compared to HOST_ARCH)
142if (WIN32)
143  if(HOST_ARCH STREQUAL "amd64")
144    SET(MSBUILD_ARCH "x64")
145  elseif(HOST_ARCH STREQUAL "x86")
146    SET(MSBUILD_ARCH "Win32")
147  else(HOST_ARCH STREQUAL "amd64")
148    SET(MSBUILD_ARCH ${HOST_ARCH})
149  endif(HOST_ARCH STREQUAL "amd64")
150endif(WIN32)
151
152ADD_CUSTOM_TARGET(build-and-cache-all)
153
154#
155# And here is the set of "latest" dependencies.
156#
157IF (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Windows")
158   _ADD_DEP_PACKAGE(breakpad 20160926 20160926-couchbase 2)
159ELSE (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Windows")
160   MESSAGE(STATUS "Skipping breakpad for ${CMAKE_SYSTEM_NAME}")
161ENDIF (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Windows")
162_ADD_DEP_PACKAGE(snappy 1.1.6 1.1.6 1)
163_ADD_DEP_PACKAGE(python-snappy c97d633 c97d633 2)
164_ADD_DEP_PACKAGE(icu4c 59.1 r59.1 1)
165_ADD_DEP_PACKAGE(libevent 2.1.8 release-2.1.8-stable-cb 4)
166_ADD_DEP_PACKAGE(v8 5.9 5.9.223 5)
167# jemalloc comes from "stable-4" branch, which is a bit later than their
168# 4.5.0 release, so we call it 4.5.0.1.
169_ADD_DEP_PACKAGE(jemalloc 4.5.0.1 stable-4 1)
170_ADD_DEP_PACKAGE(curl 7.49.1 curl-7_49_1 1)
171
172_ADD_DEP_PACKAGE(erlang OTP-20.3.2 OTP-20.3.2 3)
173
174_ADD_DEP_PACKAGE(libsqlite3 3.7.2 3.7.2 1)
175
176IF (PLATFORM STREQUAL "fedora26" OR PLATFORM STREQUAL "fedora27")
177  _ADD_DEP_PACKAGE(flatbuffers 1.7.1 v1.7.1 1)
178ELSE ()
179  _ADD_DEP_PACKAGE(flatbuffers 1.4.0 v1.4.0 1)
180ENDIF ()
181
182_ADD_DEP_PACKAGE(json 1.1.0 v1.1.0 1)
183_ADD_DEP_PACKAGE(boost 1.62.0 v1.62.0 3)
184IF (WIN32 OR APPLE)
185  # Note: we build libevent with support for SSL, so whenever
186  # OpenSSL is upgraded with an API breaking change we probably
187  # need to rebuild libevent as well.
188  _ADD_DEP_PACKAGE(openssl 1.0.2k OpenSSL_1_0_2k 2)
189ENDIF (WIN32 OR APPLE)
190_ADD_DEP_PACKAGE(libcouchbase 2.8.4 2.8.4 1)
191IF (CMAKE_SYSTEM_NAME STREQUAL "Linux")
192  IF (PLATFORM STREQUAL "fedora26" OR PLATFORM STREQUAL "fedora27")
193    _ADD_DEP_PACKAGE(libcxx 4.0.0 release_40 1)
194  ELSE ()
195    _ADD_DEP_PACKAGE(libcxx 3.9.1 release_39 2)
196  ENDIF ()
197ENDIF ()
198_ADD_DEP_PACKAGE(libuv 1.13.1 v1.13.1 4)
199IF (WIN32)
200  _ADD_DEP_PACKAGE(flex 2.5.4a master 1)
201ELSE ()
202  _ADD_DEP_PACKAGE(flex 2.6.4 master 4)
203ENDIF ()
204_ADD_DEP_PACKAGE(zlib 1.2.11 v1.2.11 3)
205_ADD_DEP_PACKAGE(numactl 2.0.11 v2.0.11 1)
206
207IF (NOT WIN32)
208    _ADD_DEP_PACKAGE(rocksdb 5.10.2 v5.10.2 1)
209ENDIF ()
210_ADD_DEP_PACKAGE(lz4 1.8.0 v1.8.0 2)
211# maven 3.5.2-cb3 and 3.5.2-cb4 exist as attempts to make Windows work,
212# but are not correct.
213_ADD_DEP_PACKAGE(maven 3.5.2 master 5)
214