xref: /5.5.2/kv_engine/engines/ep/CMakeLists.txt (revision 075614a6)
1CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
2PROJECT(EventuallyPersistentEngine LANGUAGES CXX)
3
4INCLUDE(CheckFunctionExists)
5INCLUDE(CheckIncludeFileCXX)
6INCLUDE(CheckIncludeFiles)
7INCLUDE(CheckLibraryExists)
8INCLUDE(CheckSymbolExists)
9INCLUDE(CheckTypeSize)
10INCLUDE(CMakeDependentOption)
11INCLUDE(CTest)
12
13CMAKE_DEPENDENT_OPTION(EP_USE_ROCKSDB "Enable support for RocksDB" ON
14        "ROCKSDB_INCLUDE_DIR;ROCKSDB_LIBRARIES" OFF)
15
16INCLUDE_DIRECTORIES(BEFORE ${CMAKE_INSTALL_PREFIX}/include
17                           ${CMAKE_CURRENT_SOURCE_DIR}
18                           ${CMAKE_CURRENT_SOURCE_DIR}/src
19                           ${CMAKE_CURRENT_BINARY_DIR}/src
20                           ${BOOST_INCLUDE_DIR}
21                           ${SNAPPY_INCLUDE_DIR}
22                           ${BOOST_INCLUDE_DIR}
23                           ${Platform_SOURCE_DIR}/include
24                           ${Platform_SOURCE_DIR}/external
25                           ${Memcached_SOURCE_DIR}
26                           ${Memcached_SOURCE_DIR}/utilities
27                           ${Memcached_SOURCE_DIR}/tracing
28                           ${Memcached_SOURCE_DIR}/include
29                           ${Couchstore_SOURCE_DIR}/include
30                           ${Couchstore_BINARY_DIR}/include
31                           ${phosphor_SOURCE_DIR}/include
32                           ${CMAKE_CURRENT_BINARY_DIR})
33
34# Mark third-party libraries as 'system' so we skip any warnings they
35# generate.
36INCLUDE_DIRECTORIES(BEFORE SYSTEM ${hdr_histogram_SOURCE_DIR}/src)
37
38INCLUDE_DIRECTORIES(AFTER ${Memcached_BINARY_DIR}/include)
39
40SET(EP_STORAGE_LIBS couchstore)
41
42IF (EP_USE_ROCKSDB)
43    INCLUDE_DIRECTORIES(AFTER ${ROCKSDB_INCLUDE_DIR})
44    SET(ROCKSDB_KVSTORE_SOURCE src/rocksdb-kvstore/rocksdb-kvstore.cc
45        src/rocksdb-kvstore/rocksdb-kvstore_config.cc)
46    LIST(APPEND EP_STORAGE_LIBS ${ROCKSDB_LIBRARIES})
47    ADD_DEFINITIONS(-DEP_USE_ROCKSDB=1)
48    MESSAGE(STATUS "ep-engine: Using RocksDB")
49ENDIF (EP_USE_ROCKSDB)
50
51INCLUDE_DIRECTORIES(AFTER SYSTEM
52                    ${gtest_SOURCE_DIR}/include
53                    ${gmock_SOURCE_DIR}/include)
54
55CHECK_INCLUDE_FILES("arpa/inet.h" HAVE_ARPA_INET_H)
56CHECK_INCLUDE_FILES("unistd.h" HAVE_UNISTD_H)
57CHECK_INCLUDE_FILES("netdb.h" HAVE_NETDB_H)
58CHECK_INCLUDE_FILES("poll.h" HAVE_POLL_H)
59CHECK_INCLUDE_FILES("unistd.h" HAVE_UNISTD_H)
60CHECK_INCLUDE_FILES("sys/socket.h" HAVE_SYS_SOCKET_H)
61CHECK_INCLUDE_FILES("sys/time.h" HAVE_SYS_TIME_H)
62CHECK_INCLUDE_FILES("netinet/in.h" HAVE_NETINET_IN_H)
63CHECK_INCLUDE_FILES("netinet/tcp.h" HAVE_NETINET_TCP_H)
64
65# For debugging without compiler optimizations uncomment line below..
66#SET (CMAKE_BUILD_TYPE DEBUG)
67
68SET(EP_ENGINE_VERSION "${MEMCACHED_VERSION}")
69
70CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/src/config.cmake.h
71                ${CMAKE_CURRENT_BINARY_DIR}/src/config.h)
72
73# Generate the python wrappers
74CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/wrapper/wrapper
75                ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbepctl)
76CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/wrapper/wrapper
77                ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbstats)
78CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/wrapper/wrapper
79                ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbcompact)
80CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/wrapper/wrapper
81                ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbvdiff)
82CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/wrapper/wrapper
83                ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbvbucketctl)
84CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/wrapper/wrapper
85                ${CMAKE_CURRENT_BINARY_DIR}/wrapper/kv_trace_dump)
86
87SET(Python_ADDITIONAL_VERSIONS 2.6)
88FIND_PACKAGE(PythonInterp)
89
90# to avoid cluttering source dir with name + "c" files
91SET(ENV{PYTHONDONTWRITEBYTECODE} 1)
92
93if (COUCHBASE_KV_BUILD_UNIT_TESTS)
94    # runs cbstats & cbepctl - will fail on basic syntax errors
95    ADD_TEST(NAME cbstats_test
96             COMMAND ${PYTHON_EXECUTABLE}
97             ${CMAKE_CURRENT_SOURCE_DIR}/management/cbstats --help)
98    ADD_TEST(NAME cbepctl_test
99             COMMAND ${PYTHON_EXECUTABLE}
100             ${CMAKE_CURRENT_SOURCE_DIR}/management/cbepctl --help)
101    ADD_TEST(NAME kv_trace_dump_test
102             COMMAND ${PYTHON_EXECUTABLE}
103             ${CMAKE_CURRENT_SOURCE_DIR}/management/kv_trace_dump --help)
104endif (COUCHBASE_KV_BUILD_UNIT_TESTS)
105
106IF (WIN32)
107   INCLUDE_DIRECTORIES(AFTER ${CMAKE_SOURCE_DIR}/platform/include/win32)
108ENDIF (WIN32)
109
110ADD_EXECUTABLE(gencode tools/gencode.cc)
111TARGET_LINK_LIBRARIES(gencode cJSON platform)
112
113ADD_EXECUTABLE(genconfig tools/genconfig.cc)
114TARGET_LINK_LIBRARIES(genconfig cJSON platform)
115
116ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/stats-info.c
117                          ${CMAKE_CURRENT_BINARY_DIR}/src/stats-info.h
118                  COMMAND
119                     gencode -j ${CMAKE_CURRENT_SOURCE_DIR}/docs/stats.json -h ${CMAKE_CURRENT_BINARY_DIR}/src/stats-info.h -c ${CMAKE_CURRENT_BINARY_DIR}/src/stats-info.c -f get_stats_info
120                  DEPENDS
121                        docs/stats.json
122                        gencode
123                  COMMENT "Generating code for stats info")
124
125ADD_CUSTOM_COMMAND(OUTPUT
126                     src/generated_configuration.cc.temp
127                     src/generated_configuration.h.temp
128                  COMMAND
129                     genconfig ${CMAKE_CURRENT_SOURCE_DIR}/configuration.json src/generated_configuration.h.temp src/generated_configuration.cc.temp
130                  DEPENDS
131                        configuration.json
132                        genconfig
133                  COMMENT "Generating code for configuration class")
134
135ADD_CUSTOM_COMMAND(OUTPUT
136                     src/generated_configuration.cc
137                     src/generated_configuration.h
138                  COMMAND
139                     ${CMAKE_COMMAND} -E copy_if_different src/generated_configuration.cc.temp src/generated_configuration.cc
140                  COMMAND
141                     ${CMAKE_COMMAND} -E copy_if_different src/generated_configuration.h.temp src/generated_configuration.h
142                  DEPENDS
143                     src/generated_configuration.cc.temp
144                     src/generated_configuration.h.temp
145                  COMMENT "Copying code for configuration class")
146
147SET(COUCH_KVSTORE_SOURCE src/couch-kvstore/couch-kvstore.cc
148            src/couch-kvstore/couch-fs-stats.cc)
149SET(OBJECTREGISTRY_SOURCE src/objectregistry.cc)
150SET(CONFIG_SOURCE src/configuration.cc
151  ${CMAKE_CURRENT_BINARY_DIR}/src/generated_configuration.cc)
152
153SET(COLLECTIONS_SOURCE src/collections/collections_callbacks.cc
154                       src/collections/collections_dockey.cc
155                       src/collections/collections_types.cc
156                       src/collections/eraser_context.cc
157                       src/collections/filter.cc
158                       src/collections/manager.cc
159                       src/collections/manifest.cc
160                       src/collections/scan_context.cc
161                       src/collections/vbucket_filter.cc
162                       src/collections/vbucket_manifest.cc
163                       src/collections/vbucket_manifest_entry.cc)
164
165ADD_LIBRARY(ep_objs OBJECT
166            src/access_scanner.cc
167            src/atomic.cc
168            src/bgfetcher.cc
169            src/blob.cc
170            src/bloomfilter.cc
171            src/callbacks.cc
172            src/checkpoint.cc
173            src/checkpoint_config.cc
174            src/checkpoint_remover.cc
175            src/conflict_resolution.cc
176            src/connhandler.cc
177            src/connmap.cc
178            src/crc32.c
179            src/dcp/backfill.cc
180            src/dcp/backfill-manager.cc
181            src/dcp/backfill_disk.cc
182            src/dcp/backfill_memory.cc
183            src/dcp/consumer.cc
184            src/dcp/dcp-types.h
185            src/dcp/dcpconnmap.cc
186            src/dcp/flow-control.cc
187            src/dcp/flow-control-manager.cc
188            src/dcp/producer.cc
189            src/dcp/response.cc
190            src/dcp/stream.cc
191            src/defragmenter.cc
192            src/defragmenter_visitor.cc
193            src/ep_bucket.cc
194            src/ep_vb.cc
195            src/ep_engine.cc
196            src/ep_time.cc
197            src/ep_types.cc
198            src/ephemeral_bucket.cc
199            src/ephemeral_tombstone_purger.cc
200            src/ephemeral_vb.cc
201            src/ephemeral_vb_count_visitor.cc
202            src/executorpool.cc
203            src/executorthread.cc
204            src/ext_meta_parser.cc
205            src/failover-table.cc
206            src/flusher.cc
207            src/globaltask.cc
208            src/hash_table.cc
209            src/hdrhistogram.cc
210            src/hlc.cc
211            src/htresizer.cc
212            src/item.cc
213            src/item_compressor.cc
214            src/item_compressor_visitor.cc
215            src/item_eviction.cc
216            src/item_freq_decayer.cc
217            src/item_freq_decayer_visitor.cc
218            src/item_pager.cc
219            src/kvstore.cc
220            src/kvstore_config.cc
221            src/logger.cc
222            src/kv_bucket.cc
223            src/kvshard.cc
224            src/memory_tracker.cc
225            src/murmurhash3.cc
226            src/mutation_log.cc
227            src/mutation_log_entry.cc
228            src/persistence_callback.cc
229            src/pre_link_document_context.cc
230            src/pre_link_document_context.h
231            src/progress_tracker.cc
232            src/replicationthrottle.cc
233            src/linked_list.cc
234            src/seqlist.cc
235            src/stats.cc
236            src/string_utils.cc
237            src/storeddockey.cc
238            src/stored-value.cc
239            src/systemevent.cc
240            src/tasks.cc
241            src/taskqueue.cc
242            src/vb_count_visitor.cc
243            src/vb_visitors.cc
244            src/vbucket.cc
245            src/vbucketmap.cc
246            src/vbucketdeletiontask.cc
247            src/warmup.cc
248            ${OBJECTREGISTRY_SOURCE}
249            ${CMAKE_CURRENT_BINARY_DIR}/src/stats-info.c
250            ${CONFIG_SOURCE}
251            ${COUCH_KVSTORE_SOURCE}
252            ${ROCKSDB_KVSTORE_SOURCE}
253            ${COLLECTIONS_SOURCE})
254SET_PROPERTY(TARGET ep_objs PROPERTY POSITION_INDEPENDENT_CODE 1)
255add_sanitizers(ep_objs)
256
257ADD_LIBRARY(ep SHARED $<TARGET_OBJECTS:ep_objs>)
258
259SET_TARGET_PROPERTIES(ep PROPERTIES PREFIX "")
260TARGET_LINK_LIBRARIES(ep cJSON JSON_checker ${EP_STORAGE_LIBS}
261                      engine_utilities dirutils cbcompress hdr_histogram_static
262                      mcd_util platform phosphor xattr mcd_tracing
263                      ${LIBEVENT_LIBRARIES})
264add_sanitizers(ep)
265
266if (COUCHBASE_KV_BUILD_UNIT_TESTS)
267    # Single executable containing all class-level unit tests involving
268    # EventuallyPersistentEngine driven by GoogleTest.
269    # (We end up compiling most of the src/ files of ep-engine for these unit tests,
270    # so simpler / quicker just to link them into a single executable).
271    ADD_EXECUTABLE(ep-engine_ep_unit_tests
272                   tests/mock/mock_dcp.cc
273                   tests/mock/mock_dcp_producer.cc
274                   tests/mock/mock_ephemeral_vb.cc
275                   tests/mock/mock_synchronous_ep_engine.cc
276                   tests/module_tests/atomic_unordered_map_test.cc
277                   tests/module_tests/basic_ll_test.cc
278                   tests/module_tests/bloomfilter_test.cc
279                   tests/module_tests/checkpoint_remover_test.h
280                   tests/module_tests/checkpoint_remover_test.cc
281                   tests/module_tests/checkpoint_test.h
282                   tests/module_tests/checkpoint_test.cc
283                   tests/module_tests/checkpoint_utils.h
284                   tests/module_tests/collections/collection_dockey_test.cc
285                   tests/module_tests/collections/evp_store_collections_dcp_test.cc
286                   tests/module_tests/collections/evp_store_collections_eraser_test.cc
287                   tests/module_tests/collections/evp_store_collections_test.cc
288                   tests/module_tests/collections/filter_test.cc
289                   tests/module_tests/collections/manifest_test.cc
290                   tests/module_tests/collections/vbucket_manifest_test.cc
291                   tests/module_tests/collections/vbucket_manifest_entry_test.cc
292                   tests/module_tests/configuration_test.cc
293                   tests/module_tests/defragmenter_test.cc
294                   tests/module_tests/dcp_reflection_test.cc
295                   tests/module_tests/dcp_test.cc
296                   tests/module_tests/dcp_utils.cc
297                   tests/module_tests/ep_unit_tests_main.cc
298                   tests/module_tests/ephemeral_bucket_test.cc
299                   tests/module_tests/ephemeral_vb_test.cc
300                   tests/module_tests/evp_engine_test.cc
301                   tests/module_tests/evp_store_rollback_test.cc
302                   tests/module_tests/evp_store_test.cc
303                   tests/module_tests/evp_store_single_threaded_test.cc
304                   tests/module_tests/evp_store_with_meta.cc
305                   tests/module_tests/executorpool_test.cc
306                   tests/module_tests/failover_table_test.cc
307                   tests/module_tests/futurequeue_test.cc
308                   tests/module_tests/hash_table_eviction_test.cc
309                   tests/module_tests/hash_table_test.cc
310                   tests/module_tests/hdrhistogram_test.cc
311                   tests/module_tests/item_compressor_test.cc
312                   tests/module_tests/item_eviction_test.cc
313                   tests/module_tests/item_pager_test.cc
314                   tests/module_tests/item_test.cc
315                   tests/module_tests/kvstore_test.cc
316                   tests/module_tests/kv_bucket_test.cc
317                   tests/module_tests/memory_tracker_test.cc
318                   tests/module_tests/mock_hooks_api.cc
319                   tests/module_tests/monotonic_test.cc
320                   tests/module_tests/mutation_log_test.cc
321                   tests/module_tests/objectregistry_test.cc
322                   tests/module_tests/mutex_test.cc
323                   tests/module_tests/probabilistic_counter_test.cc
324                   tests/module_tests/stats_test.cc
325                   tests/module_tests/storeddockey_test.cc
326                   tests/module_tests/stored_value_test.cc
327                   tests/module_tests/systemevent_test.cc
328                   tests/module_tests/tagged_ptr_test.cc
329                   tests/module_tests/test_helpers.cc
330                   tests/module_tests/vbucket_test.cc
331                   tests/module_tests/warmup_test.cc
332                   $<TARGET_OBJECTS:ep_objs>
333                   $<TARGET_OBJECTS:memory_tracking>
334                   $<TARGET_OBJECTS:couchstore_test_fileops>
335                   ${Memcached_SOURCE_DIR}/programs/engine_testapp/mock_server.cc
336                   ${Memcached_SOURCE_DIR}/daemon/doc_pre_expiry.cc
337                   ${Memcached_SOURCE_DIR}/daemon/protocol/mcbp/engine_errc_2_mcbp.cc)
338
339    TARGET_INCLUDE_DIRECTORIES(ep-engine_ep_unit_tests
340                               PUBLIC
341                               ${Couchstore_SOURCE_DIR})
342
343    TARGET_LINK_LIBRARIES(ep-engine_ep_unit_tests ${EP_STORAGE_LIBS} cJSON
344                          dirutils engine_utilities gtest gmock hdr_histogram_static
345                          JSON_checker memcached_logger mcd_util mcd_tracing platform
346                          phosphor xattr cbcompress ${MALLOC_LIBRARIES})
347    add_sanitizers(ep-engine_ep_unit_tests)
348
349    ADD_EXECUTABLE(ep-engine_atomic_ptr_test
350                   tests/module_tests/atomic_ptr_test.cc
351                   src/atomic.cc
352                   src/testlogger.cc)
353    TARGET_LINK_LIBRARIES(ep-engine_atomic_ptr_test platform)
354
355    ADD_EXECUTABLE(ep-engine_couch-fs-stats_test
356                   src/couch-kvstore/couch-fs-stats.cc
357                   src/generated_configuration.h
358                   tests/module_tests/couch-fs-stats_test.cc
359                   $<TARGET_OBJECTS:couchstore_wrapped_fileops_test_framework>)
360    TARGET_INCLUDE_DIRECTORIES(ep-engine_couch-fs-stats_test
361                               PRIVATE
362                               ${Couchstore_SOURCE_DIR}
363                               ${Couchstore_SOURCE_DIR}/src)
364    TARGET_LINK_LIBRARIES(ep-engine_couch-fs-stats_test gtest gtest_main gmock platform)
365
366    ADD_EXECUTABLE(ep-engine_misc_test tests/module_tests/misc_test.cc)
367    TARGET_LINK_LIBRARIES(ep-engine_misc_test platform)
368
369    ADD_EXECUTABLE(ep-engine_string_utils_test
370                   tests/module_tests/string_utils_test.cc
371                   src/string_utils.cc)
372    TARGET_LINK_LIBRARIES(ep-engine_string_utils_test gtest gtest_main platform)
373
374    ADD_EXECUTABLE(ep_engine_benchmarks
375                   benchmarks/access_scanner_bench.cc
376                   benchmarks/benchmark_memory_tracker.cc
377                   benchmarks/defragmenter_bench.cc
378                   benchmarks/engine_fixture.cc
379                   benchmarks/ep_engine_benchmarks_main.cc
380                   benchmarks/item_bench.cc
381                   benchmarks/item_compressor_bench.cc
382                   benchmarks/kvstore_bench.cc
383                   benchmarks/mem_allocator_stats_bench.cc
384                   benchmarks/vbucket_bench.cc
385                   benchmarks/probabilistic_counter_bench.cc
386                   tests/mock/mock_synchronous_ep_engine.cc
387                   $<TARGET_OBJECTS:ep_objs>
388                   $<TARGET_OBJECTS:memory_tracking>
389                   $<TARGET_OBJECTS:couchstore_test_fileops>
390                   ${Memcached_SOURCE_DIR}/programs/engine_testapp/mock_server.cc
391                   ${Memcached_SOURCE_DIR}/daemon/doc_pre_expiry.cc
392                   ${Memcached_SOURCE_DIR}/daemon/protocol/mcbp/engine_errc_2_mcbp.cc
393                   ${Memcached_SOURCE_DIR}/engines/ep/tests/module_tests/test_helpers.cc)
394
395    TARGET_LINK_LIBRARIES(ep_engine_benchmarks PRIVATE
396            benchmark
397            cbcompress
398            cJSON
399            dirutils
400            engine_utilities
401            gtest
402            gmock
403            hdr_histogram_static
404            JSON_checker
405            mcd_util
406            mcd_tracing
407            memcached_logger
408            phosphor
409            platform
410            xattr
411            ${MALLOC_LIBRARIES}
412            ${EP_STORAGE_LIBS})
413    TARGET_INCLUDE_DIRECTORIES(ep_engine_benchmarks PUBLIC
414                               ${benchmark_SOURCE_DIR}/include
415                               tests
416                               benchmarks
417                               ${Couchstore_SOURCE_DIR})
418    add_sanitizers(ep_engine_benchmarks)
419
420    ADD_TEST(NAME ep-engine_atomic_ptr_test COMMAND ep-engine_atomic_ptr_test)
421    ADD_TEST(NAME ep-engine_couch-fs-stats_test COMMAND ep-engine_couch-fs-stats_test)
422    ADD_TEST(NAME ep-engine_ep_unit_tests COMMAND ep-engine_ep_unit_tests)
423    ADD_TEST(NAME ep-engine_misc_test COMMAND ep-engine_misc_test)
424
425    ADD_LIBRARY(timing_tests SHARED tests/module_tests/timing_tests.cc)
426    SET_TARGET_PROPERTIES(timing_tests PROPERTIES PREFIX "")
427    TARGET_LINK_LIBRARIES(timing_tests platform)
428
429    ADD_EXECUTABLE(ep-engine_sizes src/sizes.cc
430                   $<TARGET_OBJECTS:ep_objs>)
431    TARGET_LINK_LIBRARIES(ep-engine_sizes cJSON JSON_checker hdr_histogram_static
432                          engine_utilities ${EP_STORAGE_LIBS} dirutils cbcompress platform mcd_util
433                          mcd_tracing phosphor xattr ${LIBEVENT_LIBRARIES})
434    add_sanitizers(ep-engine_sizes)
435
436    ADD_LIBRARY(ep_testsuite SHARED
437                tests/ep_testsuite.cc
438                src/ext_meta_parser.cc
439                tests/ep_testsuite_common.cc
440                tests/ep_test_apis.cc
441                tests/mock/mock_dcp.cc)
442    SET_TARGET_PROPERTIES(ep_testsuite PROPERTIES PREFIX "")
443    TARGET_LINK_LIBRARIES(ep_testsuite engine_utilities mcd_util
444                          ${EP_STORAGE_LIBS} dirutils JSON_checker platform
445                          xattr
446                          ${LIBEVENT_LIBRARIES})
447    ADD_DEPENDENCIES(ep_testsuite engine_testapp)
448
449    ADD_LIBRARY(ep_testsuite_basic SHARED
450                tests/ep_testsuite_basic.cc
451                src/ext_meta_parser.cc
452                tests/ep_testsuite_common.cc
453                tests/ep_test_apis.cc
454                tests/mock/mock_dcp.cc
455                )
456    SET_TARGET_PROPERTIES(ep_testsuite_basic PROPERTIES PREFIX "")
457    TARGET_LINK_LIBRARIES(ep_testsuite_basic engine_utilities JSON_checker dirutils
458                          platform ${LIBEVENT_LIBRARIES} ${SNAPPY_LIBRARIES})
459    ADD_DEPENDENCIES(ep_testsuite engine_testapp)
460
461    ADD_LIBRARY(ep_testsuite_dcp SHARED
462                tests/ep_testsuite_dcp.cc
463                src/ext_meta_parser.cc
464                tests/ep_testsuite_common.cc
465                tests/ep_test_apis.cc
466                tests/mock/mock_dcp.cc
467                )
468    SET_TARGET_PROPERTIES(ep_testsuite_dcp PROPERTIES PREFIX "")
469    TARGET_LINK_LIBRARIES(ep_testsuite_dcp engine_utilities cbcompress JSON_checker dirutils platform ${LIBEVENT_LIBRARIES} ${SNAPPY_LIBRARIES})
470    ADD_DEPENDENCIES(ep_testsuite_dcp engine_testapp)
471
472    ADD_LIBRARY(ep_testsuite_checkpoint SHARED
473                tests/ep_testsuite_common.cc
474                tests/ep_testsuite_checkpoint.cc
475                tests/ep_test_apis.cc
476                src/ext_meta_parser.cc)
477    SET_TARGET_PROPERTIES(ep_testsuite_checkpoint PROPERTIES PREFIX "")
478    TARGET_LINK_LIBRARIES(ep_testsuite_checkpoint engine_utilities JSON_checker dirutils platform ${LIBEVENT_LIBRARIES} ${SNAPPY_LIBRARIES})
479    ADD_DEPENDENCIES(ep_testsuite_checkpoint engine_testapp)
480
481    ADD_LIBRARY(ep_testsuite_xdcr SHARED
482                tests/ep_testsuite_common.cc
483                tests/ep_testsuite_xdcr.cc
484                tests/ep_test_apis.cc
485                src/ext_meta_parser.cc)
486    SET_TARGET_PROPERTIES(ep_testsuite_xdcr PROPERTIES PREFIX "")
487    TARGET_LINK_LIBRARIES(ep_testsuite_xdcr mcd_util engine_utilities JSON_checker dirutils platform xattr
488                          ${LIBEVENT_LIBRARIES} ${SNAPPY_LIBRARIES})
489    ADD_DEPENDENCIES(ep_testsuite_xdcr engine_testapp)
490
491    ADD_LIBRARY(ep_perfsuite SHARED
492                tests/ep_perfsuite.cc
493                src/ext_meta_parser.cc
494                tests/ep_testsuite_common.cc
495                tests/ep_test_apis.cc
496                tests/mock/mock_dcp.cc)
497    SET_TARGET_PROPERTIES(ep_perfsuite PROPERTIES PREFIX "")
498    TARGET_LINK_LIBRARIES(ep_perfsuite engine_utilities dirutils platform)
499    ADD_DEPENDENCIES(ep_perfsuite engine_testapp)
500
501    #ADD_CUSTOM_COMMAND(OUTPUT
502    #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_0.c
503    #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_1.c
504    #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_2.c
505    #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_3.c
506    #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_4.c
507    #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_5.c
508    #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_6.c
509    #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_7.c
510    #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_8.c
511    #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_9.c
512    #                  COMMAND
513    #                     ${PYTHON_EXECUTABLE} tests/module_tests/gen_engine_test.py
514    #                  DEPENDS
515    #                        tests/module_tests/gen_engine_test.py
516    #                        tests/module_tests/breakdancer.py
517    #                  COMMENT "Generating testsuite")
518    #
519    #ADD_LIBRARY(generated_testsuite SHARED
520    #            tests/suite_stubs.c
521    #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_0.c
522    #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_1.c
523    #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_2.c
524    #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_3.c
525    #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_4.c
526    #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_5.c
527    #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_6.c
528    #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_7.c
529    #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_8.c
530    #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_9.c)
531
532    #SET_TARGET_PROPERTIES(generated_testsuite PROPERTIES PREFIX "")
533endif (COUCHBASE_KV_BUILD_UNIT_TESTS)
534
535INSTALL(PROGRAMS
536        ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbepctl
537        ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbstats
538        ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbcompact
539        ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbvdiff
540        ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbvbucketctl
541        ${CMAKE_CURRENT_BINARY_DIR}/wrapper/kv_trace_dump
542        management/cbanalyze-core
543        DESTINATION bin)
544
545INSTALL(PROGRAMS
546        management/cbepctl
547        management/cbstats
548        management/cbcompact
549        management/cbvdiff
550        management/cbvbucketctl
551        management/kv_trace_dump
552        DESTINATION lib/python)
553
554INSTALL(FILES
555        management/clitool.py
556        management/cli_auth_utils.py
557        management/mc_bin_client.py
558        management/mc_bin_server.py
559        management/memcacheConstants.py
560        DESTINATION lib/python)
561
562INSTALL(FILES
563        docs/stats.org
564        DESTINATION share/doc/ep-engine)
565
566INSTALL(TARGETS ep
567        RUNTIME DESTINATION bin
568        LIBRARY DESTINATION lib
569        ARCHIVE DESTINATION lib)
570
571if (COUCHBASE_KV_BUILD_UNIT_TESTS)
572    IF (EP_USE_ROCKSDB)
573        ADD_TEST(NAME ep-engine-persistence-unit-tests.rocksdb
574                 COMMAND memcached_testapp -E ep -c "backend=rocksdb" --gtest_filter=*PersistToTest*)
575        SET_TESTS_PROPERTIES(ep-engine-persistence-unit-tests.rocksdb PROPERTIES TIMEOUT 300)
576    ENDIF (EP_USE_ROCKSDB)
577
578    # Defines a testsuite which runs in full and value eviction
579    # (persistent), ephemeral buckets (which has no eviction).
580    FUNCTION(ADD_TESTSUITE name timeout)
581        CMAKE_PARSE_ARGUMENTS("arg" "SKIP_EPHEMERAL" "" "" ${ARGN})
582
583        SET(_cmdline
584            ${Memcached_BINARY_DIR}/engine_testapp
585            -E $<TARGET_FILE:ep>
586            -T $<TARGET_FILE:${name}>)
587        ADD_TEST(NAME ${name}.value_eviction
588                 COMMAND ${_cmdline} -v -e "dbname=./${name}.value_eviction.db")
589        ADD_TEST(NAME ${name}.full_eviction
590                 COMMAND ${_cmdline} -v -e "item_eviction_policy=full_eviction$<SEMICOLON>dbname=./${name}.full_eviction.db")
591        SET_TESTS_PROPERTIES(${name}.value_eviction PROPERTIES TIMEOUT ${timeout})
592        SET_TESTS_PROPERTIES(${name}.full_eviction PROPERTIES TIMEOUT ${timeout})
593
594        IF (NOT arg_SKIP_EPHEMERAL)
595            ADD_TEST(NAME ${name}.ephemeral
596                     COMMAND ${_cmdline} -v -e "bucket_type=ephemeral$<SEMICOLON>dbname=./${name}.ephemeral.db")
597            SET_TESTS_PROPERTIES(${name}.ephemeral PROPERTIES TIMEOUT ${timeout})
598        ENDIF ()
599
600        IF (EP_USE_ROCKSDB)
601            ADD_TEST(NAME ${name}.value_eviction.rocksdb
602                     COMMAND ${_cmdline} -v -e "dbname=./${name}.value_eviction.rocksdb$<SEMICOLON>backend=rocksdb")
603            ADD_TEST(NAME ${name}.full_eviction.rocksdb
604                     COMMAND ${_cmdline} -v -e "item_eviction_policy=full_eviction$<SEMICOLON>dbname=./${name}.full_eviction.rocksdb$<SEMICOLON>backend=rocksdb")
605            SET_TESTS_PROPERTIES(${name}.value_eviction.rocksdb PROPERTIES TIMEOUT ${timeout})
606            SET_TESTS_PROPERTIES(${name}.full_eviction.rocksdb PROPERTIES TIMEOUT ${timeout})
607        ENDIF (EP_USE_ROCKSDB)
608    ENDFUNCTION()
609
610    ADD_TESTSUITE(ep_testsuite 1800)
611
612    ADD_TESTSUITE(ep_testsuite_basic 600)
613
614    ADD_TESTSUITE(ep_testsuite_dcp 1200)
615
616    ADD_TESTSUITE(ep_testsuite_checkpoint 120)
617
618    ADD_TESTSUITE(ep_testsuite_xdcr 120)
619
620    # ================================ PERF_TESTS ================================ #
621    SET(_ep_perfsuite_cmdline $<TARGET_FILE:engine_testapp> -E $<TARGET_FILE:ep> -T $<TARGET_FILE:ep_perfsuite> -v)
622
623    # Micro perf tests: value-only eviction mode. Note that it makes no sense to run
624    # these tests in full-eviction mode as we disable persistence - see MB-19504.
625    ADD_CUSTOM_TARGET(test-perfsuite
626                      COMMAND ${_ep_perfsuite_cmdline}
627                      DEPENDS engine_testapp
628                      ep
629                      ep_perfsuite
630                      VERBATIM)
631    ADD_TEST(NAME ep_perfsuite.value_eviction
632             COMMAND ${_ep_perfsuite_cmdline} -e "dbname=./ep_perfsuite.value_eviction.db")
633
634    ADD_TEST(NAME ep_perfsuite.ephemeral
635             COMMAND ${_ep_perfsuite_cmdline} -e "bucket_type=ephemeral$<SEMICOLON>dbname=./ep_perfsuite.ephemeral.db")
636
637    # ============================================================================ #
638
639    ENABLE_CODE_COVERAGE_REPORT()
640endif (COUCHBASE_KV_BUILD_UNIT_TESTS)
641