xref: /5.5.2/couchdb/CMakeLists.txt (revision 8be914dd)
1PROJECT(CouchDB)
2CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
3ADD_ERLANG_INCLUDE_DIR(${CMAKE_CURRENT_SOURCE_DIR}/src/couchdb)
4
5SET(COUCHDB_RUNTEST ${CMAKE_CURRENT_SOURCE_DIR}/test/etap/runtest.py)
6SET(COUCHDB_BIN_PATH ${CMAKE_CURRENT_BINARY_DIR})
7SET(COUCHSTORE_BIN_PATH ${CMAKE_BINARY_DIR}/couchstore)
8SET(abs_top_srcdir ${CMAKE_CURRENT_SOURCE_DIR})
9SET(abs_top_builddir ${CMAKE_CURRENT_BINARY_DIR})
10FILE(GLOB_RECURSE COUCHDB_ALL_ERLANG_HEADERS
11     FOLLOW_SYMLINKS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.hrl)
12
13IF(WIN32)
14ADD_CUSTOM_TARGET(check
15    COMMAND ${CMAKE_COMMAND} -E echo "Running unit tests with ipv4 bind address"
16    COMMAND ${CMAKE_COMMAND} -E env ipv6=false ${CMAKE_CTEST_COMMAND} --output-on-failure
17    COMMAND ${CMAKE_COMMAND} -E echo "Running unit tests with ipv6 bind address"
18    COMMAND ${CMAKE_COMMAND} -E env ipv6=true ${CMAKE_CTEST_COMMAND} --output-on-failure
19    DEPENDS dialyzer
20    )
21ELSE(WIN32)
22ADD_CUSTOM_TARGET(check
23    COMMAND ${CMAKE_COMMAND} -E echo "Running unit tests with ipv4 bind address"
24    COMMAND ${CMAKE_COMMAND} -E env ipv6=false ${CMAKE_CTEST_COMMAND} --output-on-failure -j4
25    COMMAND ${CMAKE_COMMAND} -E echo "Running unit tests with ipv6 bind address"
26    COMMAND ${CMAKE_COMMAND} -E env ipv6=true ${CMAKE_CTEST_COMMAND} --output-on-failure -j4
27    DEPENDS dialyzer
28    )
29ENDIF(WIN32)
30
31IF(WIN32)
32  ADD_DEFINITIONS(-D__WIN32__)
33ELSEIF (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
34  SET(COUCHBASE_UNRESOLVED -Wl,-undefined -Wl,dynamic_lookup)
35ENDIF(WIN32)
36
37SET(ERLANG_COMPILE_FLAGS +debug_info -Werror
38  +nowarn_deprecated_function +nowarn_deprecated_type)
39
40
41EXECUTE_PROCESS(COMMAND git describe
42                WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
43                OUTPUT_VARIABLE COUCHDB_VERSION
44                ERROR_QUIET
45                OUTPUT_STRIP_TRAILING_WHITESPACE)
46
47CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test/python/set_view/run.py.tpl
48               ${CMAKE_CURRENT_BINARY_DIR}/test/python/set_view/run.py)
49
50SET(CMAKE_ERL_LIB_INSTALL_PREFIX "lib/couchdb/erlang/lib" CACHE STRING
51  "Installation prefix for CouchDB libs")
52MARK_AS_ADVANCED(CMAKE_ERL_LIB_INSTALL_PREFIX)
53
54ADD_SUBDIRECTORY(bin)
55ADD_SUBDIRECTORY(etc)
56ADD_SUBDIRECTORY(src)
57
58# Build the directory layout
59FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tmp/lib
60                    ${CMAKE_CURRENT_BINARY_DIR}/tmp/log
61                    ${CMAKE_CURRENT_BINARY_DIR}/tmp/run/couchdb)
62
63ADD_SUBDIRECTORY(test)
64
65
66SET(COUCHDB_PLT_FILE ${CMAKE_CURRENT_BINARY_DIR}/couchdb.plt)
67ADD_CUSTOM_TARGET(couchdb-check-plt
68       COMMAND
69           ${CMAKE_COMMAND}
70               -DPLT_FILE=${COUCHDB_PLT_FILE}
71               -P ${CMAKE_MODULE_PATH}/ErlangCheckPlt.cmake)
72
73ADD_CUSTOM_COMMAND(OUTPUT ${COUCHDB_PLT_FILE}
74       COMMAND
75          ${DIALYZER_EXECUTABLE} --output_plt ${COUCHDB_PLT_FILE}
76                   --build_plt
77                   -pa src/lhttpc
78                   -pa src/couchdb
79                   -pa src/couch_set_view
80                   -pa src/couch_index_merger
81                   -pa src/couch_view_parser
82                   -pa src/mapreduce
83                   -pa src/couch_dcp
84                   --apps
85                        compiler
86                        crypto
87                        erts
88                        inets
89                        kernel
90                        os_mon
91                        sasl
92                        ssl
93                        stdlib
94                        xmerl
95                        syntax_tools
96                        public_key
97                        tools
98                        hipe
99                        runtime_tools
100                   -r
101                        src/erlang-oauth
102                        src/etap
103                        src/mochiweb
104                        src/snappy
105                  VERBATIM )
106
107ADD_CUSTOM_TARGET(dialyzer
108       COMMAND
109          ${DIALYZER_EXECUTABLE} --plt ${COUCHDB_PLT_FILE}
110                   --verbose
111                   -Wno_improper_lists
112                   -pa src/couchdb
113                   -pa src/couch_set_view
114                   -pa src/couch_index_merger
115                   -pa src/couch_view_parser
116                   -pa src/mapreduce
117                   -pa src/lhttpc
118                   -pa src/snappy
119                   -pa src/couch_dcp
120                   -r
121                        src/couchdb
122                        src/couch_set_view
123                        src/couch_index_merger/ebin
124                        src/couch_view_parser
125                        src/snappy
126                        src/lhttpc
127                        src/mapreduce
128                        src/couch_dcp
129       DEPENDS
130          couchdb-check-plt
131          ${COUCHDB_PLT_FILE})
132