version 0.3.25
[fms.git] / CMakeLists.txt
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.4)\r
2 IF(COMMAND CMAKE_POLICY)\r
3         CMAKE_POLICY(SET CMP0003 OLD)\r
4 ENDIF(COMMAND CMAKE_POLICY)\r
5 \r
6 PROJECT(fms)\r
7 \r
8 OPTION(USE_BUNDLED_SQLITE "Use the bundled SQLite3 library." OFF)\r
9 IF(APPLE)\r
10         SET(USE_BUNDLED_SQLITE ON)\r
11 ENDIF(APPLE)\r
12 OPTION(DO_CHARSET_CONVERSION "Do charset conversion on sent messages to UTF-8.  This requires libiconv." ON)\r
13 OPTION(I_HAVE_READ_THE_README "I have fully read and understood the readme.txt." OFF)\r
14 OPTION(ALTERNATE_CAPTCHA "Use alternate captcha.  This requires the FreeImage library." OFF)\r
15 \r
16 SET(FMS_SRC\r
17 src/base64.cpp\r
18 src/bitmapvalidator.cpp\r
19 src/board.cpp\r
20 src/boardlist.cpp\r
21 src/dbconversions.cpp\r
22 src/dbmaintenancethread.cpp\r
23 src/dbsetup.cpp\r
24 src/fmsapp.cpp\r
25 src/global.cpp\r
26 src/hex.cpp\r
27 src/ipaddressacl.cpp\r
28 src/localidentity.cpp\r
29 src/main.cpp\r
30 src/message.cpp\r
31 src/messagelist.cpp\r
32 src/messagethread.cpp\r
33 src/option.cpp\r
34 src/optionssetup.cpp\r
35 src/socketdefines.cpp\r
36 src/stringfunctions.cpp\r
37 src/threadbuilder.cpp\r
38 src/db/sqlite3db.cpp\r
39 src/db/sqlite3recordset.cpp\r
40 src/db/sqlite3statement.cpp\r
41 src/freenet/boardlistinserter.cpp\r
42 src/freenet/boardlistrequester.cpp\r
43 src/freenet/boardlistxml.cpp\r
44 src/freenet/fcpv2.cpp\r
45 src/freenet/fileinserter.cpp\r
46 src/freenet/fmsversionrequester.cpp\r
47 src/freenet/fmsversionxml.cpp\r
48 src/freenet/freenetmasterthread.cpp\r
49 src/freenet/freenetssk.cpp\r
50 src/freenet/identityinserter.cpp\r
51 src/freenet/identityintroductioninserter.cpp\r
52 src/freenet/identityintroductionrequester.cpp\r
53 src/freenet/identityintroductionxml.cpp\r
54 src/freenet/identityrequester.cpp\r
55 src/freenet/identityxml.cpp\r
56 src/freenet/introductionpuzzleinserter.cpp\r
57 src/freenet/introductionpuzzlerequester.cpp\r
58 src/freenet/introductionpuzzlexml.cpp\r
59 src/freenet/messageinserter.cpp\r
60 src/freenet/messagelistinserter.cpp\r
61 src/freenet/messagelistrequester.cpp\r
62 src/freenet/messagelistxml.cpp\r
63 src/freenet/messagerequester.cpp\r
64 src/freenet/messagexml.cpp\r
65 src/freenet/siteinserter.cpp\r
66 src/freenet/trustlistinserter.cpp\r
67 src/freenet/trustlistrequester.cpp\r
68 src/freenet/trustlistxml.cpp\r
69 src/freenet/unkeyedidcreator.cpp\r
70 src/freenet/captcha/simplecaptcha.cpp\r
71 src/freenet/captcha/easybmp/EasyBMP.cpp\r
72 src/freenet/captcha/easybmp/EasyBMP_Font.cpp\r
73 src/freenet/captcha/easybmp/EasyBMP_Geometry.cpp\r
74 src/http/fmshttprequesthandlerfactory.cpp\r
75 src/http/httpthread.cpp\r
76 src/http/identityexportxml.cpp\r
77 src/http/ipagehandler.cpp\r
78 src/http/multipartparser.cpp\r
79 src/http/pages/addpeerpage.cpp\r
80 src/http/pages/announceidentitypage.cpp\r
81 src/http/pages/boardspage.cpp\r
82 src/http/pages/confirmpage.cpp\r
83 src/http/pages/controlboardpage.cpp\r
84 src/http/pages/createidentitypage.cpp\r
85 src/http/pages/execquerypage.cpp\r
86 src/http/pages/forumcreatepostpage.cpp\r
87 src/http/pages/forummainpage.cpp\r
88 src/http/pages/forumthreadspage.cpp\r
89 src/http/pages/forumviewthreadpage.cpp\r
90 src/http/pages/homepage.cpp\r
91 src/http/pages/insertedfilespage.cpp\r
92 src/http/pages/localidentitiespage.cpp\r
93 src/http/pages/optionspage.cpp\r
94 src/http/pages/peerdetailspage.cpp\r
95 src/http/pages/peermaintenancepage.cpp\r
96 src/http/pages/peertrustpage.cpp\r
97 src/http/pages/recentlyaddedpage.cpp\r
98 src/http/pages/showcaptchapage.cpp\r
99 src/http/pages/showimagepage.cpp\r
100 src/http/pages/versioninfopage.cpp\r
101 src/nntp/extensiontrust.cpp\r
102 src/nntp/nntpconnection.cpp\r
103 src/nntp/nntplistener.cpp\r
104 src/nntp/uwildmat.cpp\r
105 src/nntp/mime/Mime.cpp\r
106 src/nntp/mime/MimeChar.cpp\r
107 src/nntp/mime/MimeCode.cpp\r
108 src/nntp/mime/MimeType.cpp\r
109 src/threadwrapper/threadedexector.cpp\r
110 src/unicode/ConvertUTF.c\r
111 src/unicode/unicodeformatter.cpp\r
112 src/unicode/utfconversion.cpp\r
113 )\r
114 \r
115 SET(FMS_PLATFORM_SRC )\r
116 \r
117 IF(DO_CHARSET_CONVERSION)\r
118         SET(FMS_SRC ${FMS_SRC} src/charsetconverter.cpp)\r
119 ENDIF(DO_CHARSET_CONVERSION)\r
120 \r
121 IF(ALTERNATE_CAPTCHA)\r
122         SET(FMS_SRC ${FMS_SRC} \r
123         src/freenet/captcha/alternatecaptcha1.cpp\r
124         src/freenet/captcha/alternatecaptcha2.cpp\r
125         src/freenet/captcha/alternatecaptchafonts.cpp\r
126         src/freenet/captcha/freeimage/bitmap.cpp\r
127         src/freenet/captcha/freeimage/font.cpp)\r
128 ELSE(ALTERNATE_CAPTCHA)\r
129         MESSAGE(STATUS "You are using the old captcha generator.  Add a -D ALTERNATE_CAPTCHA=ON to the command line to use the alternate captcha generator.")\r
130 ENDIF(ALTERNATE_CAPTCHA)\r
131 \r
132 IF(NOT I_HAVE_READ_THE_README)\r
133         MESSAGE(FATAL_ERROR "You must fully read the readme.txt before continuing.")\r
134 ENDIF(NOT I_HAVE_READ_THE_README)\r
135 \r
136 ADD_EXECUTABLE(fms ${FMS_SRC} ${FMS_PLATFORM_SRC})\r
137 \r
138 # link dl - For SQLite3 and shttpd - not for FreeBSD\r
139 IF(CMAKE_COMPILER_IS_GNUCC)\r
140         IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
141         ELSE(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
142                 TARGET_LINK_LIBRARIES(fms dl)\r
143         ENDIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
144 ENDIF(CMAKE_COMPILER_IS_GNUCC)\r
145 \r
146 # add -lcompat only for FreeBSD\r
147 IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
148         IF(CMAKE_COMPILER_IS_GNUCXX)\r
149                 TARGET_LINK_LIBRARIES(fms compat)\r
150         ENDIF(CMAKE_COMPILER_IS_GNUCXX)\r
151 ENDIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
152 \r
153 # link ws2_32 and iphlpapi for Windows\r
154 IF(WIN32)\r
155         TARGET_LINK_LIBRARIES(fms ws2_32)\r
156         TARGET_LINK_LIBRARIES(fms iphlpapi)\r
157 ENDIF(WIN32)\r
158 \r
159 # add -lxnet and -lsocket on solaris\r
160 IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")\r
161         TARGET_LINK_LIBRARIES(fms xnet)\r
162         TARGET_LINK_LIBRARIES(fms socket)\r
163 ENDIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")\r
164 \r
165 IF(NOT USE_BUNDLED_SQLITE)\r
166         FIND_LIBRARY(SQLITE3_LIBRARY NAMES sqlite3 sqlite3_s)\r
167 ENDIF(NOT USE_BUNDLED_SQLITE)\r
168 FIND_LIBRARY(POCO_FOUNDATION_LIBRARY NAMES PocoFoundation PocoFoundationmt)\r
169 FIND_LIBRARY(POCO_NET_LIBRARY NAMES PocoNet PocoNetmt)\r
170 FIND_LIBRARY(POCO_UTIL_LIBRARY NAMES PocoUtil PocoUtilmt)\r
171 FIND_LIBRARY(POCO_XML_LIBRARY NAMES PocoXML PocoXMLmt)\r
172 FIND_LIBRARY(PTHREADS_LIBRARY NAMES pthread pthreads pthreadvc2)\r
173 FIND_LIBRARY(ICONV_LIBRARY NAMES iconv iconv_s libiconv libiconv_s)\r
174 IF(ALTERNATE_CAPTCHA)\r
175         FIND_FILE(FREEIMAGE_LIBRARY NAMES libfreeimage.a PATHS /usr/lib/)\r
176         IF(NOT FREEIMAGE_LIBRARY)\r
177                 FIND_LIBRARY(FREEIMAGE_LIBRARY NAMES FreeImage libFreeImage libfreeimage freeimage)\r
178         ENDIF(NOT FREEIMAGE_LIBRARY)\r
179 ENDIF(ALTERNATE_CAPTCHA)\r
180 \r
181 IF(POCO_FOUNDATION_LIBRARY)\r
182         TARGET_LINK_LIBRARIES(fms ${POCO_FOUNDATION_LIBRARY})\r
183         ADD_DEFINITIONS(-DPOCO_HAVE_IPv6)\r
184         IF(WIN32)\r
185                 ADD_DEFINITIONS(-DPOCO_STATIC)\r
186         ENDIF(WIN32)\r
187         IF(POCO_UTIL_LIBRARY)\r
188                 TARGET_LINK_LIBRARIES(fms ${POCO_UTIL_LIBRARY})\r
189         ELSE(POCO_UTIL_LIBRARY)\r
190                 MESSAGE(FATAL_ERROR "Could not find system Poco Util library.  You must set the location manually.")\r
191         ENDIF(POCO_UTIL_LIBRARY)\r
192         IF(POCO_NET_LIBRARY)\r
193                 TARGET_LINK_LIBRARIES(fms ${POCO_NET_LIBRARY})\r
194         ELSE(POCO_NET_LIBRARY)\r
195                 MESSAGE(FATAL_ERROR "Could not find system Poco Net library.  You must set the location manually.")\r
196         ENDIF(POCO_NET_LIBRARY)\r
197         IF(POCO_XML_LIBRARY)\r
198                 TARGET_LINK_LIBRARIES(fms ${POCO_XML_LIBRARY})\r
199         ELSE(POCO_XML_LIBRARY)\r
200                 MESSAGE(FATAL_ERROR "Could not find system Poco XML library.  You must set the location manually.")\r
201         ENDIF(POCO_XML_LIBRARY)\r
202 ELSE(POCO_FOUNDATION_LIBRARY)\r
203         MESSAGE(FATAL_ERROR "Could not find system Poco Foundation library.  You must set the location manually.")\r
204 ENDIF(POCO_FOUNDATION_LIBRARY)\r
205 \r
206 IF(NOT WIN32)\r
207         IF(PTHREADS_LIBRARY)\r
208                 TARGET_LINK_LIBRARIES(fms ${PTHREADS_LIBRARY})\r
209         ELSE(PTHREADS_LIBRARY)\r
210                 MESSAGE(FATAL_ERROR "Could not find system pthread library.  You must set the location manually.")\r
211         ENDIF(PTHREADS_LIBRARY)\r
212 ENDIF(NOT WIN32)\r
213 \r
214 IF(SQLITE3_LIBRARY)\r
215         MESSAGE(STATUS "Linking against system SQLite3 library.")\r
216         TARGET_LINK_LIBRARIES(fms ${SQLITE3_LIBRARY})\r
217 ELSE(SQLITE3_LIBRARY)\r
218         IF(NOT USE_BUNDLED_SQLITE)\r
219                 MESSAGE(STATUS "Could not find system SQLite3 library.  Will compile from included source.")\r
220         ENDIF(NOT USE_BUNDLED_SQLITE)\r
221         ADD_LIBRARY(sqlite3 libs/sqlite3/sqlite3.c)\r
222         TARGET_LINK_LIBRARIES(fms sqlite3)\r
223         INCLUDE_DIRECTORIES(libs/sqlite3)\r
224 ENDIF(SQLITE3_LIBRARY)\r
225 \r
226 IF(DO_CHARSET_CONVERSION)\r
227         ADD_DEFINITIONS(-DDO_CHARSET_CONVERSION)\r
228         IF(ICONV_LIBRARY)\r
229                 TARGET_LINK_LIBRARIES(fms ${ICONV_LIBRARY})\r
230         ELSE(ICONV_LIBRARY)\r
231                 IF(WIN32)\r
232                         MESSAGE(FATAL_ERROR "Could not find iconv library.  You must set the location manually, or turn off charset conversion.")\r
233                 ENDIF(WIN32)\r
234         ENDIF(ICONV_LIBRARY)\r
235 ENDIF(DO_CHARSET_CONVERSION)\r
236 \r
237 IF(ALTERNATE_CAPTCHA)\r
238         IF(FREEIMAGE_LIBRARY)\r
239                 TARGET_LINK_LIBRARIES(fms ${FREEIMAGE_LIBRARY})\r
240                 ADD_DEFINITIONS("-DALTERNATE_CAPTCHA")\r
241         ELSE(FREEIMAGE_LIBRARY)\r
242                 MESSAGE(FATAL_ERROR "Could not find the FreeImage library.  Set the location manually, or turn off the alternate captchas.")\r
243         ENDIF(FREEIMAGE_LIBRARY)\r
244 ENDIF(ALTERNATE_CAPTCHA)\r
245 \r
246 # FreeBSD won't find Poco include files without this\r
247 IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
248         INCLUDE_DIRECTORIES(AFTER /usr/local/include)\r
249 ENDIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r