drop mod_ssl.starttls setting.
[apps/madmutt.git] / CMakeLists.txt
1 SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
2
3 PROJECT(madmutt C D)
4 SET(PACKAGE madmutt)
5
6 # Using Phobos OR Tango (can be specified from cmake command line)
7 if (NOT CMAKE_D_USE_PHOBOS AND NOT CMAKE_D_USE_TANGO)
8     # default to phobos
9     message(STATUS "This application can be built with either Phobos or Tango!")
10     message(STATUS "You did not specify a standard library -- defaulting to Phobos.")
11     message(STATUS "If you wish to use Tango add -DCMAKE_D_USE_TANGO=True to cmake command line.")
12     set(CMAKE_D_USE_PHOBOS True)
13 endif (NOT CMAKE_D_USE_PHOBOS AND NOT CMAKE_D_USE_TANGO)
14
15 include(Cpkg2c)
16 include(XConfig)
17
18 ADD_DEFINITIONS(-DHAVE_CONFIG_H)
19 ADD_DEFINITIONS(-D_GNU_SOURCE)
20 INCLUDE_DIRECTORIES(${madmutt_BINARY_DIR} ${madmutt_SOURCE_DIR})
21
22 SET(BINDIR     "${CMAKE_INSTALL_PREFIX}/bin")
23 SET(DATADIR    "${CMAKE_INSTALL_PREFIX}/share")
24 SET(PKGDATADIR "${CMAKE_INSTALL_PREFIX}/share/madmutt")
25 SET(PKGDOCDIR  "${CMAKE_INSTALL_PREFIX}/share/doc/madmutt")
26 SET(SYSCONFDIR "${CMAKE_INSTALL_PREFIX}/etc")
27 SET(VERSION    "devel")
28 SET(MUTTLIBS   "")
29
30 ADD_DEFINITIONS("-DBINDIR=\\\"${BINDIR}\\\"")
31 ADD_DEFINITIONS("-DPKGDATADIR=\\\"${PKGDATADIR}\\\"")
32 ADD_DEFINITIONS("-DPKGDOCDIR=\\\"${PKGDOCDIR}\\\"")
33 ADD_DEFINITIONS("-DSYSCONFDIR=\\\"${SYSCONFDIR}\\\"")
34 ADD_DEFINITIONS("-DVERSION=\\\"${VERSION}\\\"")
35 ADD_DEFINITIONS("-DMUTTLOCALEDIR=\\\"${DATADIR}/locale\\\"")
36
37 SET(MAILPATH         CACHE STRING "Where new mail is spooled")
38 OPTION(WITH_GPGME    "Use GPGME [default: on]" ON)
39 OPTION(WITH_IDN      "Use GNU libidn for domain names [default: off]")
40 OPTION(USE_HCACHE    "Enable headers caching  [default: off]")
41
42 FIND_FILE(SENDMAIL sendmail
43     PATHS /usr/sbin /sbin /usr/lib
44     DOC   "path to sendmail executable"
45 )
46
47 IF(NOT MAILPATH)
48     IF(EXISTS /var/mail)
49         SET(MAILPATH "/var/mail")
50     ELSEIF(EXISTS /var/spool/mail)
51         SET(MAILPATH "/var/spool/mail")
52     ELSEIF(EXISTS /usr/spool/mail)
53         SET(MAILPATH "/usr/spool/mail")
54     ELSEIF(EXISTS /usr/mail)
55         SET(MAILPATH "/usr/mail")
56     ELSE(EXISTS /var/mail)
57         MESSAGE(FATAL_ERROR "Unable to determine MAILPATH")
58     ENDIF(EXISTS /var/mail)
59 ENDIF(NOT MAILPATH)
60
61 # headers {{{
62 INCLUDE(CheckIncludeFile)
63
64 CHECK_INCLUDE_FILE(alloca.h               HAVE_ALLOCA_H)
65 CHECK_INCLUDE_FILE(argz.h                 HAVE_ARGZ_H)
66 CHECK_INCLUDE_FILE(getopt.h               HAVE_GETOPT_H)
67 CHECK_INCLUDE_FILE(iconv.h                HAVE_ICONV_H)
68 CHECK_INCLUDE_FILE(inttypes.h             HAVE_INTTYPES_H)
69 CHECK_INCLUDE_FILE(ioctl.h                HAVE_IOCTL_H)
70 CHECK_INCLUDE_FILE(langinfo.h             HAVE_LANGINFO_H)
71 CHECK_INCLUDE_FILE(limits.h               HAVE_LIMITS_H)
72 CHECK_INCLUDE_FILE(locale.h               HAVE_LOCALE_H)
73 CHECK_INCLUDE_FILE(memory.h               HAVE_MEMORY_H)
74 CHECK_INCLUDE_FILE(ncursesw/ncurses.h     HAVE_NCURSESW_NCURSES_H)
75 CHECK_INCLUDE_FILE(regex.h                HAVE_REGEX_H)
76 CHECK_INCLUDE_FILE(stdarg.h               HAVE_STDARG_H)
77 CHECK_INCLUDE_FILE(stddef.h               HAVE_STDDEF_H)
78 CHECK_INCLUDE_FILE(stdint.h               HAVE_STDINT_H)
79 CHECK_INCLUDE_FILE(stdlib.h               HAVE_STDLIB_H)
80 CHECK_INCLUDE_FILE(string.h               HAVE_STRING_H)
81 CHECK_INCLUDE_FILE(strings.h              HAVE_STRINGS_H)
82 CHECK_INCLUDE_FILE(sysexits.h             HAVE_SYSEXITS_H)
83 CHECK_INCLUDE_FILE(sys/ioctl.h            HAVE_SYS_IOCTL_H)
84 CHECK_INCLUDE_FILE(sys/param.h            HAVE_SYS_PARAM_H)
85 CHECK_INCLUDE_FILE(sys/resource.h         HAVE_SYS_RESOURCE_H)
86 CHECK_INCLUDE_FILE(sys/stat.h             HAVE_SYS_STAT_H)
87 CHECK_INCLUDE_FILE(sys/time.h             HAVE_SYS_TIME_H)
88 CHECK_INCLUDE_FILE(sys/types.h            HAVE_SYS_TYPES_H)
89 CHECK_INCLUDE_FILE(unistd.h               HAVE_UNISTD_H)
90 CHECK_INCLUDE_FILE(unix.h                 HAVE_UNIX_H)
91 CHECK_INCLUDE_FILE(wchar.h                HAVE_WCHAR_H)
92 CHECK_INCLUDE_FILE(wctype.h               HAVE_WCTYPE_H)
93
94 IF(NOT HAVE_ICONV_H)
95     MESSAGE(FATAL_ERROR "inconv.h not found")
96 ENDIF(NOT HAVE_ICONV_H)
97
98 # }}}
99 # types {{{
100
101 INCLUDE(CheckStructMember)
102
103 CHECK_STRUCT_MEMBER("struct dirent" "d_ino" "dirent.h" HAVE_DIRENT_D_INO)
104
105 # }}}
106 # functions {{{
107 INCLUDE (CheckFunctionExists)
108
109 CHECK_FUNCTION_EXISTS(strlimit    HAVE_SETRLIMIT)
110 CHECK_FUNCTION_EXISTS(getsid      HAVE_GETSID)
111 CHECK_FUNCTION_EXISTS(setegid     HAVE_SETEGID)
112 CHECK_FUNCTION_EXISTS(getopt      HAVE_GETOPT)
113 CHECK_FUNCTION_EXISTS(nl_langinfo HAVE_LANGINFO_CODESET)
114
115 # }}}
116 # libraries {{{
117 INCLUDE(CheckLibraryExists)
118 INCLUDE(FindPkgConfig)
119
120 FIND_LIBRARY(LIBUTIL NAMES util)
121 IF(NOT LIBUTIL)
122     MESSAGE(FATAL_ERROR "could not find libutil")
123 ENDIF(NOT LIBUTIL)
124 LIST(APPEND MUTTLIBS -lutil)
125
126 FIND_LIBRARY(NCURSESW NAMES ncursesw)
127 IF(NOT NCURSESW OR NOT HAVE_NCURSESW_NCURSES_H)
128     MESSAGE(FATAL_ERROR "could not libncursesw")
129 ENDIF(NOT NCURSESW OR NOT HAVE_NCURSESW_NCURSES_H)
130 SET(CMAKE_REQUIRED_INCLUDES "ncursesw/ncurses.h")
131 LIST(APPEND MUTTLIBS -lncursesw)
132
133 pkg_search_module(LUA REQUIRED lua5.1)
134 ADD_DEFINITIONS(${LUA_CFLAGS})
135 LIST(APPEND MUTTLIBS ${LUA_LDFLAGS})
136
137 IF(WITH_GPGME)
138     XCONFIG(gpgme-config gpgme_INCDIR gpgme_LINKDIR gpgme_LDFLAGS gpgme_CFLAGS)
139     INCLUDE_DIRECTORIES(${gpgme_INCDIR})
140     ADD_DEFINITIONS(${gpgme_CFLAGS})
141     LIST(APPEND MUTTLIBS ${gpgme_LDFLAGS})
142     SET(HAVE_GPGME 1)
143 ENDIF(WITH_GPGME)
144
145 XCONFIG(libgnutls-config gnutls_INCDIR gnutls_LINKDIR gnutls_LDFLAGS gnutls_CFLAGS)
146 INCLUDE_DIRECTORIES(${gnutls_INCDIR})
147 ADD_DEFINITIONS(${gnutls_CFLAGS})
148 CHECK_INCLUDE_FILE(gnutls/openssl.h  HAVE_GNUTLS_OPENSSL_H)
149 LIST(APPEND MUTTLIBS ${gnutls_LDFLAGS})
150
151 CHECK_LIBRARY_EXISTS(sasl2 sasl_client_init "" WITH_SASL)
152 IF(NOT WITH_SASL)
153     MESSAGE(FATAL_ERROR "sasl2 not found")
154 ENDIF(NOT WITH_SASL)
155 LIST(APPEND MUTTLIBS -lsasl2)
156
157 IF(WITH_IDN)
158     pkg_search_module(IDN REQUIRED libidn)
159     LIST(APPEND MUTTLIBS ${IDN_LDFLAGS})
160     SET(HAVE_LIBIDN 1)
161 ENDIF(WITH_IDN)
162
163 CHECK_LIBRARY_EXISTS(lockfile lockfile_create "" WITH_LOCKFILE)
164 IF(NOT WITH_LOCKFILE)
165     MESSAGE(FATAL_ERROR "lockfile not found")
166 ENDIF(NOT WITH_LOCKFILE)
167 LIST(APPEND MUTTLIBS -llockfile)
168
169 IF(USE_HCACHE)
170     OPTION(WITH_TC   "Use tokyocabinet for header caching [default: on]" ON)
171     OPTION(WITH_GDBM "Use gdbm for header caching [default: off]")
172     SET(USE_HCACHE)
173
174     if(WITH_TC)
175         pkg_search_module(TC REQUIRED tokyocabinet)
176         ADD_DEFINITIONS(${TC_CFLAGS})
177         LIST(APPEND MUTTLIBS ${TC_LDFLAGS})
178         SET(USE_HCACHE 1)
179         SET(HAVE_TOKYOCABINET 1)
180     ENDIF(WITH_TC)
181
182     IF(NOT USE_HCACHE AND WITH_GDBM)
183         CHECK_LIBRARY_EXISTS(gdbm gdbm_open "" GDBM)
184         IF(NOT GDBM)
185             MESSAGE(FATAL_ERROR "gdbm not found")
186         ENDIF(NOT GDBM)
187         LIST(APPEND MUTTLIBS -lgdbm)
188         SET(USE_HCACHE 1)
189         SET(HAVE_GDBM 1)
190     ENDIF(NOT USE_HCACHE AND WITH_GDBM)
191
192     IF(NOT USE_HCACHE)
193         MESSAGE(FATAL_ERROR "no backend for header caching selected")
194     ENDIF(NOT USE_HCACHE)
195 ENDIF(USE_HCACHE)
196
197 # }}}
198 # C flags {{{
199 # big debug flags
200 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -ggdb3")
201 # Use pipes and not temp files.
202 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe")
203 # optimize even more
204 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
205 # let the type char be unsigned by default
206 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -funsigned-char")
207 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstrict-aliasing")
208 # turn on all common warnings
209 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
210 # turn on extra warnings
211 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W")
212 # treat warnings as errors
213 #SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
214 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wchar-subscripts")
215 # warn about undefined preprocessor identifiers
216 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wundef")
217 # warn about local variable shadowing another local variable
218 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow")
219 # warn about casting of pointers to increased alignment requirements
220 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wcast-align")
221 # make string constants const
222 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wwrite-strings")
223 # warn about comparisons between signed and unsigned values
224 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wsign-compare")
225 # warn about unused declared stuff
226 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused")
227 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter")
228 # warn about variable use before initialization
229 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wuninitialized")
230 # warn about variables which are initialized with themselves
231 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Winit-self")
232 # warn about pointer arithmetic on void* and function pointers
233 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith")
234 # warn about multiple declarations
235 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wredundant-decls")
236 # warn if the format string is not a string literal
237 #SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wformat-nonliteral")
238 # do not warn about zero-length formats.
239 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format-zero-length")
240 # missing prototypes
241 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-prototypes")
242 # warn about functions without format attribute that should have one
243 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-format-attribute")
244 # }}}
245 # D flags {{{
246 # big debug flags
247 SET(CMAKE_D_FLAGS "${CMAKE_D_FLAGS} -ggdb3")
248 # Use pipes and not temp files.
249 SET(CMAKE_D_FLAGS "${CMAKE_D_FLAGS} -pipe")
250 # optimize even more
251 SET(CMAKE_D_FLAGS "${CMAKE_D_FLAGS} -O2")
252 # let the type char be unsigned by default
253 SET(CMAKE_D_FLAGS "${CMAKE_D_FLAGS} -funsigned-char")
254 SET(CMAKE_D_FLAGS "${CMAKE_D_FLAGS} -fstrict-aliasing")
255 # turn on all common warnings
256 SET(CMAKE_D_FLAGS "${CMAKE_D_FLAGS} -Wall")
257 # turn on extra warnings
258 SET(CMAKE_D_FLAGS "${CMAKE_D_FLAGS} -W")
259 # treat warnings as errors
260 #SET(CMAKE_D_FLAGS "${CMAKE_D_FLAGS} -Werror")
261 # warn about local variable shadowing another local variable
262 SET(CMAKE_D_FLAGS "${CMAKE_D_FLAGS} -Wshadow")
263 # warn about casting of pointers to increased alignment requirements
264 SET(CMAKE_D_FLAGS "${CMAKE_D_FLAGS} -Wcast-align")
265 # warn about comparisons between signed and unsigned values
266 SET(CMAKE_D_FLAGS "${CMAKE_D_FLAGS} -Wsign-compare")
267 # warn about unused declared stuff
268 SET(CMAKE_D_FLAGS "${CMAKE_D_FLAGS} -Wunused")
269 SET(CMAKE_D_FLAGS "${CMAKE_D_FLAGS} -Wno-unused-parameter")
270 # warn about variable use before initialization
271 SET(CMAKE_D_FLAGS "${CMAKE_D_FLAGS} -Wuninitialized")
272 # let's read GPGME's Reference Manual
273 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FILE_OFFSET_BITS=64")
274 # }}}
275
276 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
277
278 # we generate some includes
279 ADD_SUBDIRECTORY(lib-lib)
280 ADD_SUBDIRECTORY(lib-mime)
281 ADD_SUBDIRECTORY(lib-sys)
282 ADD_SUBDIRECTORY(lib-ui)
283 ADD_SUBDIRECTORY(imap)
284 ADD_SUBDIRECTORY(lib-mx)
285 ADD_SUBDIRECTORY(lib-lua)
286 ADD_SUBDIRECTORY(po)
287
288 MADMUTT_SOURCES(madmuttsrc madmuttgen
289     alias.cpkg
290     buffy.cpkg
291     charset.cpkg
292     crypt.cpkg
293     score.cpkg
294
295     account.c
296     attach.c
297     commands.c
298     compose.c
299     copy.c
300     editmsg.c
301     flags.c
302     handler.c
303     headers.c
304     help.c
305     hook.c
306     init.c
307     keymap.c
308     mutt_idna.c
309     muttlib.c
310     mutt_sasl.c
311     pager.c
312     pattern.c
313     postpone.c
314     recvattach.c
315     recvcmd.c
316     send.c
317     sendlib.c
318     sort.c
319     state.c
320     thread.c
321
322     main.c
323 )
324
325 STRING(REGEX REPLACE ";" " " MUTTLIBS "${MUTTLIBS}")
326 ADD_EXECUTABLE(madmutt ${madmuttsrc})
327 TARGET_LINK_LIBRARIES(madmutt mime sys mx lua ui imap lib)
328 SET_TARGET_PROPERTIES(madmutt PROPERTIES
329     LINK_FLAGS "${MUTTLIBS}"
330     #    LINKER_LANGUAGE D
331 )
332
333 # generate_files hack {{{
334
335 ADD_CUSTOM_COMMAND(
336     OUTPUT  ${madmutt_SOURCE_DIR}/keymap_defs.h
337     DEPENDS ${madmutt_SOURCE_DIR}/OPS ${madmutt_SOURCE_DIR}/tools/gen_defs
338     COMMAND ${madmutt_SOURCE_DIR}/tools/gen_defs ${madmutt_SOURCE_DIR}/OPS > ${madmutt_SOURCE_DIR}/keymap_defs.h
339     COMMENT "Generating ${madmutt_SOURCE_DIR}/keymap_defs.h from ${madmutt_SOURCE_DIR}/OPS"
340 )
341 ADD_CUSTOM_COMMAND(
342     OUTPUT  ${madmutt_SOURCE_DIR}/charset.gperf
343     DEPENDS ${madmutt_SOURCE_DIR}/charset.def
344     COMMAND sh ${madmutt_SOURCE_DIR}/charset.def > ${madmutt_SOURCE_DIR}/charset.gperf
345     COMMENT "Generating ${madmutt_SOURCE_DIR}/charset.gperf from ${madmutt_SOURCE_DIR}/charset.def"
346 )
347 ADD_CUSTOM_TARGET(generate_file
348     DEPENDS ${madmuttgen}
349     ${madmutt_SOURCE_DIR}/keymap_defs.h
350     ${madmutt_SOURCE_DIR}/charset.gperf
351 )
352 ADD_DEPENDENCIES(generate_file generate_files)
353 ADD_DEPENDENCIES(madmutt generate_file)
354
355 # }}}