19f6b3a1c2760fae67008294ecadba9b51c95d0c
[ep-engine.git] / CMakeLists.txt
1 PROJECT(EventuallyPersistentEngine)
2 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
3
4 IF (${CMAKE_MAJOR_VERSION} GREATER 2)
5     CMAKE_POLICY(SET CMP0042 NEW)
6 ENDIF (${CMAKE_MAJOR_VERSION} GREATER 2)
7
8 INCLUDE(CheckFunctionExists)
9 INCLUDE(CheckIncludeFileCXX)
10 INCLUDE(CheckIncludeFiles)
11 INCLUDE(CheckLibraryExists)
12 INCLUDE(CheckSymbolExists)
13 INCLUDE(CheckTypeSize)
14 INCLUDE(CTest)
15
16 OPTION(EP_USE_FORESTDB "Enable support for ForestDB" OFF)
17
18 INCLUDE_DIRECTORIES(BEFORE ${CMAKE_INSTALL_PREFIX}/include
19                            ${CMAKE_CURRENT_SOURCE_DIR}
20                            ${CMAKE_CURRENT_SOURCE_DIR}/src
21                            ${CMAKE_CURRENT_BINARY_DIR}/src
22                            ${BOOST_INCLUDE_DIR}
23                            ${SNAPPY_INCLUDE_DIR}
24                            ${BOOST_INCLUDE_DIR}
25                            ${Platform_SOURCE_DIR}/include
26                            ${Platform_SOURCE_DIR}/external
27                            ${Memcached_SOURCE_DIR}
28                            ${Memcached_SOURCE_DIR}/utilities
29                            ${Memcached_SOURCE_DIR}/include
30                            ${Couchstore_SOURCE_DIR}/include
31                            ${phosphor_SOURCE_DIR}/include
32                            ${CMAKE_CURRENT_BINARY_DIR})
33
34 INCLUDE_DIRECTORIES(AFTER ${Memcached_BINARY_DIR}/include)
35
36 IF (EP_USE_FORESTDB)
37     INCLUDE_DIRECTORIES(AFTER ${ForestDB_SOURCE_DIR}/include)
38     SET(FOREST_KVSTORE_SOURCE src/forest-kvstore/forest-kvstore.cc)
39     SET(EP_FORESTDB_LIB forestdb)
40     ADD_DEFINITIONS(-DEP_USE_FORESTDB=1)
41     MESSAGE(STATUS "ep-engine: Using ForestDB")
42 ENDIF (EP_USE_FORESTDB)
43
44 INCLUDE_DIRECTORIES(AFTER
45                     ${gtest_SOURCE_DIR}/include
46                     ${gmock_SOURCE_DIR}/include)
47
48 CHECK_INCLUDE_FILES("alloca.h" HAVE_ALLOCA_H)
49 CHECK_INCLUDE_FILES("arpa/inet.h" HAVE_ARPA_INET_H)
50 CHECK_INCLUDE_FILES("unistd.h" HAVE_UNISTD_H)
51 CHECK_INCLUDE_FILES("netdb.h" HAVE_NETDB_H)
52 CHECK_INCLUDE_FILES("mach/mach_time.h" HAVE_MACH_MACH_TIME_H)
53 CHECK_INCLUDE_FILES("poll.h" HAVE_POLL_H)
54 CHECK_INCLUDE_FILES("sysexits.h" HAVE_SYSEXITS_H)
55 CHECK_INCLUDE_FILES("unistd.h" HAVE_UNISTD_H)
56 CHECK_INCLUDE_FILES("sched.h" HAVE_SCHED_H)
57 CHECK_INCLUDE_FILES("sys/socket.h" HAVE_SYS_SOCKET_H)
58 CHECK_INCLUDE_FILES("sys/time.h" HAVE_SYS_TIME_H)
59 CHECK_INCLUDE_FILES("netinet/in.h" HAVE_NETINET_IN_H)
60 CHECK_INCLUDE_FILES("netinet/tcp.h" HAVE_NETINET_TCP_H)
61 CHECK_INCLUDE_FILE_CXX("unordered_map" HAVE_UNORDERED_MAP)
62 CHECK_INCLUDE_FILE_CXX("atomic" HAVE_ATOMIC)
63 CHECK_INCLUDE_FILE_CXX("thread" HAVE_THREAD)
64
65 CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
66 CHECK_FUNCTION_EXISTS(mach_absolute_time HAVE_MACH_ABSOLUTE_TIME)
67 CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
68 CHECK_FUNCTION_EXISTS(getopt_long HAVE_GETOPT_LONG)
69
70 # For debugging without compiler optimizations uncomment line below..
71 #SET (CMAKE_BUILD_TYPE DEBUG)
72
73 IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
74    EXECUTE_PROCESS(COMMAND git rev-parse HEAD
75                    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
76                    OUTPUT_VARIABLE EP_ENGINE_VERSION
77                    OUTPUT_STRIP_TRAILING_WHITESPACE)
78    IF (EP_ENGINE_VERSION STREQUAL "" OR EP_ENGINE_VERSION STREQUAL "HEAD")
79      MESSAGE (FATAL_ERROR "Failed to determine commit SHA!")
80    ENDIF (EP_ENGINE_VERSION STREQUAL "" OR EP_ENGINE_VERSION STREQUAL "HEAD")
81 ELSE (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
82    SET(EP_ENGINE_VERSION "unknown")
83 ENDIF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
84
85 CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/src/config.cmake.h
86                 ${CMAKE_CURRENT_BINARY_DIR}/src/config.h)
87
88 # Generate the python wrappers
89 CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/wrapper/wrapper
90                 ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbepctl)
91 CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/wrapper/wrapper
92                 ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbstats)
93 CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/wrapper/wrapper
94                 ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbcompact)
95 CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/wrapper/wrapper
96                 ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbvdiff)
97 CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/wrapper/wrapper
98                 ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbvbucketctl)
99
100 SET(Python_ADDITIONAL_VERSIONS 2.6)
101 FIND_PACKAGE(PythonInterp)
102
103 # to avoid cluttering source dir with name + "c" files
104 SET(ENV{PYTHONDONTWRITEBYTECODE} 1)
105
106 # runs cbstats & cbepctl - will fail on basic syntax errors
107 ADD_TEST(cbstats_test ${PYTHON_EXECUTABLE}
108         ${CMAKE_CURRENT_SOURCE_DIR}/management/cbstats --help)
109 ADD_TEST(cbepctl_test ${PYTHON_EXECUTABLE}
110         ${CMAKE_CURRENT_SOURCE_DIR}/management/cbepctl --help)
111
112 IF (WIN32)
113    INCLUDE_DIRECTORIES(AFTER ${CMAKE_SOURCE_DIR}/platform/include/win32)
114 ENDIF (WIN32)
115
116 ADD_EXECUTABLE(gencode tools/gencode.cc)
117 TARGET_LINK_LIBRARIES(gencode cJSON platform)
118
119 ADD_EXECUTABLE(genconfig tools/genconfig.cc)
120 TARGET_LINK_LIBRARIES(genconfig cJSON platform)
121
122 ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/stats-info.c
123                           ${CMAKE_CURRENT_BINARY_DIR}/src/stats-info.h
124                   COMMAND
125                      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
126                   DEPENDS
127                         docs/stats.json
128                         gencode
129                   COMMENT "Generating code for stats info")
130
131 ADD_CUSTOM_COMMAND(OUTPUT
132                      ${CMAKE_CURRENT_BINARY_DIR}/src/generated_configuration.cc
133                      ${CMAKE_CURRENT_BINARY_DIR}/src/generated_configuration.h
134                   COMMAND
135                      genconfig ${CMAKE_CURRENT_SOURCE_DIR}/configuration.json
136                   DEPENDS
137                         configuration.json
138                         genconfig
139                   COMMENT "Generating code for configuration class")
140
141 SET(KVSTORE_SOURCE src/kvstore.cc)
142 SET(COUCH_KVSTORE_SOURCE src/couch-kvstore/couch-kvstore.cc
143             src/couch-kvstore/couch-fs-stats.cc)
144 SET(OBJECTREGISTRY_SOURCE src/objectregistry.cc)
145 SET(CONFIG_SOURCE src/configuration.cc
146   ${CMAKE_CURRENT_BINARY_DIR}/src/generated_configuration.cc)
147
148 SET(COLLECTIONS_SOURCE src/collections/manifest.cc
149                        src/collections/vbucket_manifest.cc
150                        src/collections/vbucket_manifest_entry.cc)
151
152 ADD_LIBRARY(ep_objs OBJECT
153             src/access_scanner.cc
154             src/atomic.cc
155             src/backfill.cc
156             src/bgfetcher.cc
157             src/bloomfilter.cc
158             src/checkpoint.cc
159             src/checkpoint_remover.cc
160             src/conflict_resolution.cc
161             src/connmap.cc
162             src/crc32.c
163             src/dcp/backfill-manager.cc
164             src/dcp/backfill_disk.cc
165             src/dcp/backfill_memory.cc
166             src/dcp/consumer.cc
167             src/dcp/dcpconnmap.cc
168             src/dcp/flow-control.cc
169             src/dcp/flow-control-manager.cc
170             src/dcp/producer.cc
171             src/dcp/response.cc
172             src/dcp/stream.cc
173             src/defragmenter.cc
174             src/defragmenter_visitor.cc
175             src/ep_bucket.cc
176             src/ep_vb.cc
177             src/ep_engine.cc
178             src/ep_time.cc
179             src/ep_types.cc
180             src/ephemeral_bucket.cc
181             src/ephemeral_tombstone_purger.cc
182             src/ephemeral_vb.cc
183             src/ephemeral_vb_count_visitor.cc
184             src/executorpool.cc
185             src/executorthread.cc
186             src/ext_meta_parser.cc
187             src/failover-table.cc
188             src/flusher.cc
189             src/globaltask.cc
190             src/hash_table.cc
191             src/hlc.cc
192             src/htresizer.cc
193             src/item.cc
194             src/item_pager.cc
195             src/logger.cc
196             src/kv_bucket.cc
197             src/kvshard.cc
198             src/memory_tracker.cc
199             src/murmurhash3.cc
200             src/mutation_log.cc
201             src/mutation_log_entry.cc
202             src/pre_link_document_context.cc
203             src/pre_link_document_context.h
204             src/replicationthrottle.cc
205             src/linked_list.cc
206             src/string_utils.cc
207             src/storeddockey.cc
208             src/stored-value.cc
209             src/systemevent.cc
210             src/tapconnection.cc
211             src/tapconnmap.cc
212             src/tasks.cc
213             src/taskqueue.cc
214             src/vb_count_visitor.cc
215             src/vbucket.cc
216             src/vbucketmap.cc
217             src/vbucketmemorydeletiontask.cc
218             src/warmup.cc
219             ${OBJECTREGISTRY_SOURCE}
220             ${CMAKE_CURRENT_BINARY_DIR}/src/stats-info.c
221             ${CONFIG_SOURCE}
222             ${KVSTORE_SOURCE}
223             ${COUCH_KVSTORE_SOURCE}
224             ${FOREST_KVSTORE_SOURCE}
225             ${COLLECTIONS_SOURCE})
226 SET_PROPERTY(TARGET ep_objs PROPERTY POSITION_INDEPENDENT_CODE 1)
227
228 ADD_LIBRARY(ep SHARED $<TARGET_OBJECTS:ep_objs>)
229
230 SET_TARGET_PROPERTIES(ep PROPERTIES PREFIX "")
231 TARGET_LINK_LIBRARIES(ep cJSON JSON_checker couchstore ${EP_FORESTDB_LIB}
232                       engine_utilities dirutils cbcompress
233                       platform phosphor xattr ${LIBEVENT_LIBRARIES})
234
235 # Single executable containing all class-level unit tests involving
236 # EventuallyPersistentEngine driven by GoogleTest.
237 # (We end up compiling most of the src/ files of ep-engine for these unit tests,
238 # so simpler / quicker just to link them into a single executable).
239 ADD_EXECUTABLE(ep-engine_ep_unit_tests
240                tests/mock/mock_dcp.cc
241                tests/mock/mock_synchronous_ep_engine.cc
242                tests/module_tests/atomic_unordered_map_test.cc
243                tests/module_tests/basic_ll_test.cc
244                tests/module_tests/bloomfilter_test.cc
245                tests/module_tests/checkpoint_test.cc
246                tests/module_tests/collections/collection_dockey_test.cc
247                tests/module_tests/collections/evp_store_collections_test.cc
248                tests/module_tests/collections/manifest_test.cc
249                tests/module_tests/collections/vbucket_manifest_test.cc
250                tests/module_tests/collections/vbucket_manifest_entry_test.cc
251                tests/module_tests/configuration_test.cc
252                tests/module_tests/defragmenter_test.cc
253                tests/module_tests/dcp_test.cc
254                tests/module_tests/ep_unit_tests_main.cc
255                tests/module_tests/ephemeral_bucket_test.cc
256                tests/module_tests/ephemeral_vb_test.cc
257                tests/module_tests/evp_engine_test.cc
258                tests/module_tests/evp_store_rollback_test.cc
259                tests/module_tests/evp_store_test.cc
260                tests/module_tests/evp_store_single_threaded_test.cc
261                tests/module_tests/executorpool_test.cc
262                tests/module_tests/failover_table_test.cc
263                tests/module_tests/futurequeue_test.cc
264                tests/module_tests/hash_table_test.cc
265                tests/module_tests/item_pager_test.cc
266                tests/module_tests/kvstore_test.cc
267                tests/module_tests/kv_bucket_test.cc
268                tests/module_tests/memory_tracker_test.cc
269                tests/module_tests/mock_hooks_api.cc
270                tests/module_tests/mutation_log_test.cc
271                tests/module_tests/mutex_test.cc
272                tests/module_tests/stats_test.cc
273                tests/module_tests/storeddockey_test.cc
274                tests/module_tests/stored_value_test.cc
275                tests/module_tests/systemevent_test.cc
276                tests/module_tests/test_helpers.cc
277                tests/module_tests/vbucket_test.cc
278                tests/module_tests/warmup_test.cc
279                $<TARGET_OBJECTS:ep_objs>
280                $<TARGET_OBJECTS:memory_tracking>
281                $<TARGET_OBJECTS:couchstore_test_fileops>
282                ${Memcached_SOURCE_DIR}/programs/engine_testapp/mock_server.cc
283                ${Memcached_SOURCE_DIR}/daemon/doc_pre_expiry.cc
284                ${Memcached_SOURCE_DIR}/daemon/protocol/mcbp/engine_errc_2_mcbp.cc
285                ${Memcached_SOURCE_DIR}/utilities/string_utilities.cc)
286
287 TARGET_INCLUDE_DIRECTORIES(ep-engine_ep_unit_tests
288         PUBLIC
289         ${Couchstore_SOURCE_DIR})
290
291 TARGET_LINK_LIBRARIES(ep-engine_ep_unit_tests couchstore cJSON dirutils
292                       engine_utilities ${EP_FORESTDB_LIB}
293                       gtest gmock JSON_checker mcd_util platform
294                       phosphor xattr cbcompress ${MALLOC_LIBRARIES})
295
296 ADD_EXECUTABLE(ep-engine_atomic_ptr_test
297   tests/module_tests/atomic_ptr_test.cc
298   src/atomic.cc
299   src/testlogger.cc)
300 TARGET_LINK_LIBRARIES(ep-engine_atomic_ptr_test platform)
301
302 ADD_EXECUTABLE(ep-engine_couch-fs-stats_test
303         src/couch-kvstore/couch-fs-stats.cc
304         src/generated_configuration.h
305         tests/module_tests/couch-fs-stats_test.cc
306         $<TARGET_OBJECTS:couchstore_wrapped_fileops_test_framework>)
307 TARGET_INCLUDE_DIRECTORIES(ep-engine_couch-fs-stats_test
308         PRIVATE
309         ${Couchstore_SOURCE_DIR}
310         ${Couchstore_SOURCE_DIR}/src)
311 TARGET_LINK_LIBRARIES(ep-engine_couch-fs-stats_test gtest gtest_main gmock platform)
312
313 ADD_EXECUTABLE(ep-engine_hrtime_test tests/module_tests/hrtime_test.cc)
314 TARGET_LINK_LIBRARIES(ep-engine_hrtime_test platform)
315
316 ADD_EXECUTABLE(ep-engine_misc_test tests/module_tests/misc_test.cc)
317 TARGET_LINK_LIBRARIES(ep-engine_misc_test platform)
318
319 ADD_EXECUTABLE(ep-engine_string_utils_test
320                tests/module_tests/string_utils_test.cc
321                src/string_utils.cc)
322 TARGET_LINK_LIBRARIES(ep-engine_string_utils_test gtest gtest_main platform)
323
324 ADD_EXECUTABLE(ep_engine_benchmarks
325                benchmarks/access_scanner_bench.cc
326                tests/mock/mock_synchronous_ep_engine.cc
327                $<TARGET_OBJECTS:ep_objs>
328                $<TARGET_OBJECTS:memory_tracking>
329                $<TARGET_OBJECTS:couchstore_test_fileops>
330                ${Memcached_SOURCE_DIR}/programs/engine_testapp/mock_server.cc
331                ${Memcached_SOURCE_DIR}/daemon/doc_pre_expiry.cc
332                ${Memcached_SOURCE_DIR}/daemon/protocol/mcbp/engine_errc_2_mcbp.cc
333                ${Memcached_SOURCE_DIR}/utilities/string_utilities.cc
334                benchmarks/benchmark_memory_tracker.cc
335                benchmarks/defragmenter_bench.cc
336                tests/module_tests/vbucket_test.cc)
337
338 TARGET_LINK_LIBRARIES(ep_engine_benchmarks benchmark platform xattr couchstore
339         cJSON dirutils engine_utilities gtest gmock JSON_checker mcd_util
340         cbcompress ${MALLOC_LIBRARIES})
341 TARGET_INCLUDE_DIRECTORIES(ep_engine_benchmarks PUBLIC
342                            ${benchmark_SOURCE_DIR}/include
343                            tests
344                            benchmarks
345                            ${Couchstore_SOURCE_DIR})
346
347 ADD_TEST(ep-engine_atomic_ptr_test ep-engine_atomic_ptr_test)
348 ADD_TEST(ep-engine_couch-fs-stats_test ep-engine_couch-fs-stats_test)
349 ADD_TEST(ep-engine_ep_unit_tests ep-engine_ep_unit_tests)
350 ADD_TEST(ep-engine_hrtime_test ep-engine_hrtime_test)
351 ADD_TEST(ep-engine_misc_test ep-engine_misc_test)
352
353 ADD_LIBRARY(timing_tests SHARED tests/module_tests/timing_tests.cc)
354 SET_TARGET_PROPERTIES(timing_tests PROPERTIES PREFIX "")
355 TARGET_LINK_LIBRARIES(timing_tests platform)
356
357 ADD_EXECUTABLE(ep-engine_sizes src/sizes.cc
358                                $<TARGET_OBJECTS:ep_objs>)
359 TARGET_LINK_LIBRARIES(ep-engine_sizes cJSON JSON_checker
360   engine_utilities couchstore
361   ${EP_FORESTDB_LIB} dirutils cbcompress platform phosphor xattr
362   ${LIBEVENT_LIBRARIES})
363
364 ADD_LIBRARY(ep_testsuite SHARED
365    tests/ep_testsuite.cc
366    src/ext_meta_parser.cc
367    tests/ep_testsuite_common.cc
368    tests/ep_test_apis.cc
369    tests/mock/mock_dcp.cc
370    ${Memcached_SOURCE_DIR}/utilities/string_utilities.cc)
371 SET_TARGET_PROPERTIES(ep_testsuite PROPERTIES PREFIX "")
372 TARGET_LINK_LIBRARIES(ep_testsuite couchstore dirutils JSON_checker platform
373                       xattr
374                       ${LIBEVENT_LIBRARIES})
375 ADD_DEPENDENCIES(ep_testsuite engine_testapp)
376
377 ADD_LIBRARY(ep_testsuite_basic SHARED
378    tests/ep_testsuite_basic.cc
379    src/ext_meta_parser.cc
380    tests/ep_testsuite_common.cc
381    tests/ep_test_apis.cc
382    tests/mock/mock_dcp.cc
383 )
384 SET_TARGET_PROPERTIES(ep_testsuite_basic PROPERTIES PREFIX "")
385 TARGET_LINK_LIBRARIES(ep_testsuite_basic engine_utilities JSON_checker dirutils
386                       platform ${LIBEVENT_LIBRARIES} ${SNAPPY_LIBRARIES})
387 ADD_DEPENDENCIES(ep_testsuite engine_testapp)
388
389 ADD_LIBRARY(ep_testsuite_dcp SHARED
390 tests/ep_testsuite_dcp.cc
391 src/ext_meta_parser.cc
392 tests/ep_testsuite_common.cc
393 tests/ep_test_apis.cc
394 tests/mock/mock_dcp.cc
395 )
396 SET_TARGET_PROPERTIES(ep_testsuite_dcp PROPERTIES PREFIX "")
397 TARGET_LINK_LIBRARIES(ep_testsuite_dcp cbcompress JSON_checker dirutils platform ${LIBEVENT_LIBRARIES} ${SNAPPY_LIBRARIES})
398 ADD_DEPENDENCIES(ep_testsuite_dcp engine_testapp)
399
400 ADD_LIBRARY(ep_testsuite_tap SHARED
401    tests/ep_testsuite_common.cc
402    tests/ep_testsuite_tap.cc
403    tests/ep_test_apis.cc
404    src/ext_meta_parser.cc)
405 SET_TARGET_PROPERTIES(ep_testsuite_tap PROPERTIES PREFIX "")
406 TARGET_LINK_LIBRARIES(ep_testsuite_tap JSON_checker dirutils platform ${LIBEVENT_LIBRARIES} ${SNAPPY_LIBRARIES})
407 ADD_DEPENDENCIES(ep_testsuite_tap engine_testapp)
408
409 ADD_LIBRARY(ep_testsuite_checkpoint SHARED
410    tests/ep_testsuite_common.cc
411    tests/ep_testsuite_checkpoint.cc
412    tests/ep_test_apis.cc
413    src/ext_meta_parser.cc)
414 SET_TARGET_PROPERTIES(ep_testsuite_checkpoint PROPERTIES PREFIX "")
415 TARGET_LINK_LIBRARIES(ep_testsuite_checkpoint JSON_checker dirutils platform ${LIBEVENT_LIBRARIES} ${SNAPPY_LIBRARIES})
416 ADD_DEPENDENCIES(ep_testsuite_checkpoint engine_testapp)
417
418 ADD_LIBRARY(ep_testsuite_xdcr SHARED
419    tests/ep_testsuite_common.cc
420    tests/ep_testsuite_xdcr.cc
421    tests/ep_test_apis.cc
422    src/ext_meta_parser.cc
423    ${Memcached_SOURCE_DIR}/utilities/string_utilities.cc)
424 SET_TARGET_PROPERTIES(ep_testsuite_xdcr PROPERTIES PREFIX "")
425 TARGET_LINK_LIBRARIES(ep_testsuite_xdcr JSON_checker dirutils platform xattr
426                       ${LIBEVENT_LIBRARIES} ${SNAPPY_LIBRARIES})
427 ADD_DEPENDENCIES(ep_testsuite_xdcr engine_testapp)
428
429 ADD_LIBRARY(ep_perfsuite SHARED
430    tests/ep_perfsuite.cc
431    src/ext_meta_parser.cc
432    tests/ep_testsuite_common.cc
433    tests/ep_test_apis.cc
434    tests/mock/mock_dcp.cc)
435 SET_TARGET_PROPERTIES(ep_perfsuite PROPERTIES PREFIX "")
436 TARGET_LINK_LIBRARIES(ep_perfsuite dirutils platform)
437 ADD_DEPENDENCIES(ep_perfsuite engine_testapp)
438
439 #ADD_CUSTOM_COMMAND(OUTPUT
440 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_0.c
441 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_1.c
442 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_2.c
443 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_3.c
444 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_4.c
445 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_5.c
446 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_6.c
447 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_7.c
448 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_8.c
449 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_9.c
450 #                  COMMAND
451 #                     ${PYTHON_EXECUTABLE} tests/module_tests/gen_engine_test.py
452 #                  DEPENDS
453 #                        tests/module_tests/gen_engine_test.py
454 #                        tests/module_tests/breakdancer.py
455 #                  COMMENT "Generating testsuite")
456 #
457 #ADD_LIBRARY(generated_testsuite SHARED
458 #            tests/suite_stubs.c
459 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_0.c
460 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_1.c
461 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_2.c
462 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_3.c
463 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_4.c
464 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_5.c
465 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_6.c
466 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_7.c
467 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_8.c
468 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_9.c)
469
470 #SET_TARGET_PROPERTIES(generated_testsuite PROPERTIES PREFIX "")
471
472 INSTALL(PROGRAMS
473         ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbepctl
474         ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbstats
475         ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbcompact
476         ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbvdiff
477         ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbvbucketctl
478         management/cbanalyze-core
479         DESTINATION bin)
480
481 INSTALL(PROGRAMS
482         management/cbepctl
483         management/cbstats
484         management/cbcompact
485         management/cbvdiff
486         management/cbvbucketctl
487         DESTINATION lib/python)
488
489 INSTALL(FILES
490         management/clitool.py
491         management/cli_auth_utils.py
492         management/mc_bin_client.py
493         management/mc_bin_server.py
494         management/memcacheConstants.py
495         management/tap.py
496         management/tap_example.py
497         DESTINATION lib/python)
498
499 INSTALL(FILES
500         docs/stats.org
501         DESTINATION share/doc/ep-engine)
502
503 INSTALL(TARGETS ep
504         RUNTIME DESTINATION bin
505         LIBRARY DESTINATION lib
506         ARCHIVE DESTINATION lib)
507
508
509 # Defines a testsuite which runs in full and value eviction
510 # (persistent), ephemeral buckets (which has no eviction).
511 FUNCTION(ADD_TESTSUITE name timeout)
512   CMAKE_PARSE_ARGUMENTS("arg" "SKIP_EPHEMERAL" "" "" ${ARGN} )
513
514   SET(_cmdline
515     ${CMAKE_BINARY_DIR}/memcached/engine_testapp
516         -E ${CMAKE_CURRENT_BINARY_DIR}/ep.so
517         -T ${CMAKE_CURRENT_BINARY_DIR}/${name}.so)
518   ADD_TEST(NAME ${name}.value_eviction
519          COMMAND ${_cmdline} -v -e "dbname=./${name}.value_eviction.db")
520   ADD_TEST(NAME ${name}.full_eviction
521          COMMAND ${_cmdline} -v -e "item_eviction_policy=full_eviction$<SEMICOLON>dbname=./${name}.full_eviction.db")
522   SET_TESTS_PROPERTIES(${name}.value_eviction PROPERTIES TIMEOUT ${timeout})
523   SET_TESTS_PROPERTIES(${name}.full_eviction PROPERTIES TIMEOUT ${timeout})
524
525   IF(NOT arg_SKIP_EPHEMERAL)
526     ADD_TEST(NAME ${name}.ephemeral
527              COMMAND ${_cmdline} -v -e "bucket_type=ephemeral$<SEMICOLON>dbname=./${name}.ephemeral.db")
528     SET_TESTS_PROPERTIES(${name}.ephemeral PROPERTIES TIMEOUT ${timeout})
529   ENDIF()
530 ENDFUNCTION()
531
532 ADD_TESTSUITE(ep_testsuite 1800)
533
534 ADD_TESTSUITE(ep_testsuite_basic 600)
535
536 ADD_TESTSUITE(ep_testsuite_dcp 1200)
537
538 # TAP not supported for Ephemeral buckets.
539 ADD_TESTSUITE(ep_testsuite_tap 180 SKIP_EPHEMERAL)
540
541 ADD_TESTSUITE(ep_testsuite_checkpoint 120)
542
543 ADD_TESTSUITE(ep_testsuite_xdcr 120)
544
545 # ================================ PERF_TESTS ================================ #
546 SET(_ep_perfsuite_cmdline ${CMAKE_BINARY_DIR}/memcached/engine_testapp -E ${CMAKE_CURRENT_BINARY_DIR}/ep.so -T ${CMAKE_CURRENT_BINARY_DIR}/ep_perfsuite.so -v)
547
548 # Micro perf tests: value-only eviction mode. Note that it makes no sense to run
549 # these tests in full-eviction mode as we disable persistence - see MB-19504.
550 ADD_CUSTOM_TARGET(test-perfsuite
551                   COMMAND ${_ep_perfsuite_cmdline}
552                   DEPENDS ${CMAKE_BINARY_DIR}/memcached/engine_testapp
553                           ep
554                           ep_perfsuite
555                   VERBATIM)
556 ADD_TEST(NAME ep_perfsuite.value_eviction
557          COMMAND ${_ep_perfsuite_cmdline} -e "dbname=./ep_perfsuite.value_eviction.db")
558
559 ADD_TEST(NAME ep_perfsuite.ephemeral
560          COMMAND ${_ep_perfsuite_cmdline} -e "bucket_type=ephemeral$<SEMICOLON>dbname=./ep_perfsuite.ephemeral.db")
561
562 # ============================================================================ #
563
564 ENABLE_CODE_COVERAGE_REPORT()