1 #
2 # Copyright (c) 2011-2020 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
3 #
4 # Permission is hereby granted, free of charge, to any person obtaining a copy
5 # of this software and associated documentation files (the "Software"), to deal
6 # in the Software without restriction, including without limitation the rights
7 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 # copies of the Software, and to permit persons to whom the Software is
9 # furnished to do so, subject to the following conditions:
10 #
11 # The above copyright notice and this permission notice shall be included in
12 # all copies or substantial portions of the Software.
13 #
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 # SOFTWARE.
21 #
22
23 cmake_minimum_required(VERSION 2.8.12.2)
24 project(blahgd)
25
26 enable_testing()
27
28 include(cmake/64-bit.cmake)
29 include(config.cmake)
30
31 add_definitions(
32 -D__EXTENSIONS__
33 -D_REENTRANT
34 )
35
36 add_compile_options(
37 -Wall
38 -O2
39 -g
40 -std=gnu99
41 -fno-omit-frame-pointer
42 $<$<C_COMPILER_ID:gcc>:-fno-inline-small-functions>
43 $<$<C_COMPILER_ID:gcc>:-fno-inline-functions-called-once>
44 )
45
46 find_package(BISON)
47 find_package(FLEX)
48
49 BISON_TARGET(fmt3 post_fmt3.y post_fmt3.tab.c COMPILE_FLAGS "-p fmt3_")
50 FLEX_TARGET(fmt3 post_fmt3.l post_fmt3.lex.c COMPILE_FLAGS "-P fmt3_")
51 ADD_FLEX_BISON_DEPENDENCY(fmt3 fmt3)
52
53 BISON_TARGET(tmpl template.y template.tab.c COMPILE_FLAGS "-p tmpl_")
54 FLEX_TARGET(tmpl template.l template.lex.c COMPILE_FLAGS "-P tmpl_")
55 ADD_FLEX_BISON_DEPENDENCY(tmpl tmpl)
56
57 include_directories(
58 ${JEFFPC_INCLUDE_DIR}
59 )
60
61 add_custom_target(revisiontag ALL)
62
63 add_custom_command(TARGET revisiontag
64 COMMAND ${CMAKE_COMMAND}
65 -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
66 -DBINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}
67 -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/hg.cmake
68 )
69
70 add_library(blahg
71 version.c
72
73 # post - all formats
74 post.c
75 post_index.c
76 post_nv.c
77
78 # post - format 3
79 ${FLEX_fmt3_OUTPUTS} ${BISON_fmt3_OUTPUTS}
80 post_fmt3_cmds.c
81 listing.c
82 mangle.c
83
84 # templates
85 ${FLEX_tmpl_OUTPUTS} ${BISON_tmpl_OUTPUTS}
86 render.c
87 pipeline.c
88
89 # nvlist related things
90 nvl.c
91 vars.c
92
93 # misc
94 config.c
95 error.c
96 utils.c
97 sidebar.c
98 )
99
100 add_dependencies(blahg revisiontag)
101
102 target_link_libraries(blahg
103 m
104 ${JEFFPC_LIBRARY}
105 )
106
107 add_executable(blahgd
108 daemon.c
109
110 # request processing
111 req.c
112
113 # pages
114 admin.c
115 comment.c
116 index.c
117 story.c
118 tag.c
119 static.c
120 )
121
122 target_link_libraries(blahgd
123 blahg
124 pthread
125 )
126
127 add_executable(lisplint
128 lisplint.c
129 )
130
131 target_link_libraries(lisplint
132 blahg
133 )
134
135 include(GNUInstallDirs)
136 install(TARGETS blahgd
137 DESTINATION ${CMAKE_INSTALL_SBINDIR}
138 PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE
139 GROUP_READ GROUP_EXECUTE
140 WORLD_READ WORLD_EXECUTE)
141 install(TARGETS lisplint
142 DESTINATION libexec/blahgd
143 PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE
144 GROUP_READ GROUP_EXECUTE
145 WORLD_READ WORLD_EXECUTE)
146
147 add_executable(test_fmt3
148 test_fmt3.c
149 )
150
151 target_link_libraries(test_fmt3
152 blahg
153 )
154
155 function(simple_c_test type section bin data)
156 add_test(NAME "${type}:${section}:${data}"
157 COMMAND "${CMAKE_BINARY_DIR}/test_${bin}"
158 "${CMAKE_CURRENT_SOURCE_DIR}/${data}"
159 )
160 endfunction()
161
162 add_subdirectory(tests)