1ca6022cdSTrond NorbyePROJECT(Couchstore)
2ca6022cdSTrond NorbyeCMAKE_MINIMUM_REQUIRED(VERSION 2.8)
3ca6022cdSTrond Norbye
446f1ef48STrond NorbyeIF (${CMAKE_MAJOR_VERSION} GREATER 2)
546f1ef48STrond Norbye    CMAKE_POLICY(SET CMP0042 NEW)
646f1ef48STrond NorbyeENDIF (${CMAKE_MAJOR_VERSION} GREATER 2)
746f1ef48STrond Norbye
80c640a13STrond NorbyeINCLUDE(CheckFunctionExists)
90c640a13STrond NorbyeINCLUDE(CheckIncludeFile)
100c640a13STrond NorbyeINCLUDE(CheckIncludeFiles)
110c640a13STrond NorbyeINCLUDE(CheckLibraryExists)
120c640a13STrond NorbyeINCLUDE(CheckSymbolExists)
130c640a13STrond NorbyeINCLUDE(CheckTypeSize)
14346633adSDave RigbyINCLUDE(CTest)
15aca76c86SDave RigbyINCLUDE(GenerateExportHeader)
164d037946STrond Norbyeinclude(check_unit_test_enabled)
174d037946STrond Norbye
184d037946STrond Norbyecheck_unit_test_enabled(couchstore COUCHBASE_COUCHSTORE_BUILD_UNIT_TESTS)
190c640a13STrond Norbye
20c80a2f8aSDave RigbyINCLUDE_DIRECTORIES(BEFORE ${CMAKE_INSTALL_PREFIX}/include
21c80a2f8aSDave Rigby                           ${CMAKE_CURRENT_SOURCE_DIR}/include
220c640a13STrond Norbye                           ${CMAKE_CURRENT_SOURCE_DIR}/src
230c640a13STrond Norbye                           ${CMAKE_CURRENT_BINARY_DIR}
24290dcd61STrond Norbye                           ${CMAKE_CURRENT_SOURCE_DIR}
257312d627SJung-Sang Ahn                           ${BOOST_INCLUDE_DIR}
26c2c458ffSsduvuru                           ${Platform_SOURCE_DIR}/include
27c2c458ffSsduvuru                           ${phosphor_SOURCE_DIR}/include)
28c80a2f8aSDave Rigby
29fab83949STrond NorbyeINCLUDE_DIRECTORIES(AFTER ${gsl_lite_SOURCE_DIR}/include)
30fab83949STrond Norbye
314d037946STrond NorbyeIF (COUCHBASE_COUCHSTORE_BUILD_UNIT_TESTS AND LUA_FOUND)
324d037946STrond Norbye   INCLUDE_DIRECTORIES(AFTER SYSTEM {LUA_INCLUDE_DIR})
334d037946STrond NorbyeENDIF (COUCHBASE_COUCHSTORE_BUILD_UNIT_TESTS AND LUA_FOUND)
34d897c709STrond Norbye
3519cd7c02STrond NorbyeINCLUDE_DIRECTORIES(AFTER
36ec877c45SDave Rigby                    ${KVEngineAPI_SOURCE_DIR}
37ec877c45SDave Rigby                    ${KVEngineAPI_BINARY_DIR})
389995e2f1STrond Norbye
39fff3e200STrond NorbyeINCLUDE_DIRECTORIES(AFTER SYSTEM ${ICU_INCLUDE_DIR}
40160b6d14SChris Hillery                          ${V8_INCLUDE_DIR}
41cf120adaSJim Walker                          ${SNAPPY_INCLUDE_DIR}
42cf120adaSJim Walker                          ${FOLLY_INCLUDE_DIR})
430c640a13STrond Norbye
440c640a13STrond NorbyeCHECK_INCLUDE_FILES("netinet/in.h" HAVE_NETINET_IN_H)
450c640a13STrond NorbyeCHECK_INCLUDE_FILES("inttypes.h" HAVE_INTTYPES_H)
46462b7a82STrond NorbyeCHECK_INCLUDE_FILES("unistd.h" HAVE_UNISTD_H)
470c640a13STrond NorbyeCHECK_SYMBOL_EXISTS(fdatasync "unistd.h" HAVE_FDATASYNC)
4823b42d51SSarath LakshmanCHECK_SYMBOL_EXISTS(qsort_r "stdlib.h" HAVE_QSORT_R)
490c640a13STrond Norbye
500c640a13STrond NorbyeIF (WIN32)
518f6123bfSWill Gardner  SET(COUCHSTORE_FILE_OPS "src/os_win.cc")
520c640a13STrond NorbyeELSE(WIN32)
538f6123bfSWill Gardner  SET(COUCHSTORE_FILE_OPS "src/os.cc")
54bc928d55SSriram Melkote  # v8 expects icudtl.dat to be next to binary
55bc928d55SSriram Melkote  INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/lib/icudtl.dat
56bc928d55SSriram Melkote          DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
570c640a13STrond NorbyeENDIF(WIN32)
580c640a13STrond Norbye
59cf120adaSJim Walker# Create two object libraries, one for the core couchstore code
60cf120adaSJim WalkerADD_LIBRARY(couchstore_objs OBJECT
61cf120adaSJim Walker        src/arena.cc
62cf120adaSJim Walker        src/bitfield.cc
63cf120adaSJim Walker        src/btree_modify.cc
64cf120adaSJim Walker        src/btree_read.cc
65cf120adaSJim Walker        src/couch_db.cc
66cf120adaSJim Walker        src/couch_file_read.cc
67cf120adaSJim Walker        src/couch_file_write.cc
68cf120adaSJim Walker        src/couch_latency.cc
69cf120adaSJim Walker        src/couch_save.cc
70cf120adaSJim Walker        src/crc32.cc
71cf120adaSJim Walker        src/db_compact.cc
72cf120adaSJim Walker        src/file_merger.cc
73cf120adaSJim Walker        src/file_name_utils.c
74cf120adaSJim Walker        src/file_sorter.cc
75cf120adaSJim Walker        src/iobuffer.cc
76cf120adaSJim Walker        src/llmsort.cc
77cf120adaSJim Walker        src/mergesort.cc
78cf120adaSJim Walker        src/node_types.cc
79cf120adaSJim Walker        src/quicksort.c
80cf120adaSJim Walker        src/reduces.cc
81cf120adaSJim Walker        src/strerror.cc
82cf120adaSJim Walker        src/tree_writer.cc
83cf120adaSJim Walker        src/util.cc
84cf120adaSJim Walker        ${COUCHSTORE_FILE_OPS})
85cf120adaSJim WalkerTARGET_COMPILE_DEFINITIONS(couchstore_objs PUBLIC -Dcouchstore_EXPORTS)
86cf120adaSJim WalkerSET_PROPERTY(TARGET couchstore_objs PROPERTY POSITION_INDEPENDENT_CODE 1)
87cf120adaSJim Walker
88cf120adaSJim Walker# second object library is for the view specific code
89cf120adaSJim WalkerADD_LIBRARY(couchstore_view_objs OBJECT
90cf120adaSJim Walker        src/views/bitmap.c
91cf120adaSJim Walker        src/views/collate_json.cc
92cf120adaSJim Walker        src/views/file_merger.cc
93cf120adaSJim Walker        src/views/file_sorter.cc
94cf120adaSJim Walker        src/views/index_header.cc
95cf120adaSJim Walker        src/views/keys.cc
96cf120adaSJim Walker        src/views/mapreduce/mapreduce.cc
97cf120adaSJim Walker        src/views/mapreduce/mapreduce_c.cc
98cf120adaSJim Walker        src/views/reducers.cc
99cf120adaSJim Walker        src/views/reductions.cc
100cf120adaSJim Walker        src/views/sorted_list.c
101cf120adaSJim Walker        src/views/spatial.cc
102cf120adaSJim Walker        src/views/spatial_modify.cc
103cf120adaSJim Walker        src/views/util.cc
104cf120adaSJim Walker        src/views/values.cc
105cf120adaSJim Walker        src/views/view_group.cc
106cf120adaSJim Walker        src/views/purgers.cc
107cf120adaSJim Walker        src/views/compaction.cc
108cf120adaSJim Walker        $<TARGET_OBJECTS:couchstore_objs>)
109cf120adaSJim WalkerTARGET_COMPILE_DEFINITIONS(couchstore_view_objs PUBLIC -Dcouchstore_EXPORTS)
110cf120adaSJim WalkerSET_PROPERTY(TARGET couchstore_view_objs PROPERTY POSITION_INDEPENDENT_CODE 1)
111cf120adaSJim Walker
112cf120adaSJim Walker# libcouchstore, core couchstore library
113cf120adaSJim WalkerADD_LIBRARY(couchstore SHARED $<TARGET_OBJECTS:couchstore_objs>)
114cf120adaSJim WalkerSET(COUCHSTORE_LIBS cbcompress platform phosphor)
115cf120adaSJim WalkerTARGET_LINK_LIBRARIES(couchstore ${COUCHSTORE_LIBS})
116bcc4d4baSWill Gardner
117aca76c86SDave RigbyGENERATE_EXPORT_HEADER(couchstore
118aca76c86SDave Rigby                       EXPORT_MACRO_NAME LIBCOUCHSTORE_API
119aca76c86SDave Rigby                       EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/include/libcouchstore/visibility.h
120aca76c86SDave Rigby                       NO_EXPORT_MACRO_NAME STATIC
121aca76c86SDave Rigby                       STATIC_DEFINE LIBCOUCHSTORE_NO_VISIBILITY)
122cf120adaSJim Walker
123cf120adaSJim WalkerTARGET_INCLUDE_DIRECTORIES(couchstore_objs PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include)
124cf120adaSJim WalkerTARGET_INCLUDE_DIRECTORIES(couchstore_view_objs PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include)
125aca76c86SDave RigbyTARGET_INCLUDE_DIRECTORIES(couchstore PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include)
1260c640a13STrond Norbye
127cf120adaSJim Walker# libcouchstore_views - core couchstore library + view code and is dependent on
128cf120adaSJim Walker# v8 and icu libraries
129cf120adaSJim WalkerADD_LIBRARY(couchstore_views SHARED
130cf120adaSJim Walker            $<TARGET_OBJECTS:couchstore_objs>
131cf120adaSJim Walker            $<TARGET_OBJECTS:couchstore_view_objs>)
132cf120adaSJim WalkerSET(COUCHSTORE_VIEW_LIBS ${COUCHSTORE_LIBS} ${V8_LIBRARIES} ${ICU_LIBRARIES})
133cf120adaSJim WalkerTARGET_LINK_LIBRARIES(couchstore_views ${COUCHSTORE_VIEW_LIBS})
134cf120adaSJim WalkerTARGET_INCLUDE_DIRECTORIES(couchstore_views PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include)
135cf120adaSJim Walker
136ec877c45SDave RigbyADD_EXECUTABLE(couch_dbdump
137ec877c45SDave Rigby               src/dbdump.cc
1385525660bSDave Rigby               src/tracking_file_ops.cc
139cf120adaSJim Walker               $<TARGET_OBJECTS:couchstore_objs>
140cf120adaSJim Walker               $<TARGET_OBJECTS:couchstore_view_objs>
141ec877c45SDave Rigby               ${KVEngineAPI_BINARY_DIR}/xattr/visibility.h)
142ec877c45SDave Rigby
14382fff8edSTrond NorbyeSET_TARGET_PROPERTIES(couch_dbdump PROPERTIES COMPILE_FLAGS "-DLIBCOUCHSTORE_NO_VISIBILITY=1")
144aca76c86SDave RigbyTARGET_INCLUDE_DIRECTORIES(couch_dbdump
1452fc71585SJim Walker                           PRIVATE
1462fc71585SJim Walker                           ${CMAKE_CURRENT_BINARY_DIR}/include
1472fc71585SJim Walker                           ${FLATBUFFERS_INCLUDE_DIR})
1482fc71585SJim Walker
1492fc71585SJim WalkerTARGET_LINK_LIBRARIES(couch_dbdump
150b2c362c6SDave Rigby                      mcbp
1512fc71585SJim Walker                      xattr
1522fc71585SJim Walker                      ${FLATBUFFERS_LIBRARIES}
153cf120adaSJim Walker                      ep-engine_collections
154cf120adaSJim Walker                      ${COUCHSTORE_VIEW_LIBS})
1550c640a13STrond Norbye
1561edc19a9SJung-Sang AhnADD_EXECUTABLE(couch_dbck src/dbck.cc)
1571edc19a9SJung-Sang AhnTARGET_LINK_LIBRARIES(couch_dbck couchstore platform)
1581edc19a9SJung-Sang Ahn
1590a34f4b2SJung-Sang AhnADD_EXECUTABLE(couch_dbinfo src/dbinfo.cc)
16033c63ffeSTrond NorbyeTARGET_LINK_LIBRARIES(couch_dbinfo couchstore platform)
1610c640a13STrond Norbye
1620a34f4b2SJung-Sang AhnADD_EXECUTABLE(couch_compact src/compactor.cc)
1630c640a13STrond NorbyeTARGET_LINK_LIBRARIES(couch_compact couchstore)
1640c640a13STrond Norbye
165c4656abcSAman AchpalADD_EXECUTABLE(couch_view_file_merger src/views/bin/couch_view_file_merger.cc src/views/bin/util.cc)
166cf120adaSJim WalkerTARGET_LINK_LIBRARIES(couch_view_file_merger couchstore_views dirutils)
1670c640a13STrond Norbye
168c4656abcSAman AchpalADD_EXECUTABLE(couch_view_index_builder src/views/bin/couch_view_index_builder.cc src/views/bin/util.cc)
169cf120adaSJim WalkerTARGET_LINK_LIBRARIES(couch_view_index_builder couchstore_views dirutils)
170cf120adaSJim WalkerTARGET_INCLUDE_DIRECTORIES(couch_view_index_builder PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include)
1710c640a13STrond Norbye
172c4656abcSAman AchpalADD_EXECUTABLE(couch_view_group_cleanup src/views/bin/couch_view_group_cleanup.cc src/views/bin/util.cc)
173cf120adaSJim WalkerTARGET_LINK_LIBRARIES(couch_view_group_cleanup couchstore_views dirutils)
174cf120adaSJim WalkerTARGET_INCLUDE_DIRECTORIES(couch_view_group_cleanup PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include)
175f2d99791SSarath Lakshman
176c4656abcSAman AchpalADD_EXECUTABLE(couch_view_index_updater src/views/bin/couch_view_index_updater.cc src/views/bin/util.cc)
177cf120adaSJim WalkerTARGET_LINK_LIBRARIES(couch_view_index_updater couchstore_views dirutils)
178cf120adaSJim WalkerTARGET_INCLUDE_DIRECTORIES(couch_view_index_updater PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include)
179ee29f96bSSarath Lakshman
180c4656abcSAman AchpalADD_EXECUTABLE(couch_view_group_compactor src/views/bin/couch_view_group_compactor.cc src/views/bin/util.cc)
181cf120adaSJim WalkerTARGET_LINK_LIBRARIES(couch_view_group_compactor couchstore_views dirutils)
182cf120adaSJim WalkerTARGET_INCLUDE_DIRECTORIES(couch_view_group_compactor PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include)
183cc98f867SSarath Lakshman
18430b18fb0SJim WalkerADD_EXECUTABLE(couch_create src/couch_create.cc src/crc32.cc)
18530b18fb0SJim WalkerTARGET_LINK_LIBRARIES(couch_create couchstore platform)
186cf120adaSJim WalkerTARGET_INCLUDE_DIRECTORIES(couch_create PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include)
18730b18fb0SJim Walker
188ae717639STrond NorbyeIF (INSTALL_HEADER_FILES)
1896212a318STrond Norbye   INSTALL(FILES
1906212a318STrond Norbye           include/libcouchstore/couch_db.h
1916212a318STrond Norbye           include/libcouchstore/couch_index.h
1926212a318STrond Norbye           include/libcouchstore/couch_common.h
1936212a318STrond Norbye           include/libcouchstore/error.h
1946212a318STrond Norbye           include/libcouchstore/file_ops.h
1956212a318STrond Norbye           include/libcouchstore/visibility.h
1966212a318STrond Norbye           DESTINATION include/libcouchstore)
197ae717639STrond NorbyeENDIF(INSTALL_HEADER_FILES)
1980c640a13STrond Norbye
1990c640a13STrond NorbyeINSTALL(TARGETS couchstore
200cf120adaSJim Walker                couchstore_views
2010c640a13STrond Norbye        RUNTIME DESTINATION bin
2020c640a13STrond Norbye        LIBRARY DESTINATION lib
2030c640a13STrond Norbye        ARCHIVE DESTINATION lib)
2040c640a13STrond Norbye
2057d6bc22aSMike WiederholdIF (APPLE)
2067d6bc22aSMike Wiederhold    SET_TARGET_PROPERTIES(couchstore
2077d6bc22aSMike Wiederhold                          PROPERTIES
2087d6bc22aSMike Wiederhold                          INSTALL_RPATH "@loader_path")
2097d6bc22aSMike WiederholdENDIF (APPLE)
2107d6bc22aSMike Wiederhold
2110c640a13STrond NorbyeINSTALL(TARGETS couch_dbdump
2120c640a13STrond Norbye                couch_dbinfo
2131edc19a9SJung-Sang Ahn                couch_dbck
2140c640a13STrond Norbye                couch_compact
2150c640a13STrond Norbye                couch_view_file_merger
2160c640a13STrond Norbye                couch_view_index_builder
217f2d99791SSarath Lakshman                couch_view_group_cleanup
218ee29f96bSSarath Lakshman                couch_view_index_updater
219cc98f867SSarath Lakshman                couch_view_group_compactor
2200c640a13STrond Norbye        RUNTIME DESTINATION bin)
2210c640a13STrond Norbye
2220c640a13STrond NorbyeCONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.cmake.h.in
22316707513STrond Norbye               ${CMAKE_CURRENT_BINARY_DIR}/couchstore_config.h)
2240c640a13STrond Norbye
2250c640a13STrond Norbye# Tests:
2264d037946STrond Norbyeif (COUCHBASE_COUCHSTORE_BUILD_UNIT_TESTS)
2274d037946STrond Norbye    IF (LUA_FOUND)
2284d037946STrond Norbye        ADD_EXECUTABLE(couchscript src/couchscript.cc)
2294d037946STrond Norbye        SET_TARGET_PROPERTIES(couchscript PROPERTIES COMPILE_FLAGS
2304d037946STrond Norbye                              -I${LUA_INCLUDE_DIR})
2314d037946STrond Norbye        TARGET_LINK_LIBRARIES(couchscript couchstore ${LUA_LIBRARIES})
2324d037946STrond Norbye
2334d037946STrond Norbye        ADD_TEST(couchstore-localdoc
2344d037946STrond Norbye                 couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/localdoc.lua)
2354d037946STrond Norbye        ADD_TEST(couchstore-corrupt
2364d037946STrond Norbye                 couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/corrupt.lua)
2374d037946STrond Norbye        ADD_TEST(couchstore-bulk
2384d037946STrond Norbye                 couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/bulk.lua)
2394d037946STrond Norbye        ADD_TEST(couchstore-changes-since-filter
2404d037946STrond Norbye                 couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/changessincefilter.lua)
2414d037946STrond Norbye        ADD_TEST(couchstore-compact
2424d037946STrond Norbye                 couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/compact.lua)
2434d037946STrond Norbye        ADD_TEST(couchstore-dropdel
2444d037946STrond Norbye                 couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/dropdel.lua)
2454d037946STrond Norbye        ADD_TEST(couchstore-largefile
2464d037946STrond Norbye                 couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/largefile.lua)
2474d037946STrond Norbye        ADD_TEST(couchstore-large
2484d037946STrond Norbye                 couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/large.lua)
2494d037946STrond Norbye    ENDIF (LUA_FOUND)
2504d037946STrond Norbye
2514d037946STrond Norbye    MACRO(M_ADD_PYTHON_TEST name pyfile)
2524d037946STrond Norbye        ADD_TEST(${name} python ${pyfile})
2534d037946STrond Norbye        SET_PROPERTY(TEST ${name} PROPERTY ENVIRONMENT
2544d037946STrond Norbye                     "PYTHONPATH=${CMAKE_CURRENT_SOURCE_DIR}/python"
2554d037946STrond Norbye                     "LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}")
2564d037946STrond Norbye    ENDMACRO()
2574d037946STrond Norbye
2584d037946STrond Norbye    M_ADD_PYTHON_TEST(couchstore-purge ${CMAKE_CURRENT_SOURCE_DIR}/tests/purge.py)
2594d037946STrond Norbye    M_ADD_PYTHON_TEST(couchstore-rewind ${CMAKE_CURRENT_SOURCE_DIR}/tests/rewind.py)
2604d037946STrond Norbye    M_ADD_PYTHON_TEST(couchstore-changecount ${CMAKE_CURRENT_SOURCE_DIR}/tests/changecount.py)
2614d037946STrond Norbye
2624d037946STrond Norbye    MACRO(M_MAKE_LEGACY_TEST name)
2634d037946STrond Norbye        ADD_EXECUTABLE(${name} ${ARGN})
2644d037946STrond Norbye        SET_TARGET_PROPERTIES(${name} PROPERTIES
265cf120adaSJim Walker                              COMPILE_FLAGS "-DLIBCOUCHSTORE_NO_VISIBILITY=1")
266cf120adaSJim Walker        TARGET_LINK_LIBRARIES(${name} couchstore couchstore_views dirutils)
267cf120adaSJim Walker        TARGET_INCLUDE_DIRECTORIES(${name} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include)
2684d037946STrond Norbye    ENDMACRO()
2694d037946STrond Norbye
2704d037946STrond Norbye    M_MAKE_LEGACY_TEST(couchstore_file-deduper-test
2714d037946STrond Norbye                       src/file_merger.cc
2724d037946STrond Norbye                       tests/file_deduper_tests.cc)
2731b613a6bSAaron Miller
2744d037946STrond Norbye    M_MAKE_LEGACY_TEST(couchstore_file-merger-test
2754d037946STrond Norbye                       src/file_merger.cc
2764d037946STrond Norbye                       tests/file_merger_tests.cc)
277bcc4d4baSWill Gardner
2784d037946STrond Norbye    M_MAKE_LEGACY_TEST(couchstore_file-sorter-test
2794d037946STrond Norbye                       src/file_merger.cc
2804d037946STrond Norbye                       src/file_name_utils.c
2814d037946STrond Norbye                       src/file_sorter.cc
2824d037946STrond Norbye                       src/quicksort.c
2834d037946STrond Norbye                       tests/file_sorter_tests.c)
284f7ebb47eSWill Gardner
2854d037946STrond Norbye    SET(MAP_REDUCE_SOURCES
2864d037946STrond Norbye        src/views/mapreduce/mapreduce.cc
2874d037946STrond Norbye        src/views/mapreduce/mapreduce_c.cc)
288bcc4d4baSWill Gardner
2894d037946STrond Norbye    M_MAKE_LEGACY_TEST(couchstore_mapreduce-builtin-test
2904d037946STrond Norbye                       ${MAP_REDUCE_SOURCES}
2914d037946STrond Norbye                       tests/mapreduce/builtin.c)
2924d037946STrond Norbye
2934d037946STrond Norbye    M_MAKE_LEGACY_TEST(couchstore_mapreduce-map-test
2944d037946STrond Norbye                       ${MAP_REDUCE_SOURCES}
2954d037946STrond Norbye                       tests/mapreduce/map.c)
2964d037946STrond Norbye
2974d037946STrond Norbye    M_MAKE_LEGACY_TEST(couchstore_mapreduce-reduce-test
2984d037946STrond Norbye                       ${MAP_REDUCE_SOURCES}
2994d037946STrond Norbye                       tests/mapreduce/reduce.c)
3004d037946STrond Norbye
3014d037946STrond Norbye    ADD_EXECUTABLE(couchstore_testapp
3024d037946STrond Norbye                   tests/testapp.c
3034d037946STrond Norbye                   tests/views/tests.cc
3044d037946STrond Norbye                   tests/views/collate_json_test.cc
3054d037946STrond Norbye                   tests/views/index_headers.cc
3064d037946STrond Norbye                   tests/views/bitmaps.cc
3074d037946STrond Norbye                   tests/views/sorted_lists.cc
3084d037946STrond Norbye                   tests/views/reductions.cc
3094d037946STrond Norbye                   tests/views/keys.cc
3104d037946STrond Norbye                   tests/views/values.cc
3114d037946STrond Norbye                   tests/views/reducers.cc
3124d037946STrond Norbye                   tests/views/cleanup.cc
3134d037946STrond Norbye                   tests/views/spatial.cc
3144d037946STrond Norbye                   tests/btree_purge/purge_tests.h
3154d037946STrond Norbye                   tests/btree_purge/tests.cc
3164d037946STrond Norbye                   tests/btree_purge/purge.cc
317cf120adaSJim Walker                   $<TARGET_OBJECTS:couchstore_objs>
318cf120adaSJim Walker                   $<TARGET_OBJECTS:couchstore_view_objs>)
3194d037946STrond Norbye    SET_TARGET_PROPERTIES(couchstore_testapp PROPERTIES
320cf120adaSJim Walker                         COMPILE_FLAGS "-DLIBCOUCHSTORE_NO_VISIBILITY=1")
3214d037946STrond Norbye    TARGET_INCLUDE_DIRECTORIES(couchstore_testapp
3224d037946STrond Norbye                               PRIVATE
3234d037946STrond Norbye                               ${CMAKE_CURRENT_BINARY_DIR}/include)
324cf120adaSJim Walker    TARGET_LINK_LIBRARIES(couchstore_testapp ${COUCHSTORE_VIEW_LIBS})
325cf120adaSJim Walker    SET(COUCHSTORE_GTEST_LIBRARIES gtest gtest_main gmock phosphor)
326cf120adaSJim Walker    SET(COUCHSTORE_GTEST_INCLUDES ${gtest_SOURCE_DIR}/include ${gmock_SOURCE_DIR}/include)
3274d037946STrond Norbye    ADD_EXECUTABLE(couchstore_gtest
3284d037946STrond Norbye                   tests/couchstoretest.cc
3294d037946STrond Norbye                   tests/documents.cc
3304d037946STrond Norbye                   tests/gtest_tests.cc
3314d037946STrond Norbye                   tests/test_fileops.cc
3324d037946STrond Norbye                   src/node_types.cc
333cfc9f88eSsduvuru                   src/crc32.cc
3344d037946STrond Norbye                   ${COUCHSTORE_FILE_OPS})
3354d037946STrond Norbye    SET_TARGET_PROPERTIES(couchstore_gtest PROPERTIES
336cf120adaSJim Walker                          COMPILE_FLAGS "-DLIBCOUCHSTORE_NO_VISIBILITY=1")
3374d037946STrond Norbye    TARGET_INCLUDE_DIRECTORIES(couchstore_gtest PRIVATE ${COUCHSTORE_GTEST_INCLUDES})
3384d037946STrond Norbye    TARGET_LINK_LIBRARIES(couchstore_gtest couchstore ${COUCHSTORE_GTEST_LIBRARIES})
3394d037946STrond Norbye
3404d037946STrond Norbye    ADD_EXECUTABLE(couchstore_internal_gtest
3414d037946STrond Norbye                   tests/couchstoretest.cc
3424d037946STrond Norbye                   tests/documents.cc
3434d037946STrond Norbye                   tests/gtest_internal_tests.cc
3444d037946STrond Norbye                   tests/test_fileops.cc
345cf120adaSJim Walker                   $<TARGET_OBJECTS:couchstore_objs>)
3464d037946STrond Norbye    SET_TARGET_PROPERTIES(couchstore_internal_gtest PROPERTIES
347cf120adaSJim Walker                          COMPILE_FLAGS "-DLIBCOUCHSTORE_NO_VISIBILITY=1")
3484d037946STrond Norbye    TARGET_INCLUDE_DIRECTORIES(couchstore_internal_gtest
3494d037946STrond Norbye                               PRIVATE
3504d037946STrond Norbye                               ${CMAKE_CURRENT_BINARY_DIR}/include)
351cf120adaSJim Walker
3524d037946STrond Norbye    TARGET_LINK_LIBRARIES(couchstore_internal_gtest
3534d037946STrond Norbye                          ${COUCHSTORE_GTEST_LIBRARIES}
354cf120adaSJim Walker                          ${COUCHSTORE_LIBS})
3554d037946STrond Norbye
3564d037946STrond Norbye    # This is an object library and can be used for verifying
3574d037946STrond Norbye    # FileOpsInterface implementations that wrap other FileOps
3584d037946STrond Norbye    # propogate errors correctly.
3594d037946STrond Norbye    #
3604d037946STrond Norbye    # Example usage can be found in tests/wrapped_fileops_test.cc
3614d037946STrond Norbye    ADD_LIBRARY(couchstore_wrapped_fileops_test_framework OBJECT
3624d037946STrond Norbye                tests/test_fileops.cc
3634d037946STrond Norbye                ${COUCHSTORE_FILE_OPS})
3644d037946STrond Norbye    SET_TARGET_PROPERTIES(couchstore_wrapped_fileops_test_framework PROPERTIES
365cf120adaSJim Walker                          COMPILE_FLAGS "-DLIBCOUCHSTORE_NO_VISIBILITY=1")
3664d037946STrond Norbye    TARGET_INCLUDE_DIRECTORIES(couchstore_wrapped_fileops_test_framework
3674d037946STrond Norbye                               PRIVATE
3684d037946STrond Norbye                               ${COUCHSTORE_GTEST_INCLUDES}
3694d037946STrond Norbye                               ${CMAKE_CURRENT_BINARY_DIR}/include)
3704d037946STrond Norbye    TARGET_LINK_LIBRARIES(couchstore_wrapped_fileops_test_framework platform)
3714d037946STrond Norbye
3724d037946STrond Norbye    ADD_EXECUTABLE(couchstore_wrapped_fileops_test
3734d037946STrond Norbye                   src/iobuffer.cc
374cfc9f88eSsduvuru                   src/crc32.cc
3754d037946STrond Norbye                   tests/wrapped_fileops_test.cc
3764d037946STrond Norbye                   $<TARGET_OBJECTS:couchstore_wrapped_fileops_test_framework>)
3774d037946STrond Norbye    SET_TARGET_PROPERTIES(couchstore_wrapped_fileops_test PROPERTIES
378cf120adaSJim Walker                          COMPILE_FLAGS "-DLIBCOUCHSTORE_NO_VISIBILITY=1")
3794d037946STrond Norbye    TARGET_INCLUDE_DIRECTORIES(couchstore_wrapped_fileops_test
3804d037946STrond Norbye                               PRIVATE
3814d037946STrond Norbye                               ${CMAKE_CURRENT_BINARY_DIR}/include)
3824d037946STrond Norbye    TARGET_LINK_LIBRARIES(couchstore_wrapped_fileops_test ${COUCHSTORE_GTEST_LIBRARIES} platform)
3834d037946STrond Norbye
3844d037946STrond Norbye    ADD_LIBRARY(couchstore_test_fileops OBJECT
3854d037946STrond Norbye                tests/test_fileops.cc)
3864d037946STrond Norbye    TARGET_INCLUDE_DIRECTORIES(couchstore_test_fileops
3874d037946STrond Norbye                               PRIVATE
3884d037946STrond Norbye                               ${COUCHSTORE_GTEST_INCLUDES}
3894d037946STrond Norbye                               ${CMAKE_CURRENT_BINARY_DIR}/include)
3904d037946STrond Norbye    TARGET_LINK_LIBRARIES(couchstore_test_fileops platform)
3914d037946STrond Norbye
3924d037946STrond Norbye    ADD_TEST(couchstore-file-deduper-test couchstore_file-deduper-test)
3934d037946STrond Norbye    ADD_TEST(couchstore-file-merge-test couchstore_file-merger-test)
3944d037946STrond Norbye    ADD_TEST(couchstore-file-sorter-test couchstore_file-sorter-test)
3954d037946STrond Norbye    ADD_TEST(couchstore-gtest couchstore_gtest)
3964d037946STrond Norbye    ADD_TEST(couchstore-internal-gtest couchstore_internal_gtest)
3974d037946STrond Norbye    ADD_TEST(NAME couchstore-mapreduce-builtin-test COMMAND couchstore_mapreduce-builtin-test ${CMAKE_INSTALL_PREFIX}/bin/)
3984d037946STrond Norbye    ADD_TEST(NAME couchstore-mapreduce-map-test COMMAND couchstore_mapreduce-map-test ${CMAKE_INSTALL_PREFIX}/bin/)
3994d037946STrond Norbye    ADD_TEST(NAME couchstore-mapreduce-reduce-test COMMAND couchstore_mapreduce-reduce-test ${CMAKE_INSTALL_PREFIX}/bin/)
4004d037946STrond Norbye    ADD_TEST(NAME couchstore-testapp COMMAND couchstore_testapp ${CMAKE_INSTALL_PREFIX}/bin/)
4014d037946STrond Norbye    ADD_TEST(couchstore-wrapped_fileops-test couchstore_wrapped_fileops_test)
4024d037946STrond Norbyeendif(COUCHBASE_COUCHSTORE_BUILD_UNIT_TESTS)
403bcc4d4baSWill Gardner
40438a4c08aSTrond NorbyeADD_SUBDIRECTORY(programs)
4050b948c55SWill Gardner
4060b948c55SWill GardnerENABLE_CODE_COVERAGE_REPORT()
407