Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 183 lines (162 sloc) 6.931 kB
5ba1e82 @hsleisink Release 9.5
authored
1 cmake_minimum_required(VERSION 2.8.2)
4d7196f @hsleisink Release 8.5
authored
2 project(Hiawatha C)
3
a98bd07 @hsleisink Release 8.6
authored
4 # Compiler
8b10bd9 @hsleisink Release 9.0
authored
5 set(CMAKE_C_FLAGS "-O2 -Wall -Wextra ${CMAKE_C_FLAGS}")
a98bd07 @hsleisink Release 8.6
authored
6 set(CMAKE_BUILD_TYPE "RelWithDebInfo")
7
4d7196f @hsleisink Release 8.5
authored
8 # Options
9 option(ENABLE_CACHE "Enable cache support in Hiawatha." on)
10 option(ENABLE_IPV6 "Enable IPv6 support in Hiawatha." on)
11 option(ENABLE_MONITOR "Enable support for the Hiawatha Monitor." off)
12 option(ENABLE_RPROXY "Enable reverse proxy support in Hiawatha." on)
6b839c4 @hsleisink Release 9.13
authored
13 option(ENABLE_TLS "Enable TLS (mbed TLS) support in Hiawatha." on)
4d7196f @hsleisink Release 8.5
authored
14 option(ENABLE_TOMAHAWK "Enable Tomahawk in Hiawatha" off)
15 option(ENABLE_TOOLKIT "Enable the URL toolkit in Hiawatha" on)
16 option(ENABLE_XSLT "Enable XSLT support in Hiawatha." on)
17
ac7e052 @hsleisink Release 9.12
authored
18 option(USE_SYSTEM_MBEDTLS "Use the system's mbed TLS (>=1.3.10) library." off)
dbeb6ec @hsleisink Release 9.2
authored
19
4d7196f @hsleisink Release 8.5
authored
20 # Includes
21 include(CMakeFiles.txt)
22 include(CheckIncludeFile)
23 include(CheckIncludeFiles)
24 include(CheckFunctionExists)
25 include(CheckLibraryExists)
5d663cd @hsleisink Release 9.1
authored
26 include(CheckSymbolExists)
8b10bd9 @hsleisink Release 9.0
authored
27 if(ENABLE_XSLT)
28 include(FindLibXml2)
29 include(FindLibXslt)
30 endif()
4d72b52 @hsleisink Release 9.9
authored
31 include(FindZLIB)
4d7196f @hsleisink Release 8.5
authored
32 include(cmake/GNUInstallDirs.cmake)
33 include(cmake/CopyIfNotExists.cmake)
34
35 # Settings
8b10bd9 @hsleisink Release 9.0
authored
36 set(HIAWATHA_VERSION_MAJOR 9)
6b839c4 @hsleisink Release 9.13
authored
37 set(HIAWATHA_VERSION_MINOR 13)
b086be4 @hsleisink Release 9.4
authored
38 set(HIAWATHA_VERSION_PATCH 0)
e6c5e7c @hsleisink Release 9.10
authored
39 set(HIAWATHA_VERSION_TWEAK 0)
4d7196f @hsleisink Release 8.5
authored
40 string(TOLOWER ${CMAKE_PROJECT_NAME} PROJECT_NAME)
e6c5e7c @hsleisink Release 9.10
authored
41 set(HIAWATHA_VERSION "${HIAWATHA_VERSION_MAJOR}.${HIAWATHA_VERSION_MINOR}")
42 if(NOT ${HIAWATHA_VERSION_PATCH} EQUAL 0)
43 set(HIAWATHA_VERSION "${HIAWATHA_VERSION}.${HIAWATHA_VERSION_PATCH}")
44 endif()
45 if(NOT ${HIAWATHA_VERSION_TWEAK} EQUAL 0)
46 set(HIAWATHA_VERSION "${HIAWATHA_VERSION}-${HIAWATHA_VERSION_TWEAK}")
4d7196f @hsleisink Release 8.5
authored
47 endif()
48 if(EXISTS "/proc/loadavg")
49 option(ENABLE_LOADCHECK "Enable the ability to check for server load." on)
50 endif()
51 set(CONFIG_DIR ${CMAKE_INSTALL_FULL_SYSCONFDIR}/hiawatha CACHE STRING "Configuration directory")
52 set(LOG_DIR ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/hiawatha CACHE STRING "Log directory")
53 set(PID_DIR ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/run CACHE STRING "PID directory")
54 set(WEBROOT_DIR ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/www/hiawatha CACHE STRING "Webroot directory")
55 set(WORK_DIR ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/hiawatha CACHE STRING "Work directory")
56
a98bd07 @hsleisink Release 8.6
authored
57 # Compiler directives
4d7196f @hsleisink Release 8.5
authored
58 check_include_file(crypt.h HAVE_CRYPT_H)
59 check_include_file(arpa/inet.h HAVE_ARPA_INET_H)
60 check_include_files("sys/types.h;netinet/in.h" HAVE_NETINET_IN_H)
61 check_include_files("sys/types.h;netinet/tcp.h" HAVE_NETINET_TCP_H)
62 check_include_file(rpcsvc/crypt.h HAVE_RPCSVC_CRYPT_H)
63
64 check_function_exists(setenv HAVE_SETENV)
65 check_function_exists(unsetenv HAVE_UNSETENV)
66 check_function_exists(clearenv HAVE_CLEARENV)
67 check_function_exists(strcasecmp HAVE_STRCASECMP)
68 check_function_exists(strncasecmp HAVE_STRNCASECMP)
69 check_function_exists(strnstr HAVE_STRNSTR)
70 check_function_exists(strcasestr HAVE_STRCASESTR)
b086be4 @hsleisink Release 9.4
authored
71 check_function_exists(strncasestr HAVE_STRNCASESTR)
ea20a08 @hsleisink Release 9.8
authored
72 check_function_exists(arc4random_uniform HAVE_ARC4RANDOM)
4d7196f @hsleisink Release 8.5
authored
73
8b10bd9 @hsleisink Release 9.0
authored
74 check_library_exists(crypt crypt_r "" HAVE_CRYPT_R)
1ca32ba @hsleisink Release 9.7
authored
75 check_library_exists(crypt crypt "" HAVE_CRYPT_LIBRARY)
4d7196f @hsleisink Release 8.5
authored
76 check_library_exists(z gzdopen "" HAVE_Z_LIBRARY)
77
5d663cd @hsleisink Release 9.1
authored
78 check_symbol_exists("SO_ACCEPTFILTER" "sys/socket.h" HAVE_ACCF)
79
4d7196f @hsleisink Release 8.5
authored
80 if(HAVE_CRYPT_LIBRARY)
81 set(CRYPT_LIBRARY "crypt")
82 endif()
83 if(HAVE_Z_LIBRARY)
84 set(Z_LIBRARY "z")
85 endif()
dbeb6ec @hsleisink Release 9.2
authored
86 if(APPLE OR CYGWIN)
4d7196f @hsleisink Release 8.5
authored
87 set(CIFS 1)
88 endif()
89
90 # CPack
91 set(CPACK_PACKAGE_VERSION_MAJOR ${HIAWATHA_VERSION_MAJOR})
92 set(CPACK_PACKAGE_VERSION_MINOR ${HIAWATHA_VERSION_MINOR})
93 set(CPACK_PACKAGE_VERSION_PATCH ${HIAWATHA_VERSION_PATCH})
94 set(CPACK_SOURCE_GENERATOR "TGZ")
95 set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${HIAWATHA_VERSION}")
96 set(CPACK_SOURCE_IGNORE_FILES "/build(/|_.*/)")
97 include(CPack)
98
ac7e052 @hsleisink Release 9.12
authored
99 # mbed TLS
6b839c4 @hsleisink Release 9.13
authored
100 if(ENABLE_TLS)
4d7196f @hsleisink Release 8.5
authored
101 set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/hiawatha)
102 set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/hiawatha)
db22fed @hsleisink Release 9.11
authored
103 if (APPLE)
104 set(CMAKE_MACOSX_RPATH ${CMAKE_MACOSX_RPATH};${CMAKE_INSTALL_FULL_LIBDIR}/hiawatha)
105 endif()
ac7e052 @hsleisink Release 9.12
authored
106 if(USE_SYSTEM_MBEDTLS)
107 message(WARNING "Make sure the mbed TLS shared library has been built with the POLARSSL_THREADING_PTHREAD and POLARSSL_THREADING_C flags set. Otherwise, it may crash the Hiawatha webserver.")
108 find_library(MBEDTLS mbedtls)
dbeb6ec @hsleisink Release 9.2
authored
109 else()
ac7e052 @hsleisink Release 9.12
authored
110 option(USE_STATIC_MBEDTLS_LIBRARY "Build mbed TLS static library." off)
111 option(USE_SHARED_MBEDTLS_LIBRARY "Build mbed TLS shared library." on)
1ca32ba @hsleisink Release 9.7
authored
112 if (CMAKE_SYSTEM MATCHES "OpenBSD")
ac7e052 @hsleisink Release 9.12
authored
113 option(LINK_WITH_PTHREAD "Explicitly link mbed TLS library to pthread." on)
1ca32ba @hsleisink Release 9.7
authored
114 endif()
d6d16eb @hsleisink Release 9.3.1
authored
115 add_definitions(-DPOLARSSL_THREADING_PTHREAD -DPOLARSSL_THREADING_C)
ac7e052 @hsleisink Release 9.12
authored
116 add_subdirectory(mbedtls)
dbeb6ec @hsleisink Release 9.2
authored
117 endif()
ac7e052 @hsleisink Release 9.12
authored
118 set(MBEDTLS_LIBRARY "mbedtls")
4d7196f @hsleisink Release 8.5
authored
119 endif()
120
121 # Hiawatha
dbeb6ec @hsleisink Release 9.2
authored
122 include_directories(${CMAKE_CURRENT_BINARY_DIR})
ac7e052 @hsleisink Release 9.12
authored
123 if(NOT USE_SYSTEM_MBEDTLS)
124 include_directories(mbedtls/include)
dbeb6ec @hsleisink Release 9.2
authored
125 endif()
4d7196f @hsleisink Release 8.5
authored
126 if(ENABLE_XSLT)
127 include_directories(${LIBXML2_INCLUDE_DIR} ${LIBXSLT_INCLUDE_DIR})
128 endif()
129
130 # Configure files
131 configure_file(config.h.in config.h)
132 foreach (configfile ${config_files_in})
133 configure_file(${configfile}.in ${configfile} @ONLY)
134 endforeach()
135 foreach(manpage ${manual_pages_in})
136 configure_file(${manpage}.in ${manpage})
137 endforeach()
138 configure_file(extra/logrotate.in logrotate.d/hiawatha)
139
140 # Binaries
141 add_executable(cgi-wrapper ${cgi_wrapper_src})
142 add_executable(hiawatha ${hiawatha_src})
143 add_executable(ssi-cgi ${ssi_cgi_src})
144 add_executable(wigwam ${wigwam_src})
145 target_link_libraries(wigwam ${CRYPT_LIBRARY})
146 target_link_libraries(hiawatha ${CRYPT_LIBRARY} pthread ${Z_LIBRARY})
6b839c4 @hsleisink Release 9.13
authored
147 if(ENABLE_TLS)
ac7e052 @hsleisink Release 9.12
authored
148 target_link_libraries(hiawatha ${MBEDTLS_LIBRARY})
149 target_link_libraries(wigwam ${MBEDTLS_LIBRARY})
150 if(NOT USE_SYSTEM_MBEDTLS)
dbeb6ec @hsleisink Release 9.2
authored
151 set_target_properties(hiawatha PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/hiawatha)
152 set_target_properties(wigwam PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/hiawatha)
153 endif()
4d7196f @hsleisink Release 8.5
authored
154 endif()
155 if(ENABLE_XSLT)
156 target_link_libraries(hiawatha ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES})
157 endif()
158
159 # Installation
b279f69 @hsleisink Release 8.7
authored
160 install(TARGETS hiawatha wigwam DESTINATION ${CMAKE_INSTALL_SBINDIR})
4d7196f @hsleisink Release 8.5
authored
161 install(TARGETS cgi-wrapper DESTINATION ${CMAKE_INSTALL_SBINDIR}
162 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE SETUID)
163 install(TARGETS ssi-cgi DESTINATION ${CMAKE_INSTALL_BINDIR})
164
165 foreach(configfile ${config_files})
166 install(CODE "copy_if_not_exists(\"${CMAKE_SOURCE_DIR}/${configfile}\" \"${CONFIG_DIR}\")")
167 endforeach()
168 foreach(configfile ${config_files_in})
169 install(CODE "copy_if_not_exists(\"${CMAKE_CURRENT_BINARY_DIR}/${configfile}\" \"${CONFIG_DIR}\")")
170 endforeach()
171
172 install(FILES ${manual_pages} DESTINATION ${CMAKE_INSTALL_FULL_MANDIR}/man1)
173 foreach(manpage ${manual_pages_in})
174 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${manpage} DESTINATION ${CMAKE_INSTALL_FULL_MANDIR}/man1)
175 endforeach()
176
177 install(FILES extra/index.html DESTINATION ${WEBROOT_DIR})
178
179 # Create directories
e6c5e7c @hsleisink Release 9.10
authored
180 install(DIRECTORY DESTINATION ${LOG_DIR})
181 install(DIRECTORY DESTINATION ${PID_DIR})
182 install(DIRECTORY DESTINATION ${WORK_DIR})
Something went wrong with that request. Please try again.