xref: /6.6.0/subjson/CMakeLists.txt (revision f37e40ed)
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)
7include(check_unit_test_enabled)
8
9check_unit_test_enabled(subjson COUCHBASE_SUBJSON_BUILD_UNIT_TESTS)
10
11if (COUCHBASE_SERVER_BUILD)
12   INCLUDE_DIRECTORIES(AFTER ${Platform_SOURCE_DIR}/include)
13   ADD_DEFINITIONS(-DCOUCHBASE_BUILD)
14   ENABLE_CODE_COVERAGE_REPORT()
15   SET(EXTRA_LIBS platform)
16else(COUCHBASE_SERVER_BUILD)
17   SET(EXTRA_LIBS "")
18endif(COUCHBASE_SERVER_BUILD)
19
20if((CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
21    AND NOT COUCHBASE_SERVER_BUILD)
22    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -pedantic")
23endif()
24
25SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
26SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
27IF(WIN32)
28    SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
29    ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
30ELSE()
31    SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
32ENDIF()
33
34SET(SUBJSON_SRC subdoc/match.cc subdoc/operations.cc subdoc/path.cc
35    subdoc/util.cc)
36ADD_LIBRARY(subjson ${SUBJSON_SRC})
37TARGET_LINK_LIBRARIES(subjson ${EXTRA_LIBS})
38
39if (COUCHBASE_SUBJSON_BUILD_UNIT_TESTS)
40    ADD_EXECUTABLE(bench bench.cc contrib/cliopts/cliopts.c)
41    TARGET_LINK_LIBRARIES(bench subjson)
42
43    IF (EXISTS ${SUBJSON_GTEST} OR EXISTS ${gtest_SOURCE_DIR})
44        ENABLE_TESTING()
45        ADD_SUBDIRECTORY(tests)
46    ENDIF (EXISTS ${SUBJSON_GTEST} OR EXISTS ${gtest_SOURCE_DIR})
47endif (COUCHBASE_SUBJSON_BUILD_UNIT_TESTS)
48