1fe3bef91STrond NorbyeCMAKE_MINIMUM_REQUIRED(VERSION 3.2)
2fe3bef91STrond NorbyePROJECT(Platform LANGUAGES C CXX)
301bc6fa5SChris Hillery
4a06044f3SJames HarrisonINCLUDE(CheckFunctionExists)
5e40463a5STrond NorbyeINCLUDE(CheckIncludeFile)
673e41e75STrond NorbyeINCLUDE(CheckIncludeFileCXX)
77c9fec13STrond NorbyeINCLUDE(CheckSymbolExists)
866cd3be3SDave RigbyINCLUDE(CTest)
9b93566a1STrond NorbyeINCLUDE(GenerateExportHeader)
10874f1147STrond NorbyeINCLUDE(check_unit_test_enabled)
1166cd3be3SDave Rigby
121e351138SSundar SridharanOPTION(PLATFORM_ENABLE_CBSOCKET "Build cbsocket support" ON)
131e351138SSundar Sridharan
14874f1147STrond Norbyecheck_unit_test_enabled(platform COUCHBASE_PLATFORM_BUILD_UNIT_TESTS)
15874f1147STrond Norbyeif (COUCHBASE_PLATFORM_BUILD_UNIT_TESTS)
16874f1147STrond Norbye    ENABLE_CODE_COVERAGE_REPORT()
17874f1147STrond Norbyeendif (COUCHBASE_PLATFORM_BUILD_UNIT_TESTS)
187c9fec13STrond Norbye
19812ef862STrond NorbyeCMAKE_PUSH_CHECK_STATE(RESET)
20812ef862STrond Norbye  FIND_LIBRARY(EXECINFO_LIBRARY NAMES execinfo)
21812ef862STrond Norbye  IF (EXECINFO_LIBRARY)
22812ef862STrond Norbye    SET(CMAKE_REQUIRED_LIBRARIES "${EXECINFO_LIBRARY}")
23812ef862STrond Norbye    LIST(APPEND PLATFORM_LIBRARIES "${EXECINFO_LIBRARY}")
24812ef862STrond Norbye  ENDIF(EXECINFO_LIBRARY)
25812ef862STrond Norbye  CHECK_SYMBOL_EXISTS(backtrace execinfo.h HAVE_BACKTRACE)
26812ef862STrond NorbyeCMAKE_POP_CHECK_STATE()
274d17a68eSDave Rigby
284d17a68eSDave RigbyCMAKE_PUSH_CHECK_STATE(RESET)
29812ef862STrond Norbye  SET(CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
30812ef862STrond Norbye  FIND_LIBRARY(DL_LIBRARY NAMES dl)
31812ef862STrond Norbye  IF (DL_LIBRARY)
32812ef862STrond Norbye    SET(CMAKE_REQUIRED_LIBRARIES "${DL_LIBRARY}")
33812ef862STrond Norbye    LIST(APPEND PLATFORM_LIBRARIES "${DL_LIBRARY}")
34812ef862STrond Norbye  ENDIF (DL_LIBRARY)
35812ef862STrond Norbye  CHECK_SYMBOL_EXISTS(dladdr dlfcn.h HAVE_DLADDR)
364d17a68eSDave RigbyCMAKE_POP_CHECK_STATE()
374d17a68eSDave Rigby
38d75118b8STrond NorbyeCMAKE_PUSH_CHECK_STATE(RESET)
39d75118b8STrond NorbyeSET(CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
40d75118b8STrond NorbyeSET(CMAKE_REQUIRED_LIBRARIES "pthread")
41d75118b8STrond NorbyeCHECK_SYMBOL_EXISTS(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP)
4266d1bc68STrond NorbyeCHECK_SYMBOL_EXISTS(pthread_getname_np pthread.h HAVE_PTHREAD_GETNAME_NP)
43b20faafbSDave RigbyCHECK_SYMBOL_EXISTS(sched_getaffinity sched.h HAVE_SCHED_GETAFFINITY)
44b5f07db5SJim WalkerCHECK_SYMBOL_EXISTS(sched_getcpu sched.h HAVE_SCHED_GETCPU)
45d75118b8STrond NorbyeCMAKE_POP_CHECK_STATE()
46d75118b8STrond Norbye
471988bc55SDave RigbyCMAKE_PUSH_CHECK_STATE(RESET)
48dc63d24cSWillGardner
49dc63d24cSWillGardnerCHECK_CXX_SOURCE_COMPILES("
50dc63d24cSWillGardner    #include <memory>
51dc63d24cSWillGardner    int main() {
52dc63d24cSWillGardner        return *std::make_unique<int>(0);
53dc63d24cSWillGardner    }" HAVE_MAKE_UNIQUE)
541988bc55SDave RigbyCMAKE_POP_CHECK_STATE()
55d75118b8STrond Norbye
567c9fec13STrond NorbyeCHECK_SYMBOL_EXISTS(gethrtime sys/time.h CB_DONT_NEED_GETHRTIME)
577c9fec13STrond NorbyeCHECK_SYMBOL_EXISTS(htonll arpa/inet.h CB_DONT_NEED_BYTEORDER)
58b5f07db5SJim WalkerCHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H)
5973e41e75STrond NorbyeCONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/src/config.cmake.h
6073e41e75STrond Norbye                ${CMAKE_CURRENT_BINARY_DIR}/src/config.h)
616efa2cc0STrond Norbye
627c9fec13STrond NorbyeCONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/include/platform/dynamic.in.h
637c9fec13STrond Norbye                ${CMAKE_CURRENT_BINARY_DIR}/include/platform/dynamic.h)
647c9fec13STrond Norbye
656efa2cc0STrond Norbye#
666efa2cc0STrond Norbye# Set the include path
676efa2cc0STrond Norbye#
686696145fSDave RigbyINCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/external)
696efa2cc0STrond Norbye
70a865ae07SDave RigbyIF (MEMORY_ALLOCATOR)
71a865ae07SDave Rigby  INCLUDE_DIRECTORIES(AFTER ${MALLOC_INCLUDE_DIR})
72a865ae07SDave RigbyENDIF (MEMORY_ALLOCATOR)
73a865ae07SDave Rigby
74f5ea2249STrond NorbyeADD_LIBRARY(cJSON SHARED
75f5ea2249STrond Norbye            include/cJSON.h
76f5ea2249STrond Norbye            include/cJSON_utils.h
7770673810STrond Norbye            src/cJSON.cc
78f5ea2249STrond Norbye            src/cJSON_utils.cc)
79f5ea2249STrond NorbyeSET_TARGET_PROPERTIES(cJSON PROPERTIES SOVERSION 1.1.0)
8078c05968STrond NorbyeGENERATE_EXPORT_HEADER(cJSON
8178c05968STrond Norbye                       EXPORT_MACRO_NAME CJSON_PUBLIC_API
8278c05968STrond Norbye                       EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/include/platform/cJSON-visibility.h)
836696145fSDave RigbyTARGET_INCLUDE_DIRECTORIES(cJSON INTERFACE include)
846696145fSDave RigbyTARGET_LINK_LIBRARIES(cJSON PRIVATE gsl_lite)
8521dc4478STrond Norbye
8610379176STrond NorbyeADD_LIBRARY(JSON_checker SHARED src/JSON_checker.cc include/JSON_checker.h)
873a9ee9e9STrond NorbyeSET_TARGET_PROPERTIES(JSON_checker PROPERTIES SOVERSION 1.0.0)
886696145fSDave RigbyTARGET_LINK_LIBRARIES(JSON_checker PRIVATE platform_headers)
895c6a39bcSDave RigbyGENERATE_EXPORT_HEADER(JSON_checker
905c6a39bcSDave Rigby                       EXPORT_MACRO_NAME JSON_CHECKER_PUBLIC_API
915c6a39bcSDave Rigby                       EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/include/platform/JSON_checker-visibility.h)
92b8af0d5eSTrond Norbye
936efa2cc0STrond NorbyeIF (WIN32)
94a35b41c0STrond Norbye   INCLUDE_DIRECTORIES(AFTER ${CMAKE_CURRENT_SOURCE_DIR}/include/win32)
954aae569dSTrond Norbye   ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
96cc62f3a2STrond Norbye   SET(PLATFORM_FILES src/sockets.c
97f653d428STrond Norbye                      src/cb_win32.cc
984aae569dSTrond Norbye                      src/winrandom.c
99c92813c5STrond Norbye                      src/memorymap_win32.cc
1004aae569dSTrond Norbye                      include/win32/getopt.h
1014aae569dSTrond Norbye                      include/win32/strings.h
1024aae569dSTrond Norbye                      include/win32/unistd.h)
103be8e1986STrond Norbye
104be8e1986STrond Norbye   # Allow to build on unsupported platorms (currently with MSVC 2017CE)
105be8e1986STrond Norbye   # and the FindCouchbaseDbgHelp macro didn't pick it up in the new location
106be8e1986STrond Norbye   # stuff has been moved around for the CE version. The library is only used
107be8e1986STrond Norbye   # for backtrace support which we can live without
1084b5c476cSChris Hillery   CB_GET_SUPPORTED_PLATFORM(_supported_platform)
109be8e1986STrond Norbye   if (_supported_platform)
110be8e1986STrond Norbye       ADD_DEFINITIONS(-DHAVE_BACKTRACE_SUPPORT=1)
111be8e1986STrond Norbye       INCLUDE(FindCouchbaseDbgHelp)
112be8e1986STrond Norbye       LIST(APPEND PLATFORM_LIBRARIES "${DBGHELP_LIBRARY}")
113be8e1986STrond Norbye   endif ()
1146efa2cc0STrond NorbyeELSE (WIN32)
11540fa120eSTrond Norbye   SET(PLATFORM_FILES src/cb_pthreads.cc src/urandom.c src/memorymap_posix.cc)
1161037a5d6SJim Walker   SET_SOURCE_FILES_PROPERTIES(src/crc32c_sse4_2.cc PROPERTIES COMPILE_FLAGS -msse4.2)
117812ef862STrond Norbye   LIST(APPEND PLATFORM_LIBRARIES "pthread")
118dd84be8aSTrond Norbye
1194aae569dSTrond Norbye   IF (NOT APPLE)
120812ef862STrond Norbye      LIST(APPEND PLATFORM_LIBRARIES "rt")
1214aae569dSTrond Norbye   ENDIF(NOT APPLE)
12221dc4478STrond Norbye
123c9ca84bcSDave Rigby   SET(LIB_M m)
1246efa2cc0STrond NorbyeENDIF (WIN32)
1256efa2cc0STrond Norbye
1266696145fSDave RigbyTARGET_LINK_LIBRARIES(cJSON PRIVATE platform ${LIB_M})
127c9ca84bcSDave Rigby
1284aae569dSTrond NorbyeIF (NOT DEFINED COUCHBASE_NETWORK_LIBS)
1294aae569dSTrond Norbye   IF (WIN32)
1304aae569dSTrond Norbye      SET(COUCHBASE_NETWORK_LIBS "Ws2_32")
1314aae569dSTrond Norbye   ELSEIF ("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
1324aae569dSTrond Norbye      SET(COUCHBASE_NETWORK_LIBS socket nsl)
1334aae569dSTrond Norbye   ENDIF (WIN32)
1344aae569dSTrond NorbyeENDIF (NOT DEFINED COUCHBASE_NETWORK_LIBS)
1354aae569dSTrond Norbye
13686a96221STrond NorbyeIF ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
13786a96221STrond Norbye    # The implementation you get with chrono on a default FreeBSD 10
13886a96221STrond Norbye    # is dead slow and considered useless...
13986a96221STrond Norbye    SET(HAVE_DEAD_SLOW_CHRONO true)
14086a96221STrond NorbyeENDIF ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
14186a96221STrond Norbye
14286a96221STrond NorbyeIF (CB_DONT_NEED_GETHRTIME OR HAVE_DEAD_SLOW_CHRONO)
14333df39e7SDave Rigby   SET(PLATFORM_FILES ${PLATFORM_FILES} src/gethrtime.c)
14486a96221STrond NorbyeELSE (CB_DONT_NEED_GETHRTIME OR HAVE_DEAD_SLOW_CHRONO)
14573e41e75STrond Norbye   SET(PLATFORM_FILES ${PLATFORM_FILES} src/cxxtime.cc)
14686a96221STrond NorbyeENDIF (CB_DONT_NEED_GETHRTIME OR HAVE_DEAD_SLOW_CHRONO)
14773e41e75STrond Norbye
148a06044f3SJames HarrisonCHECK_FUNCTION_EXISTS(malloc_usable_size HAVE_MALLOC_USABLE_SIZE)
149a06044f3SJames Harrisonif(HAVE_MALLOC_USABLE_SIZE)
150a06044f3SJames Harrison  ADD_DEFINITIONS(-DHAVE_MALLOC_USABLE_SIZE)
151a06044f3SJames Harrisonendif()
1526efa2cc0STrond Norbye#
1536efa2cc0STrond Norbye# Add all of the libraries
1546efa2cc0STrond Norbye#
1553033f677SDave Rigby
1566696145fSDave Rigby# 'platform_headers' - header-only part of platform.
1576696145fSDave Rigby#
1586696145fSDave Rigby# This should typically only be used for tests / benchmarks which want the
1596696145fSDave Rigby# definitions of platform functions; but don't want to link against the
1606696145fSDave Rigby# complete library. For example, a unit test might want to just link against
1616696145fSDave Rigby# the single .cc file for the code it is testing, but needs the prototype(s)
1626696145fSDave Rigby# of that .cc file.
1636696145fSDave RigbyADD_LIBRARY(platform_headers INTERFACE)
1646696145fSDave RigbyTARGET_INCLUDE_DIRECTORIES(platform_headers INTERFACE
1656696145fSDave Rigby        include
1666696145fSDave Rigby        # "config.h" (which resides in ${Platform_BINARY_DIR}/src) is needed
1676696145fSDave Rigby        # indirectly by any targets linking against platform_headers (because
1686696145fSDave Rigby        # a number of platform's public headers include it).
1695c6a39bcSDave Rigby        ${Platform_BINARY_DIR}/src
1705c6a39bcSDave Rigby        ${Platform_BINARY_DIR}/include)
1716696145fSDave Rigby
1723033f677SDave Rigby# platform_so - the 'real' platform shared library containing our various
1733033f677SDave Rigby# platform abstraction functionality.
1743033f677SDave Rigby# Note that in general external users should link 'platform' and not
1753033f677SDave Rigby# 'platform_so' - see below.
1763033f677SDave RigbyADD_LIBRARY(platform_so SHARED ${PLATFORM_FILES}
1774aae569dSTrond Norbye                            ${CMAKE_CURRENT_BINARY_DIR}/src/config.h
17823b4c6b6STrond Norbye                            src/base64.cc
17929be3607STrond Norbye                            src/getpid.c
1804aae569dSTrond Norbye                            src/random.cc
1814d17a68eSDave Rigby                            src/backtrace.c
182aa468a60STrond Norbye                            src/byte_buffer_dump.cc
1834aae569dSTrond Norbye                            src/byteorder.c
184a865ae07SDave Rigby                            src/cb_malloc.cc
18514603289SEugen-Alexandru Virtan                            src/cb_mktemp.cc
186f223bf3eSTrond Norbye                            src/cb_time.cc
18794d56619STrond Norbye                            src/cbassert.c
188ae2a7a24STrond Norbye                            src/checked_snprintf.cc
189972dd75dSJim Walker                            src/crc32c.cc
1901037a5d6SJim Walker                            src/crc32c_sse4_2.cc
1911037a5d6SJim Walker                            src/crc32c_private.h
192cc62f3a2STrond Norbye                            src/getopt.cc
1933033f677SDave Rigby                            src/global_new_replacement.cc
194decc36ebSDave Rigby                            src/histogram.cc
19572cbf62fSWill Gardner                            src/interrupt.cc
196c66bf85eSDaniel Owen                            src/processclock.cc
197f653d428STrond Norbye                            src/strerror.cc
198f8a5ef74STrond Norbye                            src/string.cc
199157bad23STrond Norbye                            src/strnstr.cc
200b20faafbSDave Rigby                            src/sysinfo.cc
201ece3b8ddSTrond Norbye                            src/thread.cc
2024e19c8c2STrond Norbye                            src/timeutils.cc
2031a0b3e5eSTrond Norbye                            src/uuid.cc
2042d971aa5SEugen-Alexandru Virtan                            include/platform/atomic_duration.h
205654fd66cSDave Rigby                            include/platform/backtrace.h
20623b4c6b6STrond Norbye                            include/platform/base64.h
207c9135ff7SJim Walker                            include/platform/bitset.h
208aa468a60STrond Norbye                            include/platform/byte_buffer_dump.h
209654fd66cSDave Rigby                            include/platform/cacheline_padded.h
210654fd66cSDave Rigby                            include/platform/cb_malloc.h
211654fd66cSDave Rigby                            include/platform/cbassert.h
212654fd66cSDave Rigby                            include/platform/checked_snprintf.h
213654fd66cSDave Rigby                            include/platform/corestore.h
214972dd75dSJim Walker                            include/platform/crc32c.h
215cc62f3a2STrond Norbye                            include/platform/getopt.h
21672cbf62fSWill Gardner                            include/platform/interrupt.h
217654fd66cSDave Rigby                            include/platform/make_unique.h
218972dd75dSJim Walker                            include/platform/memorymap.h
219654fd66cSDave Rigby                            include/platform/non_negative_counter.h
2204aae569dSTrond Norbye                            include/platform/platform.h
2212c62e727STrond Norbye                            include/platform/pipe.h
222c66bf85eSDaniel Owen                            include/platform/processclock.h
2234aae569dSTrond Norbye                            include/platform/random.h
224a2257166SMark Nunberg                            include/platform/ring_buffer.h
225654fd66cSDave Rigby                            include/platform/rwlock.h
2269353d943SWillGardner                            include/platform/sized_buffer.h
227f653d428STrond Norbye                            include/platform/strerror.h
228f8a5ef74STrond Norbye                            include/platform/string.h
229b20faafbSDave Rigby                            include/platform/sysinfo.h
230ece3b8ddSTrond Norbye                            include/platform/thread.h
2314e19c8c2STrond Norbye                            include/platform/timeutils.h
232654fd66cSDave Rigby                            include/platform/uuid.h
2335c6a39bcSDave Rigby                            ${Platform_BINARY_DIR}/include/platform/visibility.h)
2345c6a39bcSDave RigbyGENERATE_EXPORT_HEADER(platform_so
2355c6a39bcSDave Rigby                       EXPORT_MACRO_NAME PLATFORM_PUBLIC_API
2365c6a39bcSDave Rigby                       EXPORT_FILE_NAME ${Platform_BINARY_DIR}/include/platform/visibility.h)
2374aae569dSTrond Norbye
23821991f26SWill GardnerLIST(APPEND PLATFORM_LIBRARIES "phosphor")
239812ef862STrond NorbyeLIST(REMOVE_DUPLICATES PLATFORM_LIBRARIES)
2406696145fSDave RigbyTARGET_LINK_LIBRARIES(platform_so PRIVATE
2416696145fSDave Rigby        platform_headers
2426696145fSDave Rigby        gsl_lite
2436696145fSDave Rigby        ${MALLOC_LIBRARIES}
2446696145fSDave Rigby        ${PLATFORM_LIBRARIES})
2456696145fSDave Rigby
2466696145fSDave Rigby# Link publically with COUCHBASE_NETWORK_LIBS - strictly speaking this
2476696145fSDave Rigby# shouldn't be necessary, however a number of downstream components
2486696145fSDave Rigby# (e.g. couchstore targets) rely on platform to make available
2496696145fSDave Rigby# htons/htonl (via Ws2_32) etc when building on Windows.
2506696145fSDave Rigby# Until all such targets are # updated to link directly to Ws2_32, we
2516696145fSDave Rigby# link publically.
2526696145fSDave RigbyTARGET_LINK_LIBRARIES(platform_so PUBLIC
2536696145fSDave Rigby        ${COUCHBASE_NETWORK_LIBS})
2546696145fSDave Rigby
2556696145fSDave RigbyTARGET_INCLUDE_DIRECTORIES(platform_so PUBLIC include)
2566696145fSDave Rigby# TODO: Add a TARGET_INCLUDE_DIRECTORIES(PUBLIC) to phosphor; then the
2576696145fSDave Rigby# following line can be removed:
2586696145fSDave RigbyTARGET_INCLUDE_DIRECTORIES(platform_so PRIVATE ${phosphor_SOURCE_DIR}/include)
2593033f677SDave Rigby
2603033f677SDave Rigby# 'platform' - the library clients should normally link to.
2613033f677SDave Rigby#
2623033f677SDave Rigby# 'platform' is a static library, which itself links to the main platform_so
2633033f677SDave Rigby# shared library. This is to ensure that any clients of platform always link
2643033f677SDave Rigby# in the C++ global operator new/delete replacements if they use platform at
2653033f677SDave Rigby# all. If they didn't then this would cause problems:
2663033f677SDave Rigby# 1) Memory usage from the client will not be tracked.
2673033f677SDave Rigby# 2) If a C++ object allocated in platform (using cbmalloc via new) is
2683033f677SDave Rigby#    delete'd in the client (using default free) then we have a mismatched
2693033f677SDave Rigby#    new/delete pair.
2703033f677SDave Rigby# By giving all clients of platform the global new/delete automatically we
2713033f677SDave Rigby# avoid these problems.
2723033f677SDave RigbyADD_LIBRARY(platform STATIC src/global_new_replacement.cc)
2733033f677SDave RigbySET_TARGET_PROPERTIES(platform PROPERTIES POSITION_INDEPENDENT_CODE true)
2746696145fSDave RigbyTARGET_LINK_LIBRARIES(platform platform_headers platform_so)
275f4711995STrond Norbye
276d91fece9SMike Wiederhold# On OS X 10.11 we need to remove the default rpath settings in order to all
277d91fece9SMike Wiederhold# us to load the platform library from Python scripts that are run out of
278d91fece9SMike Wiederhold# /usr/bin/python. We can remove this once we ship our own Python.
279d91fece9SMike WiederholdIF (APPLE)
2803033f677SDave Rigby    SET_TARGET_PROPERTIES(platform_so
281d91fece9SMike Wiederhold                          PROPERTIES
282d91fece9SMike Wiederhold                          INSTALL_RPATH "")
283d91fece9SMike WiederholdENDIF ()
284d91fece9SMike Wiederhold
2853033f677SDave RigbySET_TARGET_PROPERTIES(platform_so PROPERTIES SOVERSION 0.1.0)
2866efa2cc0STrond Norbye
2873033f677SDave Rigby# TODO: Given dirutils now links with platform (for cbmalloc &
2883033f677SDave Rigby# global_new_replacement) we can probably just merge it into platform.
2893033f677SDave RigbyADD_LIBRARY(dirutils SHARED
2903033f677SDave Rigby            src/dirutils.cc
2913033f677SDave Rigby            include/platform/dirutils.h)
29269030100STrond NorbyeSET_TARGET_PROPERTIES(dirutils PROPERTIES SOVERSION 0.1.0)
2933033f677SDave RigbyTARGET_LINK_LIBRARIES(dirutils platform)
294b93566a1STrond NorbyeGENERATE_EXPORT_HEADER(dirutils
295b93566a1STrond Norbye                       EXPORT_MACRO_NAME DIRUTILS_PUBLIC_API
296b93566a1STrond Norbye                       EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/include/platform/dirutils-visibility.h)
29769030100STrond Norbye
298740896b3SDave RigbyIF (BREAKPAD_FOUND)
299740896b3SDave Rigby   ADD_DEFINITIONS(-DHAVE_BREAKPAD)
300740896b3SDave Rigby   INCLUDE_DIRECTORIES(AFTER ${BREAKPAD_INCLUDE_DIR})
301740896b3SDave Rigby   # Breakpad has headers (which are dependencies for our breakpad integration
302740896b3SDave Rigby   # code) that don't compile cleanly as C++11, so the GNU standard is
303740896b3SDave Rigby   # used instead.
304740896b3SDave Rigby   IF (UNIX)
305740896b3SDave Rigby      set_source_files_properties(src/breakpad_wrapper.cc PROPERTIES COMPILE_FLAGS ${CB_GNU_CXX11_OPTION})
306740896b3SDave Rigby   ENDIF (UNIX)
307b313e2baSDave RigbyENDIF (BREAKPAD_FOUND)
308740896b3SDave Rigby
309b313e2baSDave Rigby# To simplify usage we always build breakpad_wrapper; it'll just
310b313e2baSDave Rigby# do nothing on targets which don't have Breakpad.
311b313e2baSDave RigbyADD_LIBRARY(breakpad_wrapper SHARED
312b313e2baSDave Rigby            src/breakpad_wrapper.cc
313b313e2baSDave Rigby            include/breakpad_wrapper/breakpad_wrapper.h)
3145c6a39bcSDave RigbySET_TARGET_PROPERTIES(breakpad_wrapper PROPERTIES COMPILE_FLAGS "-Dplatform_so_EXPORTS")
315b313e2baSDave RigbyTARGET_LINK_LIBRARIES(breakpad_wrapper
3166696145fSDave Rigby                      ${BREAKPAD_LIBRARIES} platform_headers)
317972dd75dSJim Walker
3183033f677SDave RigbyINSTALL(TARGETS breakpad_wrapper cJSON JSON_checker platform_so dirutils
3196efa2cc0STrond Norbye        RUNTIME DESTINATION bin
3206efa2cc0STrond Norbye        LIBRARY DESTINATION lib
3216efa2cc0STrond Norbye        ARCHIVE DESTINATION lib)
32203179825STrond Norbye
32315f14fb0STrond NorbyeADD_SUBDIRECTORY(cbcompress)
3241e351138SSundar Sridharan
3251e351138SSundar SridharanIF (PLATFORM_ENABLE_CBSOCKET)
3261e351138SSundar Sridharan   ADD_SUBDIRECTORY(cbsocket)
3271e351138SSundar SridharanENDIF (PLATFORM_ENABLE_CBSOCKET)
328aa3eecb1STrond Norbye
329874f1147STrond Norbyeif (COUCHBASE_PLATFORM_BUILD_UNIT_TESTS)
330874f1147STrond Norbye    ADD_SUBDIRECTORY(tests)
331874f1147STrond Norbyeendif (COUCHBASE_PLATFORM_BUILD_UNIT_TESTS)
332