1c6a29006STrond NorbyePROJECT(CouchDB)
2c6a29006STrond NorbyeCMAKE_MINIMUM_REQUIRED(VERSION 2.8)
382a92570SVolker MischeADD_ERLANG_INCLUDE_DIR(${CMAKE_CURRENT_SOURCE_DIR}/src/couchdb)
4c6a29006STrond Norbye
5c6a29006STrond NorbyeSET(COUCHDB_RUNTEST ${CMAKE_CURRENT_SOURCE_DIR}/test/etap/runtest.py)
6c6a29006STrond NorbyeSET(COUCHDB_BIN_PATH ${CMAKE_CURRENT_BINARY_DIR})
7c6a29006STrond NorbyeSET(COUCHSTORE_BIN_PATH ${CMAKE_BINARY_DIR}/couchstore)
8c6a29006STrond NorbyeSET(abs_top_srcdir ${CMAKE_CURRENT_SOURCE_DIR})
9c6a29006STrond NorbyeSET(abs_top_builddir ${CMAKE_CURRENT_BINARY_DIR})
101fc9a81fSVolker MischeFILE(GLOB_RECURSE COUCHDB_ALL_ERLANG_HEADERS
111fc9a81fSVolker Mische     FOLLOW_SYMLINKS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.hrl)
12c6a29006STrond Norbye
138be914ddSharshaIF(WIN32)
148be914ddSharshaADD_CUSTOM_TARGET(check
158be914ddSharsha    COMMAND ${CMAKE_COMMAND} -E echo "Running unit tests with ipv4 bind address"
168be914ddSharsha    COMMAND ${CMAKE_COMMAND} -E env ipv6=false ${CMAKE_CTEST_COMMAND} --output-on-failure
178be914ddSharsha    COMMAND ${CMAKE_COMMAND} -E echo "Running unit tests with ipv6 bind address"
188be914ddSharsha    COMMAND ${CMAKE_COMMAND} -E env ipv6=true ${CMAKE_CTEST_COMMAND} --output-on-failure
198be914ddSharsha    DEPENDS dialyzer
208be914ddSharsha    )
218be914ddSharshaELSE(WIN32)
228be914ddSharshaADD_CUSTOM_TARGET(check
238be914ddSharsha    COMMAND ${CMAKE_COMMAND} -E echo "Running unit tests with ipv4 bind address"
248be914ddSharsha    COMMAND ${CMAKE_COMMAND} -E env ipv6=false ${CMAKE_CTEST_COMMAND} --output-on-failure -j4
258be914ddSharsha    COMMAND ${CMAKE_COMMAND} -E echo "Running unit tests with ipv6 bind address"
268be914ddSharsha    COMMAND ${CMAKE_COMMAND} -E env ipv6=true ${CMAKE_CTEST_COMMAND} --output-on-failure -j4
278be914ddSharsha    DEPENDS dialyzer
288be914ddSharsha    )
298be914ddSharshaENDIF(WIN32)
30c6a29006STrond Norbye
31c6a29006STrond NorbyeIF(WIN32)
32c6a29006STrond Norbye  ADD_DEFINITIONS(-D__WIN32__)
3356a3d41cSTrond NorbyeELSEIF (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
34c6a29006STrond Norbye  SET(COUCHBASE_UNRESOLVED -Wl,-undefined -Wl,dynamic_lookup)
35c6a29006STrond NorbyeENDIF(WIN32)
36c6a29006STrond Norbye
376dc23a93SAliaksey ArtamonauSET(ERLANG_COMPILE_FLAGS +debug_info -Werror
386dc23a93SAliaksey Artamonau  +nowarn_deprecated_function +nowarn_deprecated_type)
39c6a29006STrond Norbye
40c6a29006STrond Norbye
41c6a29006STrond NorbyeEXECUTE_PROCESS(COMMAND git describe
42c6a29006STrond Norbye                WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
43c6a29006STrond Norbye                OUTPUT_VARIABLE COUCHDB_VERSION
44c6a29006STrond Norbye                ERROR_QUIET
45c6a29006STrond Norbye                OUTPUT_STRIP_TRAILING_WHITESPACE)
46c6a29006STrond Norbye
47c6a29006STrond NorbyeCONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test/python/set_view/run.py.tpl
48c6a29006STrond Norbye               ${CMAKE_CURRENT_BINARY_DIR}/test/python/set_view/run.py)
49c6a29006STrond Norbye
503e01a9d3SChris HillerySET(CMAKE_ERL_LIB_INSTALL_PREFIX "lib/couchdb/erlang/lib" CACHE STRING
513e01a9d3SChris Hillery  "Installation prefix for CouchDB libs")
523e01a9d3SChris HilleryMARK_AS_ADVANCED(CMAKE_ERL_LIB_INSTALL_PREFIX)
53c6a29006STrond Norbye
54c6a29006STrond NorbyeADD_SUBDIRECTORY(bin)
55c6a29006STrond NorbyeADD_SUBDIRECTORY(etc)
56c6a29006STrond NorbyeADD_SUBDIRECTORY(src)
57c6a29006STrond Norbye
58c6a29006STrond Norbye# Build the directory layout
59c6a29006STrond NorbyeFILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tmp/lib
60c6a29006STrond Norbye                    ${CMAKE_CURRENT_BINARY_DIR}/tmp/log
61c6a29006STrond Norbye                    ${CMAKE_CURRENT_BINARY_DIR}/tmp/run/couchdb)
62c6a29006STrond Norbye
63c6a29006STrond NorbyeADD_SUBDIRECTORY(test)
64c6a29006STrond Norbye
6582a92570SVolker Mische
6682a92570SVolker MischeSET(COUCHDB_PLT_FILE ${CMAKE_CURRENT_BINARY_DIR}/couchdb.plt)
6782a92570SVolker MischeADD_CUSTOM_TARGET(couchdb-check-plt
6882a92570SVolker Mische       COMMAND
6982a92570SVolker Mische           ${CMAKE_COMMAND}
7082a92570SVolker Mische               -DPLT_FILE=${COUCHDB_PLT_FILE}
7182a92570SVolker Mische               -P ${CMAKE_MODULE_PATH}/ErlangCheckPlt.cmake)
7282a92570SVolker Mische
7382a92570SVolker MischeADD_CUSTOM_COMMAND(OUTPUT ${COUCHDB_PLT_FILE}
74c6a29006STrond Norbye       COMMAND
750bca9c80SVolker Mische          ${DIALYZER_EXECUTABLE} --output_plt ${COUCHDB_PLT_FILE}
76c6a29006STrond Norbye                   --build_plt
77c6a29006STrond Norbye                   -pa src/lhttpc
78c6a29006STrond Norbye                   -pa src/couchdb
79c6a29006STrond Norbye                   -pa src/couch_set_view
80c6a29006STrond Norbye                   -pa src/couch_index_merger
81c6a29006STrond Norbye                   -pa src/couch_view_parser
82c6a29006STrond Norbye                   -pa src/mapreduce
83e0297e7aSharsha                   -pa src/couch_dcp
84c6a29006STrond Norbye                   --apps
85c6a29006STrond Norbye                        compiler
86c6a29006STrond Norbye                        crypto
87c6a29006STrond Norbye                        erts
88c6a29006STrond Norbye                        inets
89c6a29006STrond Norbye                        kernel
90c6a29006STrond Norbye                        os_mon
91c6a29006STrond Norbye                        sasl
92c6a29006STrond Norbye                        ssl
93c6a29006STrond Norbye                        stdlib
94c6a29006STrond Norbye                        xmerl
95c6a29006STrond Norbye                        syntax_tools
96c6a29006STrond Norbye                        public_key
97c6a29006STrond Norbye                        tools
98c6a29006STrond Norbye                        hipe
99c6a29006STrond Norbye                        runtime_tools
100c6a29006STrond Norbye                   -r
101c6a29006STrond Norbye                        src/erlang-oauth
102c6a29006STrond Norbye                        src/etap
103c6a29006STrond Norbye                        src/mochiweb
104c6a29006STrond Norbye                        src/snappy
105c6a29006STrond Norbye                  VERBATIM )
106c6a29006STrond Norbye
107c6a29006STrond NorbyeADD_CUSTOM_TARGET(dialyzer
108c6a29006STrond Norbye       COMMAND
1090bca9c80SVolker Mische          ${DIALYZER_EXECUTABLE} --plt ${COUCHDB_PLT_FILE}
110c6a29006STrond Norbye                   --verbose
111c6a29006STrond Norbye                   -Wno_improper_lists
112c6a29006STrond Norbye                   -pa src/couchdb
113c6a29006STrond Norbye                   -pa src/couch_set_view
114c6a29006STrond Norbye                   -pa src/couch_index_merger
115c6a29006STrond Norbye                   -pa src/couch_view_parser
116c6a29006STrond Norbye                   -pa src/mapreduce
117c6a29006STrond Norbye                   -pa src/lhttpc
118c6a29006STrond Norbye                   -pa src/snappy
119e0297e7aSharsha                   -pa src/couch_dcp
120c6a29006STrond Norbye                   -r
121c6a29006STrond Norbye                        src/couchdb
122c6a29006STrond Norbye                        src/couch_set_view
123c6a29006STrond Norbye                        src/couch_index_merger/ebin
124c6a29006STrond Norbye                        src/couch_view_parser
125c6a29006STrond Norbye                        src/snappy
126c6a29006STrond Norbye                        src/lhttpc
127c6a29006STrond Norbye                        src/mapreduce
128e0297e7aSharsha                        src/couch_dcp
12982a92570SVolker Mische       DEPENDS
13082a92570SVolker Mische          couchdb-check-plt
13182a92570SVolker Mische          ${COUCHDB_PLT_FILE})
132