xref: /5.5.2/couchdb/CMakeLists.txt (revision 1fc9a81f)
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
13ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND} -j4
14                  DEPENDS dialyzer)
15
16IF(WIN32)
17  ADD_DEFINITIONS(-D__WIN32__)
18ELSEIF (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
19  SET(COUCHBASE_UNRESOLVED -Wl,-undefined -Wl,dynamic_lookup)
20ENDIF(WIN32)
21
22SET(ERLANG_COMPILE_FLAGS +debug_info -Werror
23  +nowarn_deprecated_function +nowarn_deprecated_type)
24
25
26EXECUTE_PROCESS(COMMAND git describe
27                WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
28                OUTPUT_VARIABLE COUCHDB_VERSION
29                ERROR_QUIET
30                OUTPUT_STRIP_TRAILING_WHITESPACE)
31
32CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test/python/set_view/run.py.tpl
33               ${CMAKE_CURRENT_BINARY_DIR}/test/python/set_view/run.py)
34
35SET(CMAKE_ERL_LIB_INSTALL_PREFIX "lib/couchdb/erlang/lib" CACHE STRING
36  "Installation prefix for CouchDB libs")
37MARK_AS_ADVANCED(CMAKE_ERL_LIB_INSTALL_PREFIX)
38
39ADD_SUBDIRECTORY(bin)
40ADD_SUBDIRECTORY(etc)
41ADD_SUBDIRECTORY(src)
42
43# Build the directory layout
44FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tmp/lib
45                    ${CMAKE_CURRENT_BINARY_DIR}/tmp/log
46                    ${CMAKE_CURRENT_BINARY_DIR}/tmp/run/couchdb)
47
48ADD_SUBDIRECTORY(test)
49
50
51SET(COUCHDB_PLT_FILE ${CMAKE_CURRENT_BINARY_DIR}/couchdb.plt)
52ADD_CUSTOM_TARGET(couchdb-check-plt
53       COMMAND
54           ${CMAKE_COMMAND}
55               -DPLT_FILE=${COUCHDB_PLT_FILE}
56               -P ${CMAKE_MODULE_PATH}/ErlangCheckPlt.cmake)
57
58ADD_CUSTOM_COMMAND(OUTPUT ${COUCHDB_PLT_FILE}
59       COMMAND
60          ${DIALYZER_EXECUTABLE} --output_plt ${COUCHDB_PLT_FILE}
61                   --build_plt
62                   -pa src/lhttpc
63                   -pa src/couchdb
64                   -pa src/couch_set_view
65                   -pa src/couch_index_merger
66                   -pa src/couch_view_parser
67                   -pa src/mapreduce
68                   -pa src/couch_dcp
69                   --apps
70                        compiler
71                        crypto
72                        erts
73                        inets
74                        kernel
75                        os_mon
76                        sasl
77                        ssl
78                        stdlib
79                        xmerl
80                        syntax_tools
81                        public_key
82                        tools
83                        hipe
84                        runtime_tools
85                   -r
86                        src/erlang-oauth
87                        src/etap
88                        src/mochiweb
89                        src/snappy
90                  VERBATIM )
91
92ADD_CUSTOM_TARGET(dialyzer
93       COMMAND
94          ${DIALYZER_EXECUTABLE} --plt ${COUCHDB_PLT_FILE}
95                   --verbose
96                   -Wno_improper_lists
97                   -pa src/couchdb
98                   -pa src/couch_set_view
99                   -pa src/couch_index_merger
100                   -pa src/couch_view_parser
101                   -pa src/mapreduce
102                   -pa src/lhttpc
103                   -pa src/snappy
104                   -pa src/couch_dcp
105                   -r
106                        src/couchdb
107                        src/couch_set_view
108                        src/couch_index_merger/ebin
109                        src/couch_view_parser
110                        src/snappy
111                        src/lhttpc
112                        src/mapreduce
113                        src/couch_dcp
114       DEPENDS
115          couchdb-check-plt
116          ${COUCHDB_PLT_FILE})
117