]>
Commit | Line | Data |
---|---|---|
9f5d99f5 | 1 | # |
ed4837b2 | 2 | # Copyright (C) 2003-2018 Sébastien Helleu <flashcode@flashtux.org> |
6562d676 SH |
3 | # Copyright (C) 2007-2008 Julien Louis <ptitlouis@sysif.net> |
4 | # Copyright (C) 2008-2009 Emmanuel Bouthenot <kolter@openics.org> | |
5 | # | |
6 | # This file is part of WeeChat, the extensible chat client. | |
7 | # | |
8 | # WeeChat is free software; you can redistribute it and/or modify | |
9f5d99f5 | 9 | # it under the terms of the GNU General Public License as published by |
f1a39ce7 | 10 | # the Free Software Foundation; either version 3 of the License, or |
9f5d99f5 SH |
11 | # (at your option) any later version. |
12 | # | |
6562d676 | 13 | # WeeChat is distributed in the hope that it will be useful, |
9f5d99f5 SH |
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | # GNU General Public License for more details. | |
17 | # | |
18 | # You should have received a copy of the GNU General Public License | |
6562d676 | 19 | # along with WeeChat. If not, see <http://www.gnu.org/licenses/>. |
9f5d99f5 SH |
20 | # |
21 | ||
1f787ddc JL |
22 | cmake_minimum_required(VERSION 2.4) |
23 | ||
7618fdd2 SH |
24 | project(weechat C) |
25 | ||
33450ddb | 26 | # CMake options |
7618fdd2 SH |
27 | set(CMAKE_VERBOSE_MAKEFILE OFF) |
28 | set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) | |
29 | set(CMAKE_SKIP_RPATH ON) | |
d9251df1 SH |
30 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror-implicit-function-declaration") |
31 | set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror-implicit-function-declaration") | |
7618fdd2 | 32 | |
33450ddb | 33 | # version |
cfc1f397 SH |
34 | execute_process(COMMAND ${CMAKE_SOURCE_DIR}/version.sh devel-major OUTPUT_VARIABLE VERSION_MAJOR) |
35 | execute_process(COMMAND ${CMAKE_SOURCE_DIR}/version.sh devel-minor OUTPUT_VARIABLE VERSION_MINOR) | |
36 | execute_process(COMMAND ${CMAKE_SOURCE_DIR}/version.sh devel-patch OUTPUT_VARIABLE VERSION_PATCH) | |
37 | string(REGEX REPLACE "\n" "" VERSION_MAJOR "${VERSION_MAJOR}") | |
38 | string(REGEX REPLACE "\n" "" VERSION_MINOR "${VERSION_MINOR}") | |
39 | string(REGEX REPLACE "\n" "" VERSION_PATCH "${VERSION_PATCH}") | |
33450ddb SH |
40 | if(VERSION_PATCH STREQUAL "") |
41 | set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}) | |
42 | else() | |
43 | set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) | |
44 | endif() | |
45 | ||
46 | # license | |
7618fdd2 | 47 | set(LICENSE "GPL3") |
33450ddb | 48 | |
26f415f5 SH |
49 | # add definitions for version and license |
50 | if(COMMAND cmake_policy) | |
51 | cmake_policy(SET CMP0005 NEW) | |
52 | add_definitions(-DWEECHAT_VERSION="${VERSION}" -DWEECHAT_LICENSE="${LICENSE}") | |
53 | else() | |
54 | add_definitions(-DWEECHAT_VERSION='"${VERSION}"' -DWEECHAT_LICENSE='"${LICENSE}"') | |
55 | endif() | |
56 | ||
33450ddb | 57 | # package string |
7618fdd2 SH |
58 | set(PKG_STRING "${PROJECT_NAME} ${VERSION}") |
59 | string(REPLACE "\";\"" "\ " PKG_STRING ${PKG_STRING}) | |
60 | ||
61 | if(DEFINED LIBDIR) | |
62 | set(LIBDIR ${LIBDIR}/${PROJECT_NAME}) | |
63 | else() | |
64 | set(LIBDIR ${CMAKE_INSTALL_PREFIX}/lib/${PROJECT_NAME}) | |
65 | endif() | |
66 | ||
67 | if(NOT DEFINED SHAREDIR) | |
68 | set(SHAREDIR ${CMAKE_INSTALL_PREFIX}/share) | |
69 | endif() | |
70 | ||
71 | if(NOT DEFINED MANDIR) | |
72 | set(MANDIR ${SHAREDIR}/man) | |
73 | endif() | |
74 | ||
75 | if(NOT DEFINED LOCALEDIR) | |
76 | set(LOCALEDIR ${SHAREDIR}/locale) | |
77 | endif() | |
78 | ||
79 | if(DEFINED INCLUDEDIR) | |
80 | set(INCLUDEDIR ${INCLUDEDIR}/${PROJECT_NAME}) | |
81 | else() | |
82 | set(INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME}) | |
83 | endif() | |
84 | ||
805717e9 SH |
85 | option(ENABLE_NCURSES "Compile the Ncurses interface" ON) |
86 | option(ENABLE_HEADLESS "Compile the headless binary (required for tests)" ON) | |
6908ef0c SH |
87 | option(ENABLE_NLS "Enable Native Language Support" ON) |
88 | option(ENABLE_GNUTLS "Enable SSLv3/TLS support" ON) | |
89 | option(ENABLE_LARGEFILE "Enable Large File Support" ON) | |
90 | option(ENABLE_ALIAS "Enable Alias plugin" ON) | |
91 | option(ENABLE_ASPELL "Enable Aspell plugin" ON) | |
92 | option(ENABLE_ENCHANT "Enable Enchant lib for Aspell plugin" OFF) | |
edfeb60e | 93 | option(ENABLE_BUFLIST "Enable Buflist plugin" ON) |
6908ef0c SH |
94 | option(ENABLE_CHARSET "Enable Charset plugin" ON) |
95 | option(ENABLE_EXEC "Enable Exec plugin" ON) | |
96 | option(ENABLE_FIFO "Enable FIFO plugin" ON) | |
2a5eb156 | 97 | option(ENABLE_FSET "Enable Fast Set plugin" ON) |
6908ef0c SH |
98 | option(ENABLE_IRC "Enable IRC plugin" ON) |
99 | option(ENABLE_LOGGER "Enable Logger plugin" ON) | |
100 | option(ENABLE_RELAY "Enable Relay plugin" ON) | |
03456722 | 101 | option(ENABLE_SCRIPT "Enable Script plugin (script manager)" ON) |
6908ef0c SH |
102 | option(ENABLE_SCRIPTS "Enable script plugins (perl, python, ...)" ON) |
103 | option(ENABLE_PERL "Enable Perl scripting language" ON) | |
104 | option(ENABLE_PYTHON "Enable Python scripting language" ON) | |
35712daa | 105 | option(ENABLE_PYTHON3 "Use Python 3.x if found (NOT recommended because many \"official\" scripts won't work)" OFF) |
6908ef0c SH |
106 | option(ENABLE_RUBY "Enable Ruby scripting language" ON) |
107 | option(ENABLE_LUA "Enable Lua scripting language" ON) | |
108 | option(ENABLE_TCL "Enable Tcl scripting language" ON) | |
109 | option(ENABLE_GUILE "Enable Scheme (guile) scripting language" ON) | |
145191db | 110 | option(ENABLE_JAVASCRIPT "Enable JavaScript scripting language" ON) |
d032ee21 | 111 | option(ENABLE_PHP "Enable PHP scripting language" ON) |
6908ef0c SH |
112 | option(ENABLE_TRIGGER "Enable Trigger plugin" ON) |
113 | option(ENABLE_XFER "Enable Xfer plugin" ON) | |
114 | option(ENABLE_MAN "Enable build of man page" OFF) | |
115 | option(ENABLE_DOC "Enable build of documentation" OFF) | |
116 | option(ENABLE_TESTS "Enable tests" OFF) | |
9f5d99f5 | 117 | |
805717e9 SH |
118 | # headless mode is required for tests |
119 | if(ENABLE_TESTS AND NOT ENABLE_HEADLESS) | |
120 | message(FATAL_ERROR "Headless mode is required for tests.") | |
121 | endif() | |
122 | ||
87e342dd | 123 | # option WEECHAT_HOME |
7618fdd2 SH |
124 | if(NOT DEFINED WEECHAT_HOME OR "${WEECHAT_HOME}" STREQUAL "") |
125 | set(WEECHAT_HOME "~/.weechat") | |
126 | endif() | |
127 | set(WEECHAT_HOME "${WEECHAT_HOME}" CACHE | |
34e0226e SH |
128 | STRING "WeeChat home directory for config, logs, scripts.. (default is \"~/.weechat\")" |
129 | FORCE) | |
7618fdd2 | 130 | mark_as_advanced(CLEAR WEECHAT_HOME) |
34e0226e | 131 | |
87e342dd | 132 | # option CA_FILE |
7618fdd2 SH |
133 | if(NOT DEFINED CA_FILE OR "${CA_FILE}" STREQUAL "") |
134 | set(CA_FILE "/etc/ssl/certs/ca-certificates.crt") | |
135 | endif() | |
136 | set(CA_FILE "${CA_FILE}" CACHE | |
87e342dd SH |
137 | STRING "File containing the certificate authorities (default is \"/etc/ssl/certs/ca-certificates.crt\"). This is the default value of option \"weechat.network.gnutls_ca_file\"." |
138 | FORCE) | |
7618fdd2 | 139 | mark_as_advanced(CLEAR CA_FILE) |
87e342dd | 140 | |
91ce4017 SH |
141 | if(COMMAND cmake_policy) |
142 | if(POLICY CMP0003) | |
143 | cmake_policy(SET CMP0003 NEW) | |
144 | endif() | |
145 | if(POLICY CMP0017) | |
146 | cmake_policy(SET CMP0017 NEW) | |
147 | endif() | |
148 | endif() | |
149 | ||
150 | add_definitions(-DHAVE_CONFIG_H) | |
151 | ||
152 | include(CheckIncludeFiles) | |
153 | include(CheckFunctionExists) | |
154 | include(CheckSymbolExists) | |
155 | ||
156 | check_include_files("langinfo.h" HAVE_LANGINFO_CODESET) | |
157 | check_include_files("sys/resource.h" HAVE_SYS_RESOURCE_H) | |
158 | ||
159 | check_function_exists(mallinfo HAVE_MALLINFO) | |
160 | ||
161 | check_symbol_exists("eat_newline_glitch" "term.h" HAVE_EAT_NEWLINE_GLITCH) | |
162 | ||
163 | # Check for Large File Support | |
164 | if(ENABLE_LARGEFILE) | |
165 | add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_LARGE_FILES) | |
166 | endif() | |
167 | ||
168 | # Check for Gettext | |
169 | if(ENABLE_NLS) | |
170 | find_package(Gettext) | |
171 | if(GETTEXT_FOUND) | |
172 | add_definitions(-DENABLE_NLS) | |
173 | endif() | |
174 | endif() | |
175 | ||
176 | # Check for libgcrypt | |
177 | find_package(GCRYPT REQUIRED) | |
178 | add_definitions(-DHAVE_GCRYPT) | |
179 | list(APPEND EXTRA_LIBS ${GCRYPT_LDFLAGS}) | |
180 | ||
181 | # Check for GnuTLS | |
182 | if(ENABLE_GNUTLS) | |
183 | find_package(GnuTLS) | |
184 | if(GNUTLS_FOUND) | |
185 | string(REGEX REPLACE "/[^/]*$" "" GNUTLS_LIBRARY_PATH "${GNUTLS_LIBRARY}") | |
186 | add_definitions(-DHAVE_GNUTLS) | |
187 | include_directories(${GNUTLS_INCLUDE_PATH}) | |
188 | set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -L${GNUTLS_LIBRARY_PATH}") | |
189 | list(APPEND EXTRA_LIBS gnutls) | |
190 | endif() | |
191 | endif() | |
192 | ||
193 | # Check for zlib | |
194 | find_package(ZLIB REQUIRED) | |
195 | add_definitions(-DHAVE_ZLIB) | |
196 | ||
197 | # Check for iconv | |
198 | find_package(Iconv) | |
199 | if(ICONV_FOUND) | |
d0b95b68 | 200 | add_definitions(-DHAVE_ICONV) |
91ce4017 SH |
201 | endif() |
202 | ||
203 | # Check for CURL | |
204 | find_package(CURL REQUIRED) | |
205 | ||
206 | # weechat_gui_common MUST be the first lib in the list | |
207 | set(STATIC_LIBS weechat_gui_common) | |
208 | ||
209 | find_library(DL_LIBRARY | |
210 | NAMES dl | |
211 | PATHS /lib /usr/lib /usr/libexec /usr/local/lib /usr/local/libexec | |
212 | ) | |
213 | list(APPEND STATIC_LIBS weechat_plugins) | |
214 | if(DL_LIBRARY) | |
215 | string(REGEX REPLACE "/[^/]*$" "" DL_LIBRARY_PATH "${DL_LIBRARY}") | |
216 | set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -L${DL_LIBRARY_PATH}") | |
217 | list(APPEND EXTRA_LIBS dl) | |
218 | endif() | |
219 | ||
7618fdd2 | 220 | if(ENABLE_NLS) |
d0b95b68 | 221 | add_subdirectory(po) |
7618fdd2 | 222 | endif() |
2487d8a5 | 223 | |
d0b95b68 SH |
224 | add_subdirectory(src) |
225 | add_subdirectory(doc) | |
9f5d99f5 | 226 | |
32625994 SH |
227 | find_package(CppUTest) |
228 | if(ENABLE_TESTS AND CPPUTEST_FOUND) | |
db9a8e7b | 229 | enable_testing() |
d0b95b68 | 230 | add_subdirectory(tests) |
db9a8e7b SH |
231 | endif() |
232 | ||
7618fdd2 | 233 | configure_file(config.h.cmake config.h @ONLY) |
07d9deaf | 234 | |
2b78673a | 235 | # set the git version in "config-git.h" |
7618fdd2 | 236 | add_custom_target(version_git ALL |
80293c24 | 237 | COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/tools/git-version.sh" "${CMAKE_CURRENT_SOURCE_DIR}" "${VERSION}" "config-git.h" |
2b78673a SH |
238 | WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") |
239 | ||
7618fdd2 | 240 | configure_file( |
07d9deaf JL |
241 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" |
242 | "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" | |
243 | IMMEDIATE @ONLY) | |
244 | ||
7618fdd2 | 245 | add_custom_target(uninstall |
07d9deaf JL |
246 | "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") |
247 | ||
7618fdd2 | 248 | add_custom_target(dist |
5cc40052 | 249 | "${CMAKE_CURRENT_SOURCE_DIR}/tools/makedist.sh" "${VERSION}" "HEAD" "${CMAKE_CURRENT_BINARY_DIR}" |
857fb35d | 250 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |
07d9deaf | 251 | |
55aa9dd0 | 252 | # pkgconfig file |
7618fdd2 SH |
253 | set(PACKAGE "${PROJECT_NAME}") |
254 | set(prefix "${CMAKE_INSTALL_PREFIX}") | |
255 | set(exec_prefix "\${prefix}") | |
256 | set(libdir "\${exec_prefix}/lib") | |
257 | set(includedir "\${prefix}/include") | |
258 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/weechat.pc.in ${CMAKE_CURRENT_BINARY_DIR}/weechat.pc @ONLY) | |
259 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/weechat.pc DESTINATION ${LIBDIR}/../pkgconfig) | |
55aa9dd0 | 260 | |
1466a565 | 261 | # cygport file (used to build Cygwin packages) |
7618fdd2 | 262 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/weechat.cygport.in ${CMAKE_CURRENT_BINARY_DIR}/weechat-${VERSION}-1.cygport @ONLY) |
1466a565 | 263 | |
8c3b85a0 SH |
264 | # install some files (only on Cygwin) |
265 | if(CYGWIN) | |
266 | install(FILES | |
b7bdbbdc SH |
267 | ${CMAKE_CURRENT_SOURCE_DIR}/AUTHORS.adoc |
268 | ${CMAKE_CURRENT_SOURCE_DIR}/ChangeLog.adoc | |
269 | ${CMAKE_CURRENT_SOURCE_DIR}/Contributing.adoc | |
270 | ${CMAKE_CURRENT_SOURCE_DIR}/README.adoc | |
271 | ${CMAKE_CURRENT_SOURCE_DIR}/ReleaseNotes.adoc | |
8c3b85a0 SH |
272 | DESTINATION ${SHAREDIR}/doc/${PROJECT_NAME}) |
273 | endif() | |
274 | ||
4b4d80bd | 275 | # icon |
7618fdd2 | 276 | install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/weechat.png DESTINATION ${SHAREDIR}/icons/hicolor/32x32/apps) |
4b4d80bd | 277 | |
1f67c879 | 278 | # packages |
7618fdd2 SH |
279 | set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Fast, light and extensible chat client") |
280 | set(CPACK_PACKAGE_VENDOR "Sébastien Helleu") | |
b7bdbbdc | 281 | set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.adoc") |
7618fdd2 SH |
282 | set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") |
283 | set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) | |
284 | set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) | |
285 | set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH}) | |
1f67c879 SH |
286 | |
287 | # binary package | |
7618fdd2 SH |
288 | set(CPACK_GENERATOR "STGZ;TGZ;TBZ2") |
289 | set(CPACK_PACKAGE_FILE_NAME weechat-binary-${VERSION}) | |
1f67c879 SH |
290 | |
291 | # source package | |
7618fdd2 SH |
292 | set(CPACK_SOURCE_GENERATOR "TGZ;TBZ2") |
293 | set(CPACK_SOURCE_PACKAGE_FILE_NAME weechat-${VERSION}) | |
294 | set(CPACK_SOURCE_IGNORE_FILES "/\\\\.git" "/build/" "/m4/" | |
1f67c879 SH |
295 | "/autom4te\\\\.cache/" "/ABOUT-NLS$" "/config\\\\.guess$" "/config\\\\.h$" |
296 | "/config\\\\.h.in$" "/config\\\\.log$" "/config\\\\.rpath$" | |
297 | "/config\\\\.status$" "/config\\\\.sub$" "/configure$" "/depcomp$" | |
298 | "/install-sh$" "/missing$" "/intl/" "/libtool$" "/\\\\.libs/" | |
cf500946 SH |
299 | "/ltmain\\\\.sh$" "/\\\\.deps/" "/html/" "/html1/" "/Makefile$" |
300 | "/Makefile\\\\.in$" "stamp" "/po/.*\\\\.header$" "\\\\.gmo$" "~$" "\\\\.o$" | |
996da2f6 | 301 | "\\\\.lo$" "\\\\.a$" "\\\\.la$" "\\\\.lai$" "\\\\.Plo$" "/weechat$" |
1f67c879 SH |
302 | ) |
303 | ||
7618fdd2 | 304 | include(CPack) |