forked from ElektraInitiative/libelektra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
155 lines (140 loc) · 3.27 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
function (check_dependencies)
set (
FOUND_DEPENDENCIES
FALSE
PARENT_SCOPE)
set (USE_HOMEBREW_FLEX ${APPLE} AND EXISTS /usr/local/opt/flex)
if (USE_HOMEBREW_FLEX)
list (APPEND CMAKE_PREFIX_PATH "/usr/local/opt/flex")
endif (USE_HOMEBREW_FLEX)
find_package (FLEX 2.6.2 QUIET)
set (USE_HOMEBREW_BISON ${APPLE} AND EXISTS /usr/local/opt/bison)
if (USE_HOMEBREW_BISON)
list (APPEND CMAKE_PREFIX_PATH "/usr/local/opt/bison")
endif (USE_HOMEBREW_BISON)
find_package (BISON 3 QUIET)
if ((NOT FLEX_FOUND) AND (NOT BISON_FOUND))
set (
FAILURE_MESSAGE
"Flex and Bison could not be found"
PARENT_SCOPE)
return ()
endif ((NOT FLEX_FOUND) AND (NOT BISON_FOUND))
if (NOT FLEX_FOUND)
set (
FAILURE_MESSAGE
"Flex could not be found"
PARENT_SCOPE)
return ()
endif (NOT FLEX_FOUND)
if (NOT BISON_FOUND)
set (
FAILURE_MESSAGE
"Bison could not be found"
PARENT_SCOPE)
return ()
endif (NOT BISON_FOUND)
set (
FOUND_DEPENDENCIES
TRUE
PARENT_SCOPE)
endfunction (check_dependencies)
function (generate_code)
set (
GENERATED_CODE
FALSE
PARENT_SCOPE)
flex_target (TOMLScanner ${CMAKE_CURRENT_SOURCE_DIR}/lexer.l ${CMAKE_CURRENT_BINARY_DIR}/lexer.c)
bison_target (TOMLParser ${CMAKE_CURRENT_SOURCE_DIR}/parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.c VERBOSE bison_verbose.txt)
add_flex_bison_dependency (TOMLScanner TOMLParser)
if ((NOT FLEX_TOMLScanner_DEFINED) AND (NOT BISON_TOMLParser_DEFINED))
set (
FAILURE_MESSAGE
"Flex and Bison code could not be generated"
PARENT_SCOPE)
return ()
endif ((NOT FLEX_TOMLScanner_DEFINED) AND (NOT BISON_TOMLParser_DEFINED))
if (NOT FLEX_TOMLScanner_DEFINED)
set (
FAILURE_MESSAGE
"Flex code could not be generated"
PARENT_SCOPE)
return ()
endif (NOT FLEX_TOMLScanner_DEFINED)
if (NOT BISON_TOMLParser_DEFINED)
set (
FAILURE_MESSAGE
"Bison code could not be generated"
PARENT_SCOPE)
return ()
endif (NOT BISON_TOMLParser_DEFINED)
set (
FLEX_OUTPUT_SOURCE
${FLEX_TOMLScanner_OUTPUTS}
PARENT_SCOPE)
set (
FLEX_OUTPUT_HEADER
${FLEX_TOMLScanner_OUTPUT_HEADER}
PARENT_SCOPE)
set (
BISON_OUTPUT_SOURCE
${BISON_TOMLParser_OUTPUT_SOURCE}
PARENT_SCOPE)
set (
BISON_OUTPUT_HEADER
${BISON_TOMLParser_OUTPUT_HEADER}
PARENT_SCOPE)
set (
GENERATED_CODE
TRUE
PARENT_SCOPE)
endfunction (generate_code)
if (DEPENDENCY_PHASE)
check_dependencies ()
if (NOT FOUND_DEPENDENCIES)
remove_plugin (toml ${FAILURE_MESSAGE})
else (NOT FOUND_DEPENDENCIES)
generate_code ()
if (NOT GENERATED_CODE)
remove_plugin (toml ${FAILURE_MESSAGE})
endif (NOT GENERATED_CODE)
endif (NOT FOUND_DEPENDENCIES)
set (
SOURCE_FILES
toml.h
toml.c
driver.h
driver.c
scalar.h
scalar.c
table_array.h
table_array.c
comment_list.h
comment_list.c
utf8_dfa.h
codepoint.h
codepoint.c
utility.h
utility.c
write.h
write.c
node.h
node.c
prepare.c
prepare.h
integer.h
integer.c
type.h
type.c
error.h
${FLEX_OUTPUT_HEADER}
${FLEX_OUTPUT_SOURCE}
${BISON_OUTPUT_HEADER}
${BISON_OUTPUT_SOURCE})
endif (DEPENDENCY_PHASE)
add_plugin (
toml ADD_TEST INSTALL_TEST_DATA TEST_README
TEST_REQUIRED_PLUGINS type base64
LINK_ELEKTRA elektra-meta
SOURCES ${SOURCE_FILES}
INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR} COMPONENT libelektra${SO_VERSION})