-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathCMakeLists.txt
36 lines (28 loc) · 1.1 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
35
36
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(libtoml)
FIND_PROGRAM(RAGEL ragel)
FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(PC_LIBICU icu-uc)
PKG_CHECK_MODULES(PC_CUNIT cunit)
SET(RAGEL_SRCS toml_parse.rl)
SET(CMAKE_INCLUDE_CURRENT_DIR TRUE)
INCLUDE_DIRECTORIES(${PC_LIBICU_INCLUDE_DIRS} ${PC_CUNIT_INCLUDE_DIRS})
SET(SRCS toml.h toml.c toml_private.h toml_private.c)
FOREACH(RAGEL_SRC ${RAGEL_SRCS})
STRING(REPLACE ".rl" ".c" C_SRC ${RAGEL_SRC})
ADD_CUSTOM_COMMAND(OUTPUT ${C_SRC}
COMMAND ${RAGEL} -n -p -o ${C_SRC} ${RAGEL_SRC}
DEPENDS ${RAGEL} ${RAGEL_SRC}
COMMENT "Building ${C_SRC} from ${RAGEL_SRC}"
)
SET_SOURCE_FILES_PROPERTIES(${C_SRC} PROPERTIES GENERATED TRUE)
LIST(APPEND SRCS ${C_SRC} ${RAGEL_SRC})
SOURCE_GROUP("Ragel Files" ${RAGEL_SRC})
ENDFOREACH()
LINK_DIRECTORIES(${PC_LIBICU_LIBRARY_DIRS} ${PC_CUNIT_LIBRARY_DIRS})
ADD_LIBRARY(toml SHARED ${SRCS})
TARGET_LINK_LIBRARIES(toml ${PC_LIBICU_LIBRARIES})
ADD_EXECUTABLE(main main.c)
TARGET_LINK_LIBRARIES(main toml ${PC_LIBICU_LIBRARIES})
ADD_EXECUTABLE(test test.c)
TARGET_LINK_LIBRARIES(test toml ${PC_LIBICU_LIBRARIES} ${PC_CUNIT_LIBRARIES})