utils: do not emit eof chunk for 204/304 responses
[project/uhttpd.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2
3 PROJECT(uhttpd C)
4
5 INCLUDE (CheckFunctionExists)
6
7 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
8 ADD_DEFINITIONS(-Os -Wall -Werror -Wmissing-declarations --std=gnu99 -g3)
9
10 OPTION(TLS_SUPPORT "TLS support" ON)
11 OPTION(LUA_SUPPORT "Lua support" ON)
12 OPTION(UBUS_SUPPORT "ubus support" ON)
13
14 IF(APPLE)
15   INCLUDE_DIRECTORIES(/opt/local/include)
16   LINK_DIRECTORIES(/opt/local/lib)
17 ENDIF()
18
19 FIND_LIBRARY(LIBS crypt)
20 IF(LIBS STREQUAL "LIBS-NOTFOUND")
21         SET(LIBS "")
22 ENDIF()
23
24 SET(SOURCES main.c listen.c client.c utils.c file.c auth.c cgi.c relay.c proc.c plugin.c)
25 IF(TLS_SUPPORT)
26         SET(SOURCES ${SOURCES} tls.c)
27         ADD_DEFINITIONS(-DHAVE_TLS)
28 ENDIF()
29
30 CHECK_FUNCTION_EXISTS(getspnam HAVE_SHADOW)
31 IF(HAVE_SHADOW)
32     ADD_DEFINITIONS(-DHAVE_SHADOW)
33 ENDIF()
34
35 ADD_EXECUTABLE(uhttpd ${SOURCES})
36 TARGET_LINK_LIBRARIES(uhttpd ubox dl ${LIBS})
37
38 SET(PLUGINS "")
39 IF(LUA_SUPPORT)
40         FIND_PROGRAM(PKG_CONFIG pkg-config)
41
42         IF(NOT LUA_CFLAGS AND PKG_CONFIG)
43                 EXECUTE_PROCESS(
44                         COMMAND pkg-config --silence-errors --cflags lua5.1
45                         OUTPUT_VARIABLE LUA_CFLAGS
46                         OUTPUT_STRIP_TRAILING_WHITESPACE
47                 )
48         ENDIF()
49
50         IF(NOT LUA_LIBS AND PKG_CONFIG)
51                 EXECUTE_PROCESS(
52                         COMMAND pkg-config --silence-errors --libs lua5.1
53                         OUTPUT_VARIABLE LUA_LIBS
54                         OUTPUT_STRIP_TRAILING_WHITESPACE
55                 )
56         ENDIF()
57
58         IF(NOT LUA_LIBS)
59                 SET(LUA_LIBS "lua")
60         ENDIF()
61
62         SET(PLUGINS ${PLUGINS} uhttpd_lua)
63         ADD_DEFINITIONS(-DHAVE_LUA ${LUA_CFLAGS})
64         ADD_LIBRARY(uhttpd_lua MODULE lua.c)
65         TARGET_LINK_LIBRARIES(uhttpd_lua ${LUA_LIBS} m dl)
66 ENDIF()
67
68 IF(UBUS_SUPPORT)
69         SET(PLUGINS ${PLUGINS} uhttpd_ubus)
70         ADD_DEFINITIONS(-DHAVE_UBUS)
71         ADD_LIBRARY(uhttpd_ubus MODULE ubus.c)
72         FIND_LIBRARY(libjson NAMES json-c json)
73         TARGET_LINK_LIBRARIES(uhttpd_ubus ubus ubox blobmsg_json ${libjson})
74 ENDIF()
75
76 IF(PLUGINS)
77         SET_TARGET_PROPERTIES(${PLUGINS} PROPERTIES
78                 PREFIX ""
79         )
80 ENDIF()
81
82 INSTALL(TARGETS uhttpd ${PLUGINS}
83         RUNTIME DESTINATION bin
84         LIBRARY DESTINATION lib
85 )