-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
34 lines (23 loc) · 1.09 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
cmake_minimum_required(VERSION 3.21)
project(Hocon VERSION 1.0 LANGUAGES C)
set(SRC_DIR "src")
set(PARSER_DIR "${CMAKE_CURRENT_BINARY_DIR}")
find_package(FLEX 2.6 REQUIRED)
find_package(BISON 3.0 REQUIRED)
set(LEXER_OUT "${PARSER_DIR}/scanner.c")
set(PARSER_OUT "${PARSER_DIR}/parser.c")
option(ASAN "Build with address sanitizer" OFF)
if(ASAN)
set(CMAKE_BUILD_TYPE Debug)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
endif(ASAN)
flex_target(LEXER "scanner.l" "${LEXER_OUT}" DEFINES_FILE "${PARSER_DIR}/scanner.h")
bison_target(PARSER "parser.y" "${PARSER_OUT}" DEFINES_FILE "${PARSER_DIR}/parser.h")
add_flex_bison_dependency(LEXER PARSER)
add_library(hocon SHARED "${LEXER_OUT}" "${PARSER_OUT}" "cJSON.c" "hocon.c")
target_include_directories(hocon PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(hocon PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
add_executable(hocon_parser ${CMAKE_CURRENT_SOURCE_DIR}/main.c hocon)
target_include_directories(hocon_parser PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(hocon_parser PRIVATE hocon)