1# -*- mode: cmake; cmake-tab-width: 4; indent-tabs-mode: nil -*-
2#
3# libcouchbase
4# Copyright (C) 2013 Couchbase, Inc
5# All rights reserved.
6#
7#   Licensed under the Apache License, Version 2.0 (the "License");
8#   you may not use this file except in compliance with the License.
9#   You may obtain a copy of the License at
10#
11#       http://www.apache.org/licenses/LICENSE-2.0
12#
13#   Unless required by applicable law or agreed to in writing, software
14#   distributed under the License is distributed on an "AS IS" BASIS,
15#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16#   See the License for the specific language governing permissions and
17#   limitations under the License.
18
19CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
20
21### BEGIN CONFIGURABLES ###
22# These variables can be modified as needed
23
24# Couchbase mock path to download
25SET(COUCHBASE_MOCK_VERSION 1.5.25)
26SET(COUCHBASE_MOCK_URL "https://github.com/couchbase/CouchbaseMock/releases/download/${COUCHBASE_MOCK_VERSION}/CouchbaseMock-${COUCHBASE_MOCK_VERSION}.jar")
27project(libcouchbase)
28
29if (NOT CMAKE_VERSION VERSION_LESS "3.13")
30    # CMP0077: option() honors normal variables
31    # https://cmake.org/cmake/help/latest/policy/CMP0077.html
32    cmake_policy(SET CMP0077 NEW)
33endif()
34
35OPTION(LCB_NO_TESTS "Disable building of tests" OFF)
36OPTION(LCB_NO_TOOLS "Disable building of additional tools" OFF)
37OPTION(LCB_NO_PLUGINS "Disable the building of IO plugins for external libs" OFF)
38OPTION(LCB_BUILD_LIBEVENT "Build the libevent plugin" ON)
39OPTION(LCB_BUILD_LIBEV "Build the libev plugin (if available)" ON)
40OPTION(LCB_BUILD_LIBUV "Build the libuv plugin (if available)" ON)
41OPTION(LCB_MAINTAINER_MODE "Enables maintainer mode" OFF)
42OPTION(LCB_NO_SSL "Do not compile SSL support" OFF)
43OPTION(LCB_USE_ASAN "Use AddressSanitizer support (Requires Clang)" OFF)
44OPTION(LCB_USE_COVERAGE "Build with code coverage support" OFF)
45OPTION(LCB_USE_ARCHLIBDIR "Use architecture-prefixed library installation directory, if possible" OFF)
46OPTION(LCB_BUILD_EXAMPLES "Build example applications" OFF)
47OPTION(LCB_NO_MOCK "Don't run tests which depend on the mock" OFF)
48OPTION(LCB_BUILD_DTRACE "Build DTrace instrumentation, if available on platform" ON)
49OPTION(LCB_EMBED_PLUGIN_LIBEVENT "Embed the libevent plugin" OFF)
50OPTION(LCB_STATIC_LIBEVENT "Link static libevent (only applicable if EMBED_PLUGIN_LIBEVENT is ON" OFF)
51OPTION(LCB_USE_HDR_HISTOGRAM "Use HdrHistogram for statistics recording" OFF)
52OPTION(LCB_INSTALL_HEADERS "Install header files" ON)
53OPTION(LCB_INSTALL_PKGCONFIG "Install pkgconfig/libcouchbase.pc" ON)
54OPTION(LCB_DUMP_PACKETS "Enable dumping network packets on TRACE log level" OFF)
55OPTION(LCB_USE_PROFILER "Build with profiler support (from gperftools)" OFF)
56OPTION(LCB_SKIP_GIT_VERSION "Skip version detection using git" OFF)
57
58STRING(TIMESTAMP LCB_BUILD_TIMESTAMP "%Y-%m-%d %H:%M:%S" UTC)
59
60### END CONFIGURABLES ###
61IF(MSVC)
62    SET(CMAKE_DEBUG_POSTFIX "_d")
63ELSE()
64    IF(APPLE)
65        SET(CMAKE_MACOSX_RPATH ON)
66    ENDIF()
67    SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
68    SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
69    LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
70    IF("${isSystemDir}" STREQUAL "-1")
71        SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
72    ENDIF("${isSystemDir}" STREQUAL "-1")
73ENDIF()
74
75# If building from a configured autotools tree, bail.
76IF(EXISTS ${PROJECT_SOURCE_DIR}/src/config.h)
77    MESSAGE(FATAL_ERROR "config.h found in src/. This will break the CMake build. Remove it manually then rerun")
78ENDIF()
79
80SET(LCB_GENSRCDIR ${PROJECT_BINARY_DIR}/generated)
81INCLUDE_DIRECTORIES(${LCB_GENSRCDIR})
82SET(LCB_GENINFODIR ${PROJECT_SOURCE_DIR}/packaging/distinfo)
83
84INCLUDE(cmake/Modules/GetLibcouchbaseFlags.cmake)
85INCLUDE(cmake/Modules/FindCouchbaseLibevent.cmake)
86IF (LCB_BUILD_LIBEV)
87    INCLUDE(cmake/Modules/FindCouchbaseLibev.cmake)
88ENDIF()
89IF (LCB_BUILD_LIBUV)
90    INCLUDE(cmake/Modules/FindCouchbaseLibuv.cmake)
91ENDIF()
92INCLUDE(cmake/Modules/GetPlatformCCInfo.cmake)
93INCLUDE(cmake/Modules/GetVersionInfo.cmake)
94IF (MSVC)
95    INCLUDE(cmake/Modules/CopyPDB.cmake)
96ENDIF ()
97INCLUDE(cmake/Modules/DownloadLcbDep.cmake)
98INCLUDE(CheckIncludeFiles)
99INCLUDE(cmake/source_files.cmake)
100
101IF(LCB_USE_PROFILER)
102    INCLUDE(cmake/Modules/FindProfiler.cmake)
103ENDIF()
104IF(LCB_USE_HDR_HISTOGRAM)
105    INCLUDE(cmake/Modules/FindCouchbaseHdrHistogram.cmake)
106ENDIF()
107IF(HDR_HISTOGRAM_FOUND)
108    INCLUDE_DIRECTORIES(${HDR_HISTOGRAM_INCLUDES})
109    SET(LCB_HDR_HISTOGRAM_LINK "${HDR_HISTOGRAM_LIBRARIES}")
110    LIST(APPEND LCB_CORE_SRC "src/hdr_timings.c")
111ELSE()
112    SET(LCB_HDR_HISTOGRAM_LINK "")
113    LIST(APPEND LCB_CORE_SRC "src/timings.c")
114ENDIF()
115
116IF(LIB_INSTALL_DIR)
117    SET(CMAKE_INSTALL_LIBDIR "${LIB_INSTALL_DIR}")
118ENDIF()
119IF(NOT LCB_USE_ARCHLIBDIR AND NOT CMAKE_INSTALL_LIBDIR)
120    SET(CMAKE_INSTALL_LIBDIR "lib")
121ENDIF()
122INCLUDE(GNUInstallDirs)
123
124
125SET(CPACK_PACKAGE_VERSION_MAJOR "${LCB_VERSION_MAJOR}")
126SET(CPACK_PACKAGE_VERSION_MINOR "${LCB_VERSION_MINOR}")
127SET(CPACK_PACKAGE_VERSION_PATCH "${LCB_VERSION_PATCH}")
128IF(NOT CMAKE_BUILD_TYPE)
129    SET(CPACK_INSTALL_SCRIPT
130        "${PROJECT_SOURCE_DIR}/cmake/Modules/DistScript.cmake")
131ENDIF()
132SET(lcb_package_name "libcouchbase-${LCB_VERSION}_${LCB_CC_STRING}_${LCB_ARCH_STRING}")
133SET(CPACK_PACKAGE_FILE_NAME ${lcb_package_name})
134
135IF(WIN32)
136    SET(CPACK_GENERATOR "ZIP")
137ELSE()
138    SET(CPACK_GENERATOR "TGZ")
139ENDIF()
140
141INCLUDE(CPack)
142
143CONFIGURE_FILE(
144    ${PROJECT_SOURCE_DIR}/include/libcouchbase/configuration.h.in
145    ${LCB_GENSRCDIR}/libcouchbase/configuration.h
146    @ONLY)
147
148CONFIGURE_FILE(
149    ${PROJECT_SOURCE_DIR}/cmake/defs.mk.in
150    ${PROJECT_BINARY_DIR}/defs.mk)
151
152CONFIGURE_FILE(
153    ${PROJECT_SOURCE_DIR}/packaging/dllversion.rc.in
154    ${PROJECT_BINARY_DIR}/dllversion.rc)
155
156SET(NT_REQUIRED_VERSION 0x0600)
157
158ADD_DEFINITIONS(-DLIBCOUCHBASE_INTERNAL=1)
159
160SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
161SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
162IF(WIN32)
163    SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
164ELSE()
165    SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
166ENDIF()
167
168SET(SOURCE_ROOT ${PROJECT_SOURCE_DIR})
169
170IF(WIN32)
171    ADD_DEFINITIONS(-DWINVER=${NT_REQUIRED_VERSION})
172    ADD_DEFINITIONS(-D_WIN32_WINNT=${NT_REQUIRED_VERSION})
173    SET(lcb_plat_includes "${SOURCE_ROOT}/contrib/win32-defs")
174    SET(lcb_plat_libs ws2_32.lib dnsapi.lib)
175    SET(lcb_plat_objs $<TARGET_OBJECTS:couchbase_iocp>)
176ELSE()
177    SET(lcb_plat_libs m)
178    IF(NOT CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
179        SET(lcb_plat_libs ${lcb_plat_libs} dl resolv)
180    ELSE()
181        # BSD _and_ DTrace
182        IF(LCB_BUILD_DTRACE)
183            SET(lcb_plat_libs ${lcb_plat_libs} elf)
184        ENDIF()
185    ENDIF()
186    IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
187        SET(lcb_plat_libs ${lcb_plat_libs} nsl socket)
188    ENDIF()
189    IF(LCB_EMBED_PLUGIN_LIBEVENT)
190        SET(lcb_plat_objs ${lcb_plat_objs} $<TARGET_OBJECTS:couchbase_libevent>)
191        SET(lcb_plat_libs ${lcb_plat_libs} ${LIBEVENT_LIBRARIES})
192        ADD_DEFINITIONS(-DLCB_EMBED_PLUGIN_LIBEVENT)
193    ENDIF()
194ENDIF()
195
196INCLUDE_DIRECTORIES(BEFORE ${SOURCE_ROOT}/include
197                           ${SOURCE_ROOT}/contrib
198                           ${SOURCE_ROOT}/contrib/cbsasl/include
199                           ${SOURCE_ROOT}/src
200                           ${lcb_plat_includes}
201                           ${SOURCE_ROOT})
202
203# These files are bundled in a static library.
204# They export no symbols of their own and may
205# be considered as 'static'
206
207ADD_LIBRARY(couchbase_utils OBJECT ${LCB_UTILS_SRC})
208
209MACRO(LCB_UTIL tgt)
210    SET_TARGET_PROPERTIES(${tgt}
211        PROPERTIES
212        COMPILE_FLAGS "${LCB_CORE_CFLAGS}"
213        POSITION_INDEPENDENT_CODE TRUE)
214ENDMACRO()
215
216MACRO(LCB_CXXUTIL tgt)
217    SET_TARGET_PROPERTIES(${tgt}
218        PROPERTIES
219        COMPILE_FLAGS "${LCB_CORE_CXXFLAGS}"
220        POSITION_INDEPENDENT_CODE TRUE)
221ENDMACRO()
222
223ADD_LIBRARY(netbuf OBJECT ${LCB_NETBUF_SRC})
224ADD_LIBRARY(netbuf-malloc OBJECT ${LCB_NETBUF_SRC})
225ADD_LIBRARY(mcreq OBJECT ${LCB_MC_SRC})
226ADD_LIBRARY(mcreq-cxx OBJECT ${LCB_MC_CXXSRC})
227ADD_LIBRARY(rdb OBJECT ${LCB_RDB_SRC})
228ADD_LIBRARY(lcbio OBJECT ${LCB_IO_SRC})
229ADD_LIBRARY(lcbio-cxx OBJECT ${LCB_IO_CXXSRC})
230ADD_LIBRARY(lcbht OBJECT ${LCB_HT_SRC})
231ADD_LIBRARY(lcbcore OBJECT ${LCB_CORE_SRC})
232ADD_LIBRARY(lcbcore-cxx OBJECT ${LCB_CORE_CXXSRC})
233
234SET_TARGET_PROPERTIES(netbuf-malloc PROPERTIES COMPILE_DEFINITIONS NETBUF_LIBC_PROXY=1)
235LCB_UTIL(netbuf-malloc)
236LCB_UTIL(netbuf)
237LCB_UTIL(rdb)
238LCB_UTIL(lcbio)
239LCB_CXXUTIL(lcbio-cxx)
240LCB_UTIL(couchbase_utils)
241LCB_UTIL(mcreq)
242LCB_CXXUTIL(mcreq-cxx)
243LCB_UTIL(lcbht)
244LCB_UTIL(lcbcore)
245LCB_CXXUTIL(lcbcore-cxx)
246
247IF(LCB_NO_SSL)
248    MESSAGE(STATUS "SSL support will be disabled")
249    ADD_DEFINITIONS(-DLCB_NO_SSL=1)
250ELSE()
251    IF(NOT OPENSSL_FOUND)
252        # When building under Couchbase Server we've already detected
253        # and set the appropriate OpenSSL variables
254        IF(APPLE)
255            IF(NOT OpenSSL_DIR)
256                EXECUTE_PROCESS(COMMAND brew --prefix openssl
257                    OUTPUT_VARIABLE OPENSSL_ROOT_DIR
258                    OUTPUT_STRIP_TRAILING_WHITESPACE)
259                MESSAGE(STATUS "Found OpenSSL Prefix: ${OPENSSL_ROOT_DIR}")
260            ENDIF()
261        ENDIF()
262        FIND_PACKAGE(OpenSSL)
263    ENDIF(NOT OPENSSL_FOUND)
264
265    IF(OPENSSL_FOUND)
266        MESSAGE(STATUS "SSL Found: ${OPENSSL_VERSION} (${OPENSSL_LIBRARIES})")
267    ELSE()
268        MESSAGE(STATUS "SSL Not Found. SSL support will be disabled")
269        ADD_DEFINITIONS(-DLCB_NO_SSL=1)
270    ENDIF()
271ENDIF()
272
273ADD_SUBDIRECTORY(src/vbucket)
274ADD_SUBDIRECTORY(contrib/cbsasl)
275ADD_SUBDIRECTORY(contrib/cliopts)
276ADD_SUBDIRECTORY(src/ssl)
277ADD_SUBDIRECTORY(contrib/lcb-jsoncpp)
278ADD_SUBDIRECTORY(contrib/snappy)
279IF(LCB_BUILD_EXAMPLES)
280    ADD_SUBDIRECTORY(example)
281ENDIF()
282
283IF(LCB_BUILD_STATIC)
284    SET(_lcb_linkspec STATIC)
285ELSE()
286    SET(_lcb_linkspec SHARED)
287ENDIF()
288
289# CMake configuration
290IF(NOT WIN32 AND LCB_BUILD_DTRACE)
291    INCLUDE(cmake/Modules/ConfigureDtrace.cmake)
292ENDIF()
293
294FILE(GLOB LCB_JSPARSE_SRC src/jsparse/*.cc)
295ADD_LIBRARY(lcb_jsparse OBJECT ${LCB_JSPARSE_SRC})
296LCB_CXXUTIL(lcb_jsparse)
297
298INCLUDE_DIRECTORIES(contrib/snappy)
299
300SET(LCB_CORE_OBJS
301    $<TARGET_OBJECTS:couchbase_select>
302    $<TARGET_OBJECTS:couchbase_utils>
303    $<TARGET_OBJECTS:vbucket-lcb>
304    $<TARGET_OBJECTS:mcreq>
305    $<TARGET_OBJECTS:mcreq-cxx>
306    $<TARGET_OBJECTS:netbuf>
307    $<TARGET_OBJECTS:cbsasl-lcb>
308    $<TARGET_OBJECTS:lcbio>
309    $<TARGET_OBJECTS:lcbio-cxx>
310    $<TARGET_OBJECTS:rdb>
311    $<TARGET_OBJECTS:lcbht>
312    $<TARGET_OBJECTS:lcbcore>
313    $<TARGET_OBJECTS:lcbcore-cxx>
314    $<TARGET_OBJECTS:lcb_jsparse>
315    $<TARGET_OBJECTS:lcb_jsoncpp>
316    $<TARGET_OBJECTS:lcb_snappy>
317    ${LCB_DTRACE_OBJECT}
318    ${lcb_plat_objs}
319    ${lcb_ssl_objs})
320
321ADD_LIBRARY(couchbaseS STATIC ${LCB_CORE_OBJS})
322ADD_LIBRARY(couchbase ${_lcb_linkspec} ${LCB_CORE_OBJS} ${PROJECT_BINARY_DIR}/dllversion.rc)
323
324# For DTrace implementations which need to gain access to all the *.o files first
325# we need to hook the linker command to a custom perl script which will intercept
326# the object files passed to the linker, run dtrace on them, and inject the generated
327# object into the linker commandline. This is a bit fragile but we don't officially
328# support any of these platforms anyway
329IF(LCB_DTRACE_INSTRO)
330    SET(_lcb_linkhook "${PROJECT_SOURCE_DIR}/cmake/dtrace-instr-link.pl ${LCB_DTRACE_SRC}")
331    SET_TARGET_PROPERTIES(couchbase PROPERTIES RULE_LAUNCH_LINK ${_lcb_linkhook})
332    SET_TARGET_PROPERTIES(couchbaseS PROPERTIES RULE_LAUNCH_LINK ${_lcb_linkhook})
333ENDIF()
334
335# This is done to be ABI-compatible with Autotools. On OSX, autotools generates
336# a library with a Compatibility and Current versions of 3.x despite our library
337# actually being versioned at 2.x. To make things worse, autotools also actually
338# provided a _symlink_ of libcouchbase.2.dylib. CMake cannot do this manually
339# and thus we disable the SOVERSION appending when on OS X, and revert to
340# inserting the version information by hand.
341IF(NOT APPLE)
342    SET_TARGET_PROPERTIES(couchbase PROPERTIES
343        SOVERSION "${LCB_SONAME_MAJOR}" VERSION "${LCB_SONAME_FULL}")
344ELSE()
345    SET_TARGET_PROPERTIES(couchbase PROPERTIES
346        LINK_FLAGS "-compatibility_version ${LCB_SONAME_MAJOR} -current_version ${LCB_SONAME_FULL}"
347        OUTPUT_NAME couchbase.2)
348    IF(NOT LCB_BUILD_STATIC)
349        ADD_CUSTOM_COMMAND(TARGET couchbase POST_BUILD
350            COMMAND rm -f libcouchbase.dylib
351            COMMAND ln libcouchbase.2.dylib libcouchbase.dylib
352            WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
353        INSTALL(FILES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libcouchbase.dylib
354            DESTINATION ${CMAKE_INSTALL_LIBDIR})
355    ENDIF()
356ENDIF()
357
358SET_TARGET_PROPERTIES(couchbase PROPERTIES PREFIX "lib")
359SET_TARGET_PROPERTIES(couchbase PROPERTIES IMPORT_PREFIX "lib")
360SET(LCB_LINK_DEPS ${lcb_plat_libs} ${lcb_ssl_libs} ${LCB_HDR_HISTOGRAM_LINK})
361IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
362    SET(LCB_LINK_DEPS ${LCB_LINK_DEPS} rt)
363ENDIF()
364IF(LIBPROFILER)
365    SET(LCB_LINK_DEPS ${LCB_LINK_DEPS} ${LIBPROFILER})
366ENDIF()
367
368TARGET_LINK_LIBRARIES(couchbase ${LCB_LINK_DEPS})
369TARGET_LINK_LIBRARIES(couchbaseS ${LCB_LINK_DEPS})
370
371ENABLE_TESTING()
372IF(NOT LCB_NO_TESTS)
373    ADD_SUBDIRECTORY(tests tests)
374ELSE()
375    ADD_TEST(NAME dummytest COMMAND echo "No Tests!")
376ENDIF(NOT LCB_NO_TESTS)
377
378IF(NOT LCB_NO_TOOLS)
379    ADD_SUBDIRECTORY(tools tools)
380ENDIF(NOT LCB_NO_TOOLS)
381
382# Always add this file, as we need the headers for this!
383ADD_SUBDIRECTORY(plugins/io/libuv)
384IF(NOT LCB_NO_PLUGINS AND LCB_BUILD_LIBUV)
385ENDIF()
386
387IF(NOT LCB_NO_PLUGINS AND NOT WIN32)
388    IF(LCB_BUILD_LIBEVENT)
389        ADD_SUBDIRECTORY(plugins/io/libevent)
390    ENDIF()
391    IF(LCB_BUILD_LIBEV)
392        ADD_SUBDIRECTORY(plugins/io/libev)
393    ENDIF()
394    IF(NOT (HAVE_LIBEV OR HAVE_LIBEVENT))
395        MESSAGE(FATAL_ERROR
396            "libev or libevent development files missing.
397            You can disable these dependencies by passing
398            -DLCB_NO_PLUGINS=1 to Cmake, or
399            --disable-plugins to the configure script")
400    ENDIF()
401ENDIF()
402
403
404IF(LCB_MAINTAINER_MODE)
405    IF(NOT (HAVE_LIBEV AND HAVE_LIBEVENT AND HAVE_LIBUV))
406        MESSAGE(FATAL_ERROR "Maintainer mode requires all plugins to be present")
407    ENDIF()
408ENDIF()
409
410ADD_SUBDIRECTORY(plugins/io/select)
411ADD_SUBDIRECTORY(plugins/io/iocp)
412INSTALL(TARGETS couchbase
413    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
414    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
415    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
416
417IF(LCB_INSTALL_HEADERS)
418    INSTALL(DIRECTORY include/libcouchbase ${LCB_GENSRCDIR}/libcouchbase
419            DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
420            FILES_MATCHING PATTERN *.h PATTERN *.c)
421ENDIF()
422
423INSTALL(DIRECTORY doc/man/ DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 FILES_MATCHING PATTERN *.1)
424INSTALL(DIRECTORY doc/man/ DESTINATION ${CMAKE_INSTALL_MANDIR}/man4  FILES_MATCHING PATTERN *.4)
425
426IF(MSVC)
427    INSTALL_PDBS(couchbase)
428ENDIF()
429
430SET(_lcb_tarname "libcouchbase-${LCB_VERSION}")
431SET(_lcb_manifest "${LCB_GENINFODIR}/MANIFEST")
432
433# pkg-config stuff goes with installation
434IF(NOT WIN32 AND LCB_INSTALL_PKGCONFIG)
435    CONFIGURE_FILE(packaging/libcouchbase.pc.in packaging/libcouchbase.pc @ONLY)
436    INSTALL(FILES ${PROJECT_BINARY_DIR}/packaging/libcouchbase.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
437ENDIF()
438
439
440ADD_CUSTOM_TARGET(uninstall
441    COMMAND xargs rm -vf < ${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt)
442
443ADD_CUSTOM_TARGET(file_manifest
444    COMMAND sh -c 'test -e ${_lcb_manifest} || git ls-files > ${_lcb_manifest}'
445    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
446
447
448ADD_CUSTOM_TARGET(dist
449    COMMAND rm -rf "${_lcb_tarname}"
450    COMMAND mkdir "${_lcb_tarname}"
451    COMMAND tar -cf - -C ${PROJECT_SOURCE_DIR} -T ${_lcb_manifest} | tar xf - -C "${_lcb_tarname}"
452    COMMAND cp -a "${LCB_GENINFODIR}" "${_lcb_tarname}/packaging"
453    COMMAND tar -czf "${_lcb_tarname}.tar.gz" "${_lcb_tarname}"
454    COMMAND rm -rf "${_lcb_tarname}"
455    DEPENDS file_manifest)
456
457# Generate our configuration file _after_ we've collected everything
458INCLUDE(cmake/Modules/GenerateConfigDotH.cmake)
459
460# Build any local tests/scripts
461IF (EXISTS ${SOURCE_ROOT}/tests/LOCAL)
462    ADD_SUBDIRECTORY(${SOURCE_ROOT}/tests/LOCAL)
463ENDIF()
464