version 0.2.16
[fms.git] / CMakeLists.txt
1 PROJECT(fms)\r
2 \r
3 OPTION(USE_BUNDLED_SQLITE "Use the bundled SQLite3 library." OFF)\r
4 OPTION(DO_CHARSET_CONVERSION "Do charset conversion on sent messages to UTF-8.  This requires libiconv." OFF)\r
5 \r
6 SET(FMS_SRC \r
7 src/base64.cpp\r
8 src/board.cpp\r
9 src/boardlist.cpp\r
10 src/commandthread.cpp\r
11 src/datetime.cpp\r
12 src/global.cpp\r
13 src/hex.cpp\r
14 src/localidentity.cpp\r
15 src/logfile.cpp\r
16 src/main.cpp\r
17 src/message.cpp\r
18 src/messagelist.cpp\r
19 src/option.cpp\r
20 src/socketdefines.cpp\r
21 src/stringfunctions.cpp\r
22 src/threadcontroller.cpp\r
23 src/uuidgenerator.cpp\r
24 src/db/sqlite3db.cpp\r
25 src/db/sqlite3recordset.cpp\r
26 src/db/sqlite3statement.cpp\r
27 src/freenet/boardlistinserter.cpp\r
28 src/freenet/boardlistrequester.cpp\r
29 src/freenet/boardlistxml.cpp\r
30 src/freenet/fcpv2.cpp\r
31 src/freenet/fileinserter.cpp\r
32 src/freenet/freenetmasterthread.cpp\r
33 src/freenet/freenetssk.cpp\r
34 src/freenet/identityinserter.cpp\r
35 src/freenet/identityintroductioninserter.cpp\r
36 src/freenet/identityintroductionrequester.cpp\r
37 src/freenet/identityintroductionxml.cpp\r
38 src/freenet/identityrequester.cpp\r
39 src/freenet/identityxml.cpp\r
40 src/freenet/introductionpuzzleinserter.cpp\r
41 src/freenet/introductionpuzzlerequester.cpp\r
42 src/freenet/introductionpuzzlexml.cpp\r
43 src/freenet/messageinserter.cpp\r
44 src/freenet/messagelistinserter.cpp\r
45 src/freenet/messagelistrequester.cpp\r
46 src/freenet/messagelistxml.cpp\r
47 src/freenet/messagerequester.cpp\r
48 src/freenet/messagexml.cpp\r
49 src/freenet/periodicdbmaintenance.cpp\r
50 src/freenet/siteinserter.cpp\r
51 src/freenet/trustlistinserter.cpp\r
52 src/freenet/trustlistrequester.cpp\r
53 src/freenet/trustlistxml.cpp\r
54 src/freenet/unkeyedidcreator.cpp\r
55 src/freenet/captcha/simplecaptcha.cpp\r
56 src/freenet/captcha/easybmp/EasyBMP.cpp\r
57 src/freenet/captcha/easybmp/EasyBMP_Font.cpp\r
58 src/freenet/captcha/easybmp/EasyBMP_Geometry.cpp\r
59 src/http/httpthread.cpp\r
60 src/http/identityexportxml.cpp\r
61 src/http/ipagehandler.cpp\r
62 src/http/pages/addpeerpage.cpp\r
63 src/http/pages/announceidentitypage.cpp\r
64 src/http/pages/boardspage.cpp\r
65 src/http/pages/controlboardpage.cpp\r
66 src/http/pages/createidentitypage.cpp\r
67 src/http/pages/execquerypage.cpp\r
68 src/http/pages/homepage.cpp\r
69 src/http/pages/insertedfilespage.cpp\r
70 src/http/pages/localidentitiespage.cpp\r
71 src/http/pages/optionspage.cpp\r
72 src/http/pages/peerdetailspage.cpp\r
73 src/http/pages/peermaintenancepage.cpp\r
74 src/http/pages/peertrustpage.cpp\r
75 src/http/pages/showcaptchapage.cpp\r
76 src/nntp/extensiontrust.cpp\r
77 src/nntp/nntpconnection.cpp\r
78 src/nntp/nntplistener.cpp\r
79 src/nntp/uwildmat.cpp\r
80 src/nntp/mime/Mime.cpp\r
81 src/nntp/mime/MimeChar.cpp\r
82 src/nntp/mime/MimeCode.cpp\r
83 src/nntp/mime/MimeType.cpp\r
84 src/pthreadwrapper/guard.cpp\r
85 src/pthreadwrapper/mutex.cpp\r
86 src/pthreadwrapper/runnable.cpp\r
87 src/pthreadwrapper/thread.cpp\r
88 src/pthreadwrapper/threadedexecutor.cpp\r
89 src/xyssl/sha1.c\r
90 )\r
91 \r
92 IF(DO_CHARSET_CONVERSION)\r
93         SET(FMS_SRC ${FMS_SRC} src/charsetconverter.cpp)\r
94 ENDIF(DO_CHARSET_CONVERSION)\r
95 \r
96 IF(WIN32)\r
97         SET(FMS_PLATFORM_SRC src/fmsservice.cpp)\r
98 ELSE(WIN32)\r
99         SET(FMS_PLATFORM_SRC src/fmsdaemon.cpp)\r
100 ENDIF(WIN32)\r
101 \r
102 ADD_DEFINITIONS(-DTIXML_USE_STL)\r
103 \r
104 # was for ZThreads\r
105 #IF(CMAKE_COMPILER_IS_GNUCXX)\r
106 #       #ADD_DEFINITIONS(-fpermissive)\r
107 #       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")\r
108 #ENDIF(CMAKE_COMPILER_IS_GNUCXX)\r
109 \r
110 ADD_EXECUTABLE(fms ${FMS_SRC} ${FMS_PLATFORM_SRC})\r
111 \r
112 # link dl - For SQLite3 and shttpd - not for FreeBSD\r
113 IF(CMAKE_COMPILER_IS_GNUCC)\r
114         IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
115         ELSE(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
116                 TARGET_LINK_LIBRARIES(fms dl)\r
117         ENDIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
118 ENDIF(CMAKE_COMPILER_IS_GNUCC)\r
119 \r
120 # add -lcompat only for FreeBSD\r
121 IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
122         IF(CMAKE_COMPILER_IS_GNUCXX)\r
123                 TARGET_LINK_LIBRARIES(fms compat)\r
124         ENDIF(CMAKE_COMPILER_IS_GNUCXX)\r
125 ENDIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")\r
126 \r
127 # link ws2_32 for Windows\r
128 IF(WIN32)\r
129         TARGET_LINK_LIBRARIES(fms ws2_32)\r
130 ENDIF(WIN32)\r
131 \r
132 # add -lxnet and -lsocket on solaris\r
133 IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")\r
134         TARGET_LINK_LIBRARIES(fms xnet)\r
135         TARGET_LINK_LIBRARIES(fms socket)\r
136 ENDIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")\r
137 \r
138 IF(NOT USE_BUNDLED_SQLITE)\r
139         FIND_LIBRARY(SQLITE3_LIBRARY NAMES sqlite3 sqlite3_s)\r
140 ENDIF(NOT USE_BUNDLED_SQLITE)\r
141 FIND_LIBRARY(TINYXML_LIBRARY NAMES tinyxml tinyxml_s)\r
142 FIND_LIBRARY(PTHREADS_LIBRARY NAMES pthread pthreads pthreadvc2)\r
143 FIND_LIBRARY(SHTTPD_LIBRARY NAMES shttpd shttpd_s)\r
144 FIND_LIBRARY(ICONV_LIBRARY NAMES iconv iconv_s libiconv libiconv_s)\r
145 \r
146 IF(SQLITE3_LIBRARY)\r
147         TARGET_LINK_LIBRARIES(fms ${SQLITE3_LIBRARY})\r
148 ELSE(SQLITE3_LIBRARY)\r
149         IF(NOT USE_BUNDLED_SQLITE)\r
150                 MESSAGE(STATUS "Could not find system SQLite library.  Will compile from included source.")\r
151         ENDIF(NOT USE_BUNDLED_SQLITE)\r
152         ADD_LIBRARY(sqlite3 libs/sqlite3/sqlite3.c)\r
153         TARGET_LINK_LIBRARIES(fms sqlite3)\r
154         INCLUDE_DIRECTORIES(libs/sqlite3)\r
155 ENDIF(SQLITE3_LIBRARY)\r
156 \r
157 IF(TINYXML_LIBRARY)\r
158         TARGET_LINK_LIBRARIES(fms ${TINYXML_LIBRARY})\r
159 ELSE(TINYXML_LIBRARY)\r
160         MESSAGE(STATUS "Could not find system TinyXML library.  Will compile from included source.")\r
161         ADD_LIBRARY(tinyxml libs/tinyxml/tinystr.cpp libs/tinyxml/tinyxml.cpp libs/tinyxml/tinyxmlerror.cpp libs/tinyxml/tinyxmlparser.cpp)\r
162         TARGET_LINK_LIBRARIES(fms tinyxml)\r
163         INCLUDE_DIRECTORIES(libs/tinyxml)\r
164 ENDIF(TINYXML_LIBRARY)\r
165 \r
166 IF(PTHREADS_LIBRARY)\r
167         TARGET_LINK_LIBRARIES(fms ${PTHREADS_LIBRARY})\r
168 ELSE(PTHREADS_LIBRARY)\r
169         MESSAGE(FATAL ERROR "Could not find pthreads library.  You must set the location manually.")\r
170 ENDIF(PTHREADS_LIBRARY)\r
171 \r
172 IF(SHTTPD_LIBRARY)\r
173         TARGET_LINK_LIBRARIES(fms ${SHTTPD_LIBRARY})\r
174 ELSE(SHTTPD_LIBRARY)\r
175         MESSAGE(STATUS "Could not find shttpd library.  Will compile from included source.")\r
176         ADD_DEFINITIONS(-DEMBEDDED)\r
177         INCLUDE_DIRECTORIES(libs/shttpd/include)\r
178         IF(WIN32)\r
179                 ADD_DEFINITIONS(-DNO_GUI)\r
180                 SET(SHTTPD_PLATFORM_SRC libs/shttpd/compat_win32.c)\r
181         ELSE(WIN32)\r
182                 SET(SHTTPD_PLATFORM_SRC libs/shttpd/compat_unix.c)\r
183         ENDIF(WIN32)\r
184         ADD_LIBRARY(shttpd ${SHTTPD_PLATFORM_SRC} libs/shttpd/auth.c libs/shttpd/cgi.c libs/shttpd/config.c libs/shttpd/io_cgi.c libs/shttpd/io_dir.c libs/shttpd/io_emb.c libs/shttpd/io_file.c libs/shttpd/io_socket.c libs/shttpd/io_ssi.c libs/shttpd/io_ssl.c libs/shttpd/log.c libs/shttpd/md5.c libs/shttpd/shttpd.c libs/shttpd/string.c)\r
185         TARGET_LINK_LIBRARIES(fms shttpd)\r
186 ENDIF(SHTTPD_LIBRARY)\r
187 \r
188 IF(DO_CHARSET_CONVERSION)\r
189         ADD_DEFINITIONS(-DDO_CHARSET_CONVERSION)\r
190         IF(ICONV_LIBRARY)\r
191                 TARGET_LINK_LIBRARIES(fms ${ICONV_LIBRARY})\r
192         ELSE(ICONV_LIBRARY)\r
193                 IF(WIN32)\r
194                         MESSAGE(FATAL ERROR "Could not find iconv library.  You must set the location manually, or turn off charset conversion.")\r
195                 ENDIF(WIN32)\r
196         ENDIF(ICONV_LIBRARY)\r
197 ENDIF(DO_CHARSET_CONVERSION)\r