xref: /3.0.2-MP2/couchstore/CMakeLists.txt (revision 744ff400)
1PROJECT(Couchstore)
2CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
3
4INCLUDE(CheckFunctionExists)
5INCLUDE(CheckIncludeFile)
6INCLUDE(CheckIncludeFiles)
7INCLUDE(CheckLibraryExists)
8INCLUDE(CheckSymbolExists)
9INCLUDE(CheckTypeSize)
10
11INCLUDE_DIRECTORIES(BEFORE ${CMAKE_INSTALL_PREFIX}/include
12                           ${CMAKE_CURRENT_SOURCE_DIR}/include
13                           ${CMAKE_CURRENT_SOURCE_DIR}/src
14                           ${CMAKE_CURRENT_BINARY_DIR}
15                           ${CMAKE_CURRENT_SOURCE_DIR}
16                           ${Platform_SOURCE_DIR}/include)
17
18INCLUDE_DIRECTORIES(AFTER ${ICU_INCLUDE_DIR}
19                          ${V8_INCLUDE_DIR}
20                          ${SNAPPY_INCLUDE_DIR})
21
22CHECK_INCLUDE_FILES("netinet/in.h" HAVE_NETINET_IN_H)
23CHECK_INCLUDE_FILES("inttypes.h" HAVE_INTTYPES_H)
24CHECK_INCLUDE_FILES("unistd.h" HAVE_UNISTD_H)
25CHECK_SYMBOL_EXISTS(fdatasync "unistd.h" HAVE_FDATASYNC)
26CHECK_SYMBOL_EXISTS(qsort_r "stdlib.h" HAVE_QSORT_R)
27
28IF (WIN32)
29  SET(COUCHSTORE_FILE_OPS "src/os_win.c")
30ELSE(WIN32)
31  SET(COUCHSTORE_FILE_OPS "src/os.c")
32ENDIF(WIN32)
33
34SET(COUCHSTORE_SOURCES src/arena.cc src/bitfield.c src/btree_modify.cc
35            src/btree_read.cc src/couch_db.cc src/couch_file_read.cc
36            src/couch_file_write.cc src/couch_save.cc src/crc32.c
37            src/db_compact.cc src/file_merger.cc src/file_name_utils.c
38            src/file_sorter.cc src/iobuffer.cc src/llmsort.cc
39            src/mergesort.cc src/node_types.cc src/reduces.cc
40            src/rfc1321/md5c.c src/strerror.cc src/tree_writer.cc
41            src/util.cc src/views/bitmap.c src/views/collate_json.c
42            src/views/file_merger.c src/views/file_sorter.c
43            src/views/index_header.c src/views/keys.c
44            src/views/mapreduce/mapreduce.cc
45            src/views/mapreduce/mapreduce_c.cc src/views/reducers.c
46            src/views/reductions.c src/views/sorted_list.c
47            src/views/spatial.c src/views/spatial_modify.c
48            src/views/util.c src/views/values.c
49            src/views/view_group.c src/views/purgers.c
50            src/views/compaction.c src/quicksort.c ${COUCHSTORE_FILE_OPS})
51SET(COUCHSTORE_LIBRARIES ${V8_LIBRARIES} ${ICU_LIBRARIES} ${SNAPPY_LIBRARIES} platform)
52
53ADD_LIBRARY(couchstore SHARED ${COUCHSTORE_SOURCES})
54SET_TARGET_PROPERTIES(couchstore PROPERTIES COMPILE_FLAGS "-DLIBCOUCHSTORE_INTERNAL=1 -DLIBMAPREDUCE_INTERNAL=1")
55TARGET_LINK_LIBRARIES(couchstore ${COUCHSTORE_LIBRARIES})
56
57ADD_EXECUTABLE(couch_dbdump src/dbdump.c ${COUCHSTORE_SOURCES})
58SET_TARGET_PROPERTIES(couch_dbdump PROPERTIES COMPILE_FLAGS "-DLIBCOUCHSTORE_NO_VISIBILITY=1")
59TARGET_LINK_LIBRARIES(couch_dbdump ${COUCHSTORE_LIBRARIES})
60
61ADD_EXECUTABLE(couch_dbinfo src/dbinfo.c)
62TARGET_LINK_LIBRARIES(couch_dbinfo couchstore)
63
64ADD_EXECUTABLE(couch_compact src/compactor.c)
65TARGET_LINK_LIBRARIES(couch_compact couchstore)
66
67ADD_EXECUTABLE(couch_view_file_sorter src/views/bin/couch_view_file_sorter.c src/views/bin/util.c)
68TARGET_LINK_LIBRARIES(couch_view_file_sorter couchstore)
69
70ADD_EXECUTABLE(couch_view_file_merger src/views/bin/couch_view_file_merger.c src/views/bin/util.c)
71TARGET_LINK_LIBRARIES(couch_view_file_merger couchstore)
72
73ADD_EXECUTABLE(couch_view_index_builder src/views/bin/couch_view_index_builder.c src/views/bin/util.c)
74TARGET_LINK_LIBRARIES(couch_view_index_builder couchstore)
75
76ADD_EXECUTABLE(couch_view_group_cleanup src/views/bin/couch_view_group_cleanup.c src/views/bin/util.c)
77TARGET_LINK_LIBRARIES(couch_view_group_cleanup couchstore)
78
79ADD_EXECUTABLE(couch_view_index_updater src/views/bin/couch_view_index_updater.c src/views/bin/util.c)
80TARGET_LINK_LIBRARIES(couch_view_index_updater couchstore)
81
82ADD_EXECUTABLE(couch_view_group_compactor src/views/bin/couch_view_group_compactor.c src/views/bin/util.c)
83TARGET_LINK_LIBRARIES(couch_view_group_compactor couchstore)
84
85IF (INSTALL_HEADER_FILES)
86   INSTALL(FILES
87           include/libcouchstore/couch_db.h
88           include/libcouchstore/couch_index.h
89           include/libcouchstore/couch_common.h
90           include/libcouchstore/error.h
91           include/libcouchstore/file_ops.h
92           include/libcouchstore/visibility.h
93           DESTINATION include/libcouchstore)
94ENDIF(INSTALL_HEADER_FILES)
95
96INSTALL(TARGETS couchstore
97        RUNTIME DESTINATION bin
98        LIBRARY DESTINATION lib
99        ARCHIVE DESTINATION lib)
100
101INSTALL(TARGETS couch_dbdump
102                couch_dbinfo
103                couch_compact
104                couch_view_file_sorter
105                couch_view_file_merger
106                couch_view_index_builder
107                couch_view_group_cleanup
108                couch_view_index_updater
109                couch_view_group_compactor
110        RUNTIME DESTINATION bin)
111
112INSTALL(FILES
113        python/couchstore.py
114        DESTINATION lib/python)
115
116CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.cmake.h.in
117               ${CMAKE_CURRENT_BINARY_DIR}/config.h)
118
119# Tests:
120
121IF (LUA_FOUND)
122   ADD_EXECUTABLE(couchscript src/couchscript.cc)
123   SET_TARGET_PROPERTIES(couchscript PROPERTIES COMPILE_FLAGS
124                         -I${LUA_INCLUDE_DIR})
125   TARGET_LINK_LIBRARIES(couchscript couchstore ${LUA_LIBRARIES})
126
127   ADD_TEST(couchstore-localdoc
128            couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/localdoc.lua)
129   ADD_TEST(couchstore-corrupt
130            couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/corrupt.lua)
131   ADD_TEST(couchstore-bulk
132            couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/bulk.lua)
133   ADD_TEST(couchstore-changes-since-filter
134           couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/changessincefilter.lua)
135   ADD_TEST(couchstore-compact
136            couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/compact.lua)
137   ADD_TEST(couchstore-dropdel
138            couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/dropdel.lua)
139   ADD_TEST(couchstore-largefile
140            couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/largefile.lua)
141   ADD_TEST(couchstore-large
142            couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/large.lua)
143ENDIF(LUA_FOUND)
144
145MACRO (M_ADD_PYTHON_TEST name pyfile)
146  ADD_TEST(${name} python ${pyfile})
147  SET_PROPERTY(TEST ${name} PROPERTY ENVIRONMENT
148    "PYTHONPATH=${CMAKE_CURRENT_SOURCE_DIR}/python"
149    "LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}")
150ENDMACRO()
151
152M_ADD_PYTHON_TEST(couchstore-purge ${CMAKE_CURRENT_SOURCE_DIR}/tests/purge.py)
153M_ADD_PYTHON_TEST(couchstore-rewind ${CMAKE_CURRENT_SOURCE_DIR}/tests/rewind.py)
154M_ADD_PYTHON_TEST(couchstore-changecount ${CMAKE_CURRENT_SOURCE_DIR}/tests/changecount.py)
155
156ADD_EXECUTABLE(couchstore_testapp tests/testapp.c
157	tests/file_merger_tests.c
158	tests/file_sorter_tests.c
159	tests/file_deduper_tests.c
160	tests/mapreduce/tests.c
161	tests/mapreduce/map.c
162	tests/mapreduce/reduce.c
163	tests/mapreduce/builtin.c
164	tests/views/tests.c
165	tests/views/collate_json_test.c
166	tests/views/index_headers.c
167	tests/views/bitmaps.c
168	tests/views/sorted_lists.c
169	tests/views/reductions.c
170	tests/views/keys.c
171	tests/views/values.c
172	tests/views/reducers.c
173	tests/views/cleanup.c
174	tests/views/spatial.c
175	tests/btree_purge/purge_tests.h
176	tests/btree_purge/tests.c
177	tests/btree_purge/purge.c
178        ${COUCHSTORE_SOURCES} )
179SET_TARGET_PROPERTIES(couchstore_testapp PROPERTIES
180                      COMPILE_FLAGS "-DLIBCOUCHSTORE_NO_VISIBILITY=1 -DTESTAPP=1")
181
182TARGET_LINK_LIBRARIES(couchstore_testapp ${COUCHSTORE_LIBRARIES})
183ADD_TEST(couchstore-testapp couchstore_testapp)
184
185ADD_SUBDIRECTORY(programs)
186