parser: change exitcode in case of oom errors
[project/jsonpath.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2
3 PROJECT(jsonpath C)
4 ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -Wmissing-declarations)
5
6 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
7
8 IF(APPLE)
9   INCLUDE_DIRECTORIES(/opt/local/include)
10   LINK_DIRECTORIES(/opt/local/lib)
11 ENDIF()
12
13 find_library(json NAMES json-c json)
14
15 IF(DEBUG)
16   ADD_DEFINITIONS(-DDEBUG -g3)
17 ENDIF()
18
19 INCLUDE(FindPkgConfig)
20 PKG_CHECK_MODULES(JSONC json-c json)
21 IF(JSONC_FOUND)
22   ADD_DEFINITIONS(-DJSONC)
23   INCLUDE_DIRECTORIES(${JSONC_INCLUDE_DIRS})
24 ENDIF()
25
26 FIND_PACKAGE(BISON REQUIRED)
27 IF(BISON_FOUND)
28     ADD_CUSTOM_COMMAND(
29       OUTPUT parser.c
30       DEPENDS parser.y
31       COMMAND ${BISON_EXECUTABLE} parser.y
32       COMMENT "Generating parser.c"
33     )
34 ENDIF()
35
36 FIND_PACKAGE(FLEX REQUIRED)
37 IF(FLEX_FOUND)
38     ADD_CUSTOM_COMMAND(
39       OUTPUT lexer.c
40       DEPENDS lexer.l
41       COMMAND ${FLEX_EXECUTABLE} lexer.l
42       COMMENT "Generating lexer.c"
43     )
44 ENDIF()
45
46 SET_PROPERTY(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "lexer.h;parser.h")
47 SET_SOURCE_FILES_PROPERTIES("lexer.c;parser.c" PROPERTIES GENERATED TRUE)
48 ADD_EXECUTABLE(jsonpath main.c lexer.c parser.c matcher.c)
49 TARGET_LINK_LIBRARIES(jsonpath ubox ${json})
50
51 INSTALL(TARGETS jsonpath RUNTIME DESTINATION bin)