1CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9)
2PROJECT(subjson)
3SET(SUBJSON_GTEST ${PROJECT_SOURCE_DIR}/contrib/gtest)
4INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
5
6INCLUDE(CTest)
7
8if (COUCHBASE_SERVER_BUILD)
9   INCLUDE_DIRECTORIES(AFTER ${Platform_SOURCE_DIR}/include)
10   ADD_DEFINITIONS(-DCOUCHBASE_BUILD)
11   ENABLE_CODE_COVERAGE_REPORT()
12   SET(EXTRA_LIBS platform)
13else(COUCHBASE_SERVER_BUILD)
14   SET(EXTRA_LIBS "")
15endif(COUCHBASE_SERVER_BUILD)
16
17if((CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
18    AND NOT COUCHBASE_SERVER_BUILD)
19    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -pedantic")
20endif()
21
22SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
23SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
24IF(WIN32)
25    SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
26    ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
27ELSE()
28    SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
29ENDIF()
30
31SET(SUBJSON_SRC subdoc/match.cc subdoc/operations.cc subdoc/path.cc
32    subdoc/util.cc)
33ADD_LIBRARY(subjson ${SUBJSON_SRC})
34TARGET_LINK_LIBRARIES(subjson ${EXTRA_LIBS})
35ADD_EXECUTABLE(bench bench.cc contrib/cliopts/cliopts.c)
36TARGET_LINK_LIBRARIES(bench subjson)
37
38IF(EXISTS ${SUBJSON_GTEST} OR EXISTS ${gtest_SOURCE_DIR})
39  ENABLE_TESTING()
40  ADD_SUBDIRECTORY(tests)
41ENDIF(EXISTS ${SUBJSON_GTEST} OR EXISTS ${gtest_SOURCE_DIR})
42