contrib: add ParseTrace prototype to parser skeleton
[oweals/jsonpath.git] / CMakeLists.txt
index 9b2fd50..8db786e 100644 (file)
@@ -1,9 +1,9 @@
 cmake_minimum_required(VERSION 2.6)
 
 PROJECT(jsonpath C)
-ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -Wmissing-declarations)
+ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -Wmissing-declarations -Wno-error=unused-variable -ffunction-sections -D_GNU_SOURCE)
 
-SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
+SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,--gc-sections")
 
 IF(APPLE)
   INCLUDE_DIRECTORIES(/opt/local/include)
@@ -23,25 +23,23 @@ IF(JSONC_FOUND)
   INCLUDE_DIRECTORIES(${JSONC_INCLUDE_DIRS})
 ENDIF()
 
-FIND_PACKAGE(BISON REQUIRED)
-IF(BISON_FOUND)
-    ADD_CUSTOM_COMMAND(
-      OUTPUT parser.c
-      COMMAND ${BISON_EXECUTABLE} parser.y
-      COMMENT "Generating parser.c"
-    )
-ENDIF()
-
-FIND_PACKAGE(FLEX REQUIRED)
-IF(FLEX_FOUND)
-    ADD_CUSTOM_COMMAND(
-      OUTPUT lexer.c
-      COMMAND ${FLEX_EXECUTABLE} lexer.l
-      COMMENT "Generating lexer.c"
-    )
-ENDIF()
-
-ADD_EXECUTABLE(jsonpath main.c lexer.c parser.c matcher.c)
+ADD_CUSTOM_COMMAND(
+  OUTPUT contrib/lemon
+  DEPENDS contrib/lemon.c contrib/lempar.c
+  COMMAND gcc -o contrib/lemon contrib/lemon.c
+  COMMENT "Generating lemon parser generator"
+)
+
+ADD_CUSTOM_COMMAND(
+  OUTPUT parser.c
+  DEPENDS parser.y contrib/lemon
+  COMMAND ./contrib/lemon parser.y
+  COMMENT "Generating parser.c"
+)
+
+SET_PROPERTY(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "lemon;parser.h;parser.out")
+SET_SOURCE_FILES_PROPERTIES("parser.c" PROPERTIES GENERATED TRUE)
+ADD_EXECUTABLE(jsonpath main.c ast.c lexer.c parser.c matcher.c)
 TARGET_LINK_LIBRARIES(jsonpath ubox ${json})
 
 INSTALL(TARGETS jsonpath RUNTIME DESTINATION bin)