MB-22602: Use CMake variables for target paths
[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 # Customize some CTest properties
101 CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.cmake.in
102                 ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake)
103
104 SET(Python_ADDITIONAL_VERSIONS 2.6)
105 FIND_PACKAGE(PythonInterp)
106
107 # to avoid cluttering source dir with name + "c" files
108 SET(ENV{PYTHONDONTWRITEBYTECODE} 1)
109
110 # runs cbstats & cbepctl - will fail on basic syntax errors
111 ADD_TEST(NAME cbstats_test
112         COMMAND ${PYTHON_EXECUTABLE}
113         ${CMAKE_CURRENT_SOURCE_DIR}/management/cbstats --help)
114 ADD_TEST(NAME cbepctl_test
115         COMMAND ${PYTHON_EXECUTABLE}
116         ${CMAKE_CURRENT_SOURCE_DIR}/management/cbepctl --help)
117
118 IF (WIN32)
119    INCLUDE_DIRECTORIES(AFTER ${CMAKE_SOURCE_DIR}/platform/include/win32)
120 ENDIF (WIN32)
121
122 ADD_EXECUTABLE(gencode tools/gencode.cc)
123 TARGET_LINK_LIBRARIES(gencode cJSON platform)
124
125 ADD_EXECUTABLE(genconfig tools/genconfig.cc)
126 TARGET_LINK_LIBRARIES(genconfig cJSON platform)
127
128 ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/stats-info.c
129                           ${CMAKE_CURRENT_BINARY_DIR}/src/stats-info.h
130                   COMMAND
131                      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
132                   DEPENDS
133                         docs/stats.json
134                         gencode
135                   COMMENT "Generating code for stats info")
136
137 ADD_CUSTOM_COMMAND(OUTPUT
138                      ${CMAKE_CURRENT_BINARY_DIR}/src/generated_configuration.cc
139                      ${CMAKE_CURRENT_BINARY_DIR}/src/generated_configuration.h
140                   COMMAND
141                      genconfig ${CMAKE_CURRENT_SOURCE_DIR}/configuration.json
142                   DEPENDS
143                         configuration.json
144                         genconfig
145                   COMMENT "Generating code for configuration class")
146
147 SET(KVSTORE_SOURCE src/kvstore.cc)
148 SET(COUCH_KVSTORE_SOURCE src/couch-kvstore/couch-kvstore.cc
149             src/couch-kvstore/couch-fs-stats.cc)
150 SET(OBJECTREGISTRY_SOURCE src/objectregistry.cc)
151 SET(CONFIG_SOURCE src/configuration.cc
152   ${CMAKE_CURRENT_BINARY_DIR}/src/generated_configuration.cc)
153
154 SET(COLLECTIONS_SOURCE src/collections/manifest.cc
155                        src/collections/vbucket_manifest.cc
156                        src/collections/vbucket_manifest_entry.cc)
157
158 ADD_LIBRARY(ep_objs OBJECT
159             src/access_scanner.cc
160             src/atomic.cc
161             src/backfill.cc
162             src/bgfetcher.cc
163             src/bloomfilter.cc
164             src/checkpoint.cc
165             src/checkpoint_remover.cc
166             src/conflict_resolution.cc
167             src/connmap.cc
168             src/crc32.c
169             src/dcp/backfill-manager.cc
170             src/dcp/backfill_disk.cc
171             src/dcp/backfill_memory.cc
172             src/dcp/consumer.cc
173             src/dcp/dcpconnmap.cc
174             src/dcp/flow-control.cc
175             src/dcp/flow-control-manager.cc
176             src/dcp/producer.cc
177             src/dcp/response.cc
178             src/dcp/stream.cc
179             src/defragmenter.cc
180             src/defragmenter_visitor.cc
181             src/ep_bucket.cc
182             src/ep_vb.cc
183             src/ep_engine.cc
184             src/ep_time.cc
185             src/ep_types.cc
186             src/ephemeral_bucket.cc
187             src/ephemeral_tombstone_purger.cc
188             src/ephemeral_vb.cc
189             src/ephemeral_vb_count_visitor.cc
190             src/executorpool.cc
191             src/executorthread.cc
192             src/ext_meta_parser.cc
193             src/failover-table.cc
194             src/flusher.cc
195             src/globaltask.cc
196             src/hash_table.cc
197             src/hlc.cc
198             src/htresizer.cc
199             src/item.cc
200             src/item_pager.cc
201             src/logger.cc
202             src/kv_bucket.cc
203             src/kvshard.cc
204             src/memory_tracker.cc
205             src/murmurhash3.cc
206             src/mutation_log.cc
207             src/mutation_log_entry.cc
208             src/pre_link_document_context.cc
209             src/pre_link_document_context.h
210             src/replicationthrottle.cc
211             src/linked_list.cc
212             src/seqlist.cc
213             src/string_utils.cc
214             src/storeddockey.cc
215             src/stored-value.cc
216             src/systemevent.cc
217             src/tapconnection.cc
218             src/tapconnmap.cc
219             src/tasks.cc
220             src/taskqueue.cc
221             src/vb_count_visitor.cc
222             src/vbucket.cc
223             src/vbucketmap.cc
224             src/vbucketdeletiontask.cc
225             src/warmup.cc
226             ${OBJECTREGISTRY_SOURCE}
227             ${CMAKE_CURRENT_BINARY_DIR}/src/stats-info.c
228             ${CONFIG_SOURCE}
229             ${KVSTORE_SOURCE}
230             ${COUCH_KVSTORE_SOURCE}
231             ${FOREST_KVSTORE_SOURCE}
232             ${COLLECTIONS_SOURCE})
233 SET_PROPERTY(TARGET ep_objs PROPERTY POSITION_INDEPENDENT_CODE 1)
234
235 ADD_LIBRARY(ep SHARED $<TARGET_OBJECTS:ep_objs>)
236
237 SET_TARGET_PROPERTIES(ep PROPERTIES PREFIX "")
238 TARGET_LINK_LIBRARIES(ep cJSON JSON_checker couchstore ${EP_FORESTDB_LIB}
239                       engine_utilities dirutils cbcompress
240                       platform phosphor xattr ${LIBEVENT_LIBRARIES})
241
242 # Single executable containing all class-level unit tests involving
243 # EventuallyPersistentEngine driven by GoogleTest.
244 # (We end up compiling most of the src/ files of ep-engine for these unit tests,
245 # so simpler / quicker just to link them into a single executable).
246 ADD_EXECUTABLE(ep-engine_ep_unit_tests
247                tests/mock/mock_dcp.cc
248                tests/mock/mock_synchronous_ep_engine.cc
249                tests/module_tests/atomic_unordered_map_test.cc
250                tests/module_tests/basic_ll_test.cc
251                tests/module_tests/bloomfilter_test.cc
252                tests/module_tests/checkpoint_test.cc
253                tests/module_tests/collections/collection_dockey_test.cc
254                tests/module_tests/collections/evp_store_collections_test.cc
255                tests/module_tests/collections/manifest_test.cc
256                tests/module_tests/collections/vbucket_manifest_test.cc
257                tests/module_tests/collections/vbucket_manifest_entry_test.cc
258                tests/module_tests/configuration_test.cc
259                tests/module_tests/defragmenter_test.cc
260                tests/module_tests/dcp_test.cc
261                tests/module_tests/ep_unit_tests_main.cc
262                tests/module_tests/ephemeral_bucket_test.cc
263                tests/module_tests/ephemeral_vb_test.cc
264                tests/module_tests/evp_engine_test.cc
265                tests/module_tests/evp_store_rollback_test.cc
266                tests/module_tests/evp_store_test.cc
267                tests/module_tests/evp_store_single_threaded_test.cc
268                tests/module_tests/evp_store_with_meta.cc
269                tests/module_tests/executorpool_test.cc
270                tests/module_tests/failover_table_test.cc
271                tests/module_tests/futurequeue_test.cc
272                tests/module_tests/hash_table_test.cc
273                tests/module_tests/item_pager_test.cc
274                tests/module_tests/kvstore_test.cc
275                tests/module_tests/kv_bucket_test.cc
276                tests/module_tests/memory_tracker_test.cc
277                tests/module_tests/mock_hooks_api.cc
278                tests/module_tests/mutation_log_test.cc
279                tests/module_tests/mutex_test.cc
280                tests/module_tests/stats_test.cc
281                tests/module_tests/storeddockey_test.cc
282                tests/module_tests/stored_value_test.cc
283                tests/module_tests/systemevent_test.cc
284                tests/module_tests/test_helpers.cc
285                tests/module_tests/vbucket_test.cc
286                tests/module_tests/warmup_test.cc
287                $<TARGET_OBJECTS:ep_objs>
288                $<TARGET_OBJECTS:memory_tracking>
289                $<TARGET_OBJECTS:couchstore_test_fileops>
290                ${Memcached_SOURCE_DIR}/programs/engine_testapp/mock_server.cc
291                ${Memcached_SOURCE_DIR}/daemon/doc_pre_expiry.cc
292                ${Memcached_SOURCE_DIR}/daemon/protocol/mcbp/engine_errc_2_mcbp.cc
293                ${Memcached_SOURCE_DIR}/utilities/string_utilities.cc)
294
295 TARGET_INCLUDE_DIRECTORIES(ep-engine_ep_unit_tests
296         PUBLIC
297         ${Couchstore_SOURCE_DIR})
298
299 TARGET_LINK_LIBRARIES(ep-engine_ep_unit_tests couchstore cJSON dirutils
300                       engine_utilities ${EP_FORESTDB_LIB}
301                       gtest gmock JSON_checker mcd_util platform
302                       phosphor xattr cbcompress ${MALLOC_LIBRARIES})
303
304 ADD_EXECUTABLE(ep-engine_atomic_ptr_test
305   tests/module_tests/atomic_ptr_test.cc
306   src/atomic.cc
307   src/testlogger.cc)
308 TARGET_LINK_LIBRARIES(ep-engine_atomic_ptr_test platform)
309
310 ADD_EXECUTABLE(ep-engine_couch-fs-stats_test
311         src/couch-kvstore/couch-fs-stats.cc
312         src/generated_configuration.h
313         tests/module_tests/couch-fs-stats_test.cc
314         $<TARGET_OBJECTS:couchstore_wrapped_fileops_test_framework>)
315 TARGET_INCLUDE_DIRECTORIES(ep-engine_couch-fs-stats_test
316         PRIVATE
317         ${Couchstore_SOURCE_DIR}
318         ${Couchstore_SOURCE_DIR}/src)
319 TARGET_LINK_LIBRARIES(ep-engine_couch-fs-stats_test gtest gtest_main gmock platform)
320
321 ADD_EXECUTABLE(ep-engine_hrtime_test tests/module_tests/hrtime_test.cc)
322 TARGET_LINK_LIBRARIES(ep-engine_hrtime_test platform)
323
324 ADD_EXECUTABLE(ep-engine_misc_test tests/module_tests/misc_test.cc)
325 TARGET_LINK_LIBRARIES(ep-engine_misc_test platform)
326
327 ADD_EXECUTABLE(ep-engine_string_utils_test
328                tests/module_tests/string_utils_test.cc
329                src/string_utils.cc)
330 TARGET_LINK_LIBRARIES(ep-engine_string_utils_test gtest gtest_main platform)
331
332 ADD_EXECUTABLE(ep_engine_benchmarks
333                benchmarks/access_scanner_bench.cc
334                tests/mock/mock_synchronous_ep_engine.cc
335                $<TARGET_OBJECTS:ep_objs>
336                $<TARGET_OBJECTS:memory_tracking>
337                $<TARGET_OBJECTS:couchstore_test_fileops>
338                ${Memcached_SOURCE_DIR}/programs/engine_testapp/mock_server.cc
339                ${Memcached_SOURCE_DIR}/daemon/doc_pre_expiry.cc
340                ${Memcached_SOURCE_DIR}/daemon/protocol/mcbp/engine_errc_2_mcbp.cc
341                ${Memcached_SOURCE_DIR}/utilities/string_utilities.cc
342                benchmarks/benchmark_memory_tracker.cc
343                benchmarks/defragmenter_bench.cc
344                tests/module_tests/vbucket_test.cc)
345
346 TARGET_LINK_LIBRARIES(ep_engine_benchmarks benchmark platform xattr couchstore
347         cJSON dirutils engine_utilities gtest gmock JSON_checker mcd_util
348         cbcompress ${MALLOC_LIBRARIES})
349 TARGET_INCLUDE_DIRECTORIES(ep_engine_benchmarks PUBLIC
350                            ${benchmark_SOURCE_DIR}/include
351                            tests
352                            benchmarks
353                            ${Couchstore_SOURCE_DIR})
354
355 ADD_TEST(NAME ep-engine_atomic_ptr_test COMMAND ep-engine_atomic_ptr_test)
356 ADD_TEST(NAME ep-engine_couch-fs-stats_test COMMAND ep-engine_couch-fs-stats_test)
357 ADD_TEST(NAME ep-engine_ep_unit_tests COMMAND ep-engine_ep_unit_tests)
358 ADD_TEST(NAME ep-engine_hrtime_test COMMAND ep-engine_hrtime_test)
359 ADD_TEST(NAME ep-engine_misc_test COMMAND ep-engine_misc_test)
360
361 ADD_LIBRARY(timing_tests SHARED tests/module_tests/timing_tests.cc)
362 SET_TARGET_PROPERTIES(timing_tests PROPERTIES PREFIX "")
363 TARGET_LINK_LIBRARIES(timing_tests platform)
364
365 ADD_EXECUTABLE(ep-engine_sizes src/sizes.cc
366                                $<TARGET_OBJECTS:ep_objs>)
367 TARGET_LINK_LIBRARIES(ep-engine_sizes cJSON JSON_checker
368   engine_utilities couchstore
369   ${EP_FORESTDB_LIB} dirutils cbcompress platform phosphor xattr
370   ${LIBEVENT_LIBRARIES})
371
372 ADD_LIBRARY(ep_testsuite SHARED
373    tests/ep_testsuite.cc
374    src/ext_meta_parser.cc
375    tests/ep_testsuite_common.cc
376    tests/ep_test_apis.cc
377    tests/mock/mock_dcp.cc
378    ${Memcached_SOURCE_DIR}/utilities/string_utilities.cc)
379 SET_TARGET_PROPERTIES(ep_testsuite PROPERTIES PREFIX "")
380 TARGET_LINK_LIBRARIES(ep_testsuite couchstore dirutils JSON_checker platform
381                       xattr
382                       ${LIBEVENT_LIBRARIES})
383 ADD_DEPENDENCIES(ep_testsuite engine_testapp)
384
385 ADD_LIBRARY(ep_testsuite_basic SHARED
386    tests/ep_testsuite_basic.cc
387    src/ext_meta_parser.cc
388    tests/ep_testsuite_common.cc
389    tests/ep_test_apis.cc
390    tests/mock/mock_dcp.cc
391 )
392 SET_TARGET_PROPERTIES(ep_testsuite_basic PROPERTIES PREFIX "")
393 TARGET_LINK_LIBRARIES(ep_testsuite_basic engine_utilities JSON_checker dirutils
394                       platform ${LIBEVENT_LIBRARIES} ${SNAPPY_LIBRARIES})
395 ADD_DEPENDENCIES(ep_testsuite engine_testapp)
396
397 ADD_LIBRARY(ep_testsuite_dcp SHARED
398 tests/ep_testsuite_dcp.cc
399 src/ext_meta_parser.cc
400 tests/ep_testsuite_common.cc
401 tests/ep_test_apis.cc
402 tests/mock/mock_dcp.cc
403 )
404 SET_TARGET_PROPERTIES(ep_testsuite_dcp PROPERTIES PREFIX "")
405 TARGET_LINK_LIBRARIES(ep_testsuite_dcp cbcompress JSON_checker dirutils platform ${LIBEVENT_LIBRARIES} ${SNAPPY_LIBRARIES})
406 ADD_DEPENDENCIES(ep_testsuite_dcp engine_testapp)
407
408 ADD_LIBRARY(ep_testsuite_tap SHARED
409    tests/ep_testsuite_common.cc
410    tests/ep_testsuite_tap.cc
411    tests/ep_test_apis.cc
412    src/ext_meta_parser.cc)
413 SET_TARGET_PROPERTIES(ep_testsuite_tap PROPERTIES PREFIX "")
414 TARGET_LINK_LIBRARIES(ep_testsuite_tap JSON_checker dirutils platform ${LIBEVENT_LIBRARIES} ${SNAPPY_LIBRARIES})
415 ADD_DEPENDENCIES(ep_testsuite_tap engine_testapp)
416
417 ADD_LIBRARY(ep_testsuite_checkpoint SHARED
418    tests/ep_testsuite_common.cc
419    tests/ep_testsuite_checkpoint.cc
420    tests/ep_test_apis.cc
421    src/ext_meta_parser.cc)
422 SET_TARGET_PROPERTIES(ep_testsuite_checkpoint PROPERTIES PREFIX "")
423 TARGET_LINK_LIBRARIES(ep_testsuite_checkpoint JSON_checker dirutils platform ${LIBEVENT_LIBRARIES} ${SNAPPY_LIBRARIES})
424 ADD_DEPENDENCIES(ep_testsuite_checkpoint engine_testapp)
425
426 ADD_LIBRARY(ep_testsuite_xdcr SHARED
427    tests/ep_testsuite_common.cc
428    tests/ep_testsuite_xdcr.cc
429    tests/ep_test_apis.cc
430    src/ext_meta_parser.cc
431    ${Memcached_SOURCE_DIR}/utilities/string_utilities.cc)
432 SET_TARGET_PROPERTIES(ep_testsuite_xdcr PROPERTIES PREFIX "")
433 TARGET_LINK_LIBRARIES(ep_testsuite_xdcr JSON_checker dirutils platform xattr
434                       ${LIBEVENT_LIBRARIES} ${SNAPPY_LIBRARIES})
435 ADD_DEPENDENCIES(ep_testsuite_xdcr engine_testapp)
436
437 ADD_LIBRARY(ep_perfsuite SHARED
438    tests/ep_perfsuite.cc
439    src/ext_meta_parser.cc
440    tests/ep_testsuite_common.cc
441    tests/ep_test_apis.cc
442    tests/mock/mock_dcp.cc)
443 SET_TARGET_PROPERTIES(ep_perfsuite PROPERTIES PREFIX "")
444 TARGET_LINK_LIBRARIES(ep_perfsuite dirutils platform)
445 ADD_DEPENDENCIES(ep_perfsuite engine_testapp)
446
447 #ADD_CUSTOM_COMMAND(OUTPUT
448 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_0.c
449 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_1.c
450 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_2.c
451 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_3.c
452 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_4.c
453 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_5.c
454 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_6.c
455 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_7.c
456 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_8.c
457 #                     ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_9.c
458 #                  COMMAND
459 #                     ${PYTHON_EXECUTABLE} tests/module_tests/gen_engine_test.py
460 #                  DEPENDS
461 #                        tests/module_tests/gen_engine_test.py
462 #                        tests/module_tests/breakdancer.py
463 #                  COMMENT "Generating testsuite")
464 #
465 #ADD_LIBRARY(generated_testsuite SHARED
466 #            tests/suite_stubs.c
467 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_0.c
468 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_1.c
469 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_2.c
470 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_3.c
471 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_4.c
472 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_5.c
473 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_6.c
474 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_7.c
475 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_8.c
476 #            ${CMAKE_CURRENT_BINARY_DIR}/generated_suite_9.c)
477
478 #SET_TARGET_PROPERTIES(generated_testsuite PROPERTIES PREFIX "")
479
480 INSTALL(PROGRAMS
481         ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbepctl
482         ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbstats
483         ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbcompact
484         ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbvdiff
485         ${CMAKE_CURRENT_BINARY_DIR}/wrapper/cbvbucketctl
486         management/cbanalyze-core
487         DESTINATION bin)
488
489 INSTALL(PROGRAMS
490         management/cbepctl
491         management/cbstats
492         management/cbcompact
493         management/cbvdiff
494         management/cbvbucketctl
495         DESTINATION lib/python)
496
497 INSTALL(FILES
498         management/clitool.py
499         management/cli_auth_utils.py
500         management/mc_bin_client.py
501         management/mc_bin_server.py
502         management/memcacheConstants.py
503         management/tap.py
504         management/tap_example.py
505         DESTINATION lib/python)
506
507 INSTALL(FILES
508         docs/stats.org
509         DESTINATION share/doc/ep-engine)
510
511 INSTALL(TARGETS ep
512         RUNTIME DESTINATION bin
513         LIBRARY DESTINATION lib
514         ARCHIVE DESTINATION lib)
515
516
517 # Defines a testsuite which runs in full and value eviction
518 # (persistent), ephemeral buckets (which has no eviction).
519 FUNCTION(ADD_TESTSUITE name timeout)
520   CMAKE_PARSE_ARGUMENTS("arg" "SKIP_EPHEMERAL" "" "" ${ARGN} )
521
522   SET(_cmdline
523     ${Memcached_BINARY_DIR}/engine_testapp
524         -E $<TARGET_FILE:ep>
525         -T $<TARGET_FILE:${name}>)
526   ADD_TEST(NAME ${name}.value_eviction
527          COMMAND ${_cmdline} -v -e "dbname=./${name}.value_eviction.db")
528   ADD_TEST(NAME ${name}.full_eviction
529          COMMAND ${_cmdline} -v -e "item_eviction_policy=full_eviction$<SEMICOLON>dbname=./${name}.full_eviction.db")
530   SET_TESTS_PROPERTIES(${name}.value_eviction PROPERTIES TIMEOUT ${timeout})
531   SET_TESTS_PROPERTIES(${name}.full_eviction PROPERTIES TIMEOUT ${timeout})
532
533   IF(NOT arg_SKIP_EPHEMERAL)
534     ADD_TEST(NAME ${name}.ephemeral
535              COMMAND ${_cmdline} -v -e "bucket_type=ephemeral$<SEMICOLON>dbname=./${name}.ephemeral.db")
536     SET_TESTS_PROPERTIES(${name}.ephemeral PROPERTIES TIMEOUT ${timeout})
537   ENDIF()
538 ENDFUNCTION()
539
540 ADD_TESTSUITE(ep_testsuite 1800)
541
542 ADD_TESTSUITE(ep_testsuite_basic 600)
543
544 ADD_TESTSUITE(ep_testsuite_dcp 1200)
545
546 # TAP not supported for Ephemeral buckets.
547 ADD_TESTSUITE(ep_testsuite_tap 180 SKIP_EPHEMERAL)
548
549 ADD_TESTSUITE(ep_testsuite_checkpoint 120)
550
551 ADD_TESTSUITE(ep_testsuite_xdcr 120)
552
553 # ================================ PERF_TESTS ================================ #
554 SET(_ep_perfsuite_cmdline $<TARGET_FILE:engine_testapp> -E $<TARGET_FILE:ep> -T $<TARGET_FILE:ep_perfsuite> -v)
555
556 # Micro perf tests: value-only eviction mode. Note that it makes no sense to run
557 # these tests in full-eviction mode as we disable persistence - see MB-19504.
558 ADD_CUSTOM_TARGET(test-perfsuite
559                   COMMAND ${_ep_perfsuite_cmdline}
560                   DEPENDS engine_testapp
561                           ep
562                           ep_perfsuite
563                   VERBATIM)
564 ADD_TEST(NAME ep_perfsuite.value_eviction
565          COMMAND ${_ep_perfsuite_cmdline} -e "dbname=./ep_perfsuite.value_eviction.db")
566
567 ADD_TEST(NAME ep_perfsuite.ephemeral
568          COMMAND ${_ep_perfsuite_cmdline} -e "bucket_type=ephemeral$<SEMICOLON>dbname=./ep_perfsuite.ephemeral.db")
569
570 # ============================================================================ #
571
572 ENABLE_CODE_COVERAGE_REPORT()