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         # post - format 4
  85         # XXX KEBE ASKS -- any clever way to pin an external library?
  86         post_fmt4.c
  87 
  88         # templates
  89         ${FLEX_tmpl_OUTPUTS} ${BISON_tmpl_OUTPUTS}
  90         render.c
  91         pipeline.c
  92 
  93         # nvlist related things
  94         nvl.c
  95         vars.c
  96 
  97         # misc
  98         config.c
  99         error.c
 100         utils.c
 101         sidebar.c
 102 )
 103 
 104 add_dependencies(blahg revisiontag)
 105 
 106 target_link_libraries(blahg
 107         m
 108         ${JEFFPC_LIBRARY}
 109 )
 110 
 111 add_executable(blahgd
 112         daemon.c
 113 
 114         # request processing
 115         req.c
 116 
 117         # pages
 118         admin.c
 119         comment.c
 120         index.c
 121         story.c
 122         tag.c
 123         static.c
 124 )
 125 
 126 target_link_libraries(blahgd
 127         blahg
 128         pthread
 129 )
 130 
 131 add_executable(lisplint
 132         lisplint.c
 133 )
 134 
 135 target_link_libraries(lisplint
 136         blahg
 137 )
 138 
 139 include(GNUInstallDirs)
 140 install(TARGETS blahgd
 141         DESTINATION ${CMAKE_INSTALL_SBINDIR}
 142         PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE
 143                     GROUP_READ GROUP_EXECUTE
 144                     WORLD_READ WORLD_EXECUTE)
 145 install(TARGETS lisplint
 146         DESTINATION libexec/blahgd
 147         PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE
 148                     GROUP_READ GROUP_EXECUTE
 149                     WORLD_READ WORLD_EXECUTE)
 150 
 151 add_executable(test_fmt3
 152         test_fmt3.c
 153 )
 154 
 155 target_link_libraries(test_fmt3
 156         blahg
 157 )
 158 
 159 function(simple_c_test type section bin data)
 160         add_test(NAME "${type}:${section}:${data}"
 161                  COMMAND "${CMAKE_BINARY_DIR}/test_${bin}"
 162                          "${CMAKE_CURRENT_SOURCE_DIR}/${data}"
 163         )
 164 endfunction()
 165 
 166 add_subdirectory(tests)