xref: /3.0.2-MP2/couchstore/CMakeLists.txt (revision 8fe9bd3b)
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/util.c src/views/values.c
48            src/views/view_group.c src/views/purgers.c
49            src/views/compaction.c src/quicksort.c ${COUCHSTORE_FILE_OPS})
50SET(COUCHSTORE_LIBRARIES ${V8_LIBRARIES} ${ICU_LIBRARIES} ${SNAPPY_LIBRARIES} platform)
51
52ADD_LIBRARY(couchstore SHARED ${COUCHSTORE_SOURCES})
53SET_TARGET_PROPERTIES(couchstore PROPERTIES COMPILE_FLAGS "-DLIBCOUCHSTORE_INTERNAL=1 -DLIBMAPREDUCE_INTERNAL=1")
54TARGET_LINK_LIBRARIES(couchstore ${COUCHSTORE_LIBRARIES})
55
56ADD_EXECUTABLE(couch_dbdump src/dbdump.c ${COUCHSTORE_SOURCES})
57SET_TARGET_PROPERTIES(couch_dbdump PROPERTIES COMPILE_FLAGS "-DLIBCOUCHSTORE_NO_VISIBILITY=1")
58TARGET_LINK_LIBRARIES(couch_dbdump ${COUCHSTORE_LIBRARIES})
59
60ADD_EXECUTABLE(couch_dbinfo src/dbinfo.c)
61TARGET_LINK_LIBRARIES(couch_dbinfo couchstore)
62
63ADD_EXECUTABLE(couch_compact src/compactor.c)
64TARGET_LINK_LIBRARIES(couch_compact couchstore)
65
66ADD_EXECUTABLE(couch_view_file_sorter src/views/bin/couch_view_file_sorter.c src/views/bin/util.c)
67TARGET_LINK_LIBRARIES(couch_view_file_sorter couchstore)
68
69ADD_EXECUTABLE(couch_view_file_merger src/views/bin/couch_view_file_merger.c src/views/bin/util.c)
70TARGET_LINK_LIBRARIES(couch_view_file_merger couchstore)
71
72ADD_EXECUTABLE(couch_view_index_builder src/views/bin/couch_view_index_builder.c src/views/bin/util.c)
73TARGET_LINK_LIBRARIES(couch_view_index_builder couchstore)
74
75ADD_EXECUTABLE(couch_view_group_cleanup src/views/bin/couch_view_group_cleanup.c src/views/bin/util.c)
76TARGET_LINK_LIBRARIES(couch_view_group_cleanup couchstore)
77
78ADD_EXECUTABLE(couch_view_index_updater src/views/bin/couch_view_index_updater.c src/views/bin/util.c)
79TARGET_LINK_LIBRARIES(couch_view_index_updater couchstore)
80
81ADD_EXECUTABLE(couch_view_group_compactor src/views/bin/couch_view_group_compactor.c src/views/bin/util.c)
82TARGET_LINK_LIBRARIES(couch_view_group_compactor couchstore)
83
84IF (INSTALL_HEADER_FILES)
85   INSTALL(FILES
86           include/libcouchstore/couch_db.h
87           include/libcouchstore/couch_index.h
88           include/libcouchstore/couch_common.h
89           include/libcouchstore/error.h
90           include/libcouchstore/file_ops.h
91           include/libcouchstore/visibility.h
92           DESTINATION include/libcouchstore)
93ENDIF(INSTALL_HEADER_FILES)
94
95INSTALL(TARGETS couchstore
96        RUNTIME DESTINATION bin
97        LIBRARY DESTINATION lib
98        ARCHIVE DESTINATION lib)
99
100INSTALL(TARGETS couch_dbdump
101                couch_dbinfo
102                couch_compact
103                couch_view_file_sorter
104                couch_view_file_merger
105                couch_view_index_builder
106                couch_view_group_cleanup
107                couch_view_index_updater
108                couch_view_group_compactor
109        RUNTIME DESTINATION bin)
110
111INSTALL(FILES
112        python/couchstore.py
113        DESTINATION lib/python)
114
115CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.cmake.h.in
116               ${CMAKE_CURRENT_BINARY_DIR}/config.h)
117
118# Tests:
119
120IF (LUA_FOUND)
121   ADD_EXECUTABLE(couchscript src/couchscript.cc)
122   SET_TARGET_PROPERTIES(couchscript PROPERTIES COMPILE_FLAGS
123                         -I${LUA_INCLUDE_DIR})
124   TARGET_LINK_LIBRARIES(couchscript couchstore ${LUA_LIBRARIES})
125
126   ADD_TEST(couchstore-localdoc
127            couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/localdoc.lua)
128   ADD_TEST(couchstore-corrupt
129            couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/corrupt.lua)
130   ADD_TEST(couchstore-bulk
131            couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/bulk.lua)
132   ADD_TEST(couchstore-changes-since-filter
133           couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/changessincefilter.lua)
134   ADD_TEST(couchstore-compact
135            couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/compact.lua)
136   ADD_TEST(couchstore-dropdel
137            couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/dropdel.lua)
138   ADD_TEST(couchstore-largefile
139            couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/largefile.lua)
140   ADD_TEST(couchstore-large
141            couchscript ${CMAKE_CURRENT_SOURCE_DIR}/tests/large.lua)
142ENDIF(LUA_FOUND)
143
144MACRO (M_ADD_PYTHON_TEST name pyfile)
145  ADD_TEST(${name} python ${pyfile})
146  SET_PROPERTY(TEST ${name} PROPERTY ENVIRONMENT
147    "PYTHONPATH=${CMAKE_CURRENT_SOURCE_DIR}/python"
148    "LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}")
149ENDMACRO()
150
151M_ADD_PYTHON_TEST(couchstore-purge ${CMAKE_CURRENT_SOURCE_DIR}/tests/purge.py)
152M_ADD_PYTHON_TEST(couchstore-rewind ${CMAKE_CURRENT_SOURCE_DIR}/tests/rewind.py)
153M_ADD_PYTHON_TEST(couchstore-changecount ${CMAKE_CURRENT_SOURCE_DIR}/tests/changecount.py)
154
155ADD_EXECUTABLE(couchstore_testapp tests/testapp.c
156	tests/file_merger_tests.c
157	tests/file_sorter_tests.c
158	tests/file_deduper_tests.c
159	tests/mapreduce/tests.c
160	tests/mapreduce/map.c
161	tests/mapreduce/reduce.c
162	tests/mapreduce/builtin.c
163	tests/views/tests.c
164	tests/views/collate_json_test.c
165	tests/views/index_headers.c
166	tests/views/bitmaps.c
167	tests/views/sorted_lists.c
168	tests/views/reductions.c
169	tests/views/keys.c
170	tests/views/values.c
171	tests/views/reducers.c
172	tests/views/cleanup.c
173	tests/views/spatial.c
174	tests/btree_purge/purge_tests.h
175	tests/btree_purge/tests.c
176	tests/btree_purge/purge.c
177        ${COUCHSTORE_SOURCES} )
178SET_TARGET_PROPERTIES(couchstore_testapp PROPERTIES
179                      COMPILE_FLAGS "-DLIBCOUCHSTORE_NO_VISIBILITY=1 -DTESTAPP=1")
180
181TARGET_LINK_LIBRARIES(couchstore_testapp ${COUCHSTORE_LIBRARIES})
182ADD_TEST(couchstore-testapp couchstore_testapp)
183
184ADD_SUBDIRECTORY(programs)
185