1 # This is the cmake-based build system for Quassel IRC.
3 # You may pass various options to cmake:
5 # -DWANT_(CORE|QTCLIENT|MONO)=(ON|OFF)
6 # : select binaries to build
7 # -DWITH_OPENSSL=OFF : Disable OpenSSL support
8 # -DWITH_DBUS=OFF : Disable D-Bus support (dbus notifications)
9 # -DWITH_WEBKIT=OFF : Disable WebKit support (link previews)
10 # -DWITH_PHONON=OFF : Disable Phonon support (audio notifications)
11 # -DWITH_LIBINDICATE=OFF : Disable libindicate support (Ayatana notifications)
12 # -DWITH_KDE=ON : Enable KDE4 support
13 # -DWITH_CRYPT=OFF : Disable encryption support
14 # -DWITH_OXYGEN=(ON|OFF) : Whether to install Oxygen icons (default: yes, unless KDE > 4.3.0 is present and enabled)
15 # -DWITH_SYSLOG=OFF : Disable syslog support
17 # -DEMBED_DATA=ON : Embed all data files in icons the binary, rather than installing them separately
19 # -DQT=/path/to/qt : Choose a Qt4 installation to use instead of the system Qt4
20 # -DSTATIC=ON : Enable static building of Quassel. Use with care.
21 # -DDEPLOY=ON : Mac OS X only. Use only for creating Quassel Packages!
23 # -DWITH_QT5=ON : Enable (very) experimental support for Qt5 (see doc/README.Qt5!)
25 # NOTE: You should remove CMakeCache.txt if you plan to change any of these values!
28 cmake_minimum_required(VERSION 2.8.9)
35 set(QUASSEL_VERSION_STRING "0.11-pre")
37 # Tell CMake about or own modules
38 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
40 # General conveniences
42 set(CMAKE_INCLUDE_CURRENT_DIR ON)
45 include(CheckFunctionExists)
46 include(CheckIncludeFile)
48 include(QuasselCompileSettings)
49 include(QuasselMacros)
51 # Various options and variables that can be set on the command line
52 option(WANT_CORE "Build the core (server) binary" ON)
53 option(WANT_QTCLIENT "Build the Qt4 GUI client binary" ON)
54 option(WANT_MONO "Build the monolithic (all-in-one) binary" ON)
56 option(WITH_OPENSSL "Enable OpenSSL support if present on the system" ON)
57 option(WITH_DBUS "Enable D-Bus support if present on the system" ON)
58 option(WITH_WEBKIT "Enable WebKit support (for link previews)" ON)
59 option(WITH_PHONON "Enable Phonon support (for audio notifications)" ON)
60 option(WITH_LIBINDICATE "Enable Ayatana notification support" ON)
61 option(WITH_KDE "Enable KDE4 integration" OFF)
62 option(WITH_CRYPT "Enable encryption support if present on system" ON)
63 option(WITH_SYSLOG "Use syslog for storing log data" ON)
65 # We use icon paths from KDE 4.3.x, which are partially invalid on older and possibly
66 # even on newer KDE versions. Do not disable this unless you are sure that your Quassel will
67 # run on a matching KDE version only.
68 set(WITH_OXYGEN AUTO CACHE STRING "Install Oxygen icons (default is \"AUTO\" to install when KDE 4.3 or later is present")
70 # Enable very experimental support for Qt5. Might break the compilation, or even more!
71 option(WITH_QT5 "Enable (very) experimental support for Qt5" OFF)
73 option(STATIC "Enable static building (might not be portable)" OFF)
76 option(DEPLOY "Mac OS X only! Adds required libs to bundle resources and create a dmg. Note: requires Qt to be built with 10.4u SDK" OFF)
77 # Notification Center is only available in > 10.8, which is Darwin v12
78 if(CMAKE_SYSTEM_VERSION VERSION_GREATER "11.9.9")
79 option(WITH_NOTIFICATION_CENTER "Enable OS X Notification Center support" ON)
80 endif(CMAKE_SYSTEM_VERSION VERSION_GREATER "11.9.9")
83 # Default to embedding data in the static case
87 set(EMBED_DEFAULT ON) # should be OFF as soon as everything works
88 endif(STATIC OR WIN32)
90 option(EMBED_DATA "Embed all data files in the binary (rather than installing them separately)" ${EMBED_DEFAULT})
92 set(QT "" CACHE STRING "Path to a Qt installation to use instead of the system Qt (e.g. for static builds)")
94 # Some settings imply others
96 add_definitions(-DSTATIC)
97 set(WITH_KDE OFF CACHE BOOL "Static building with KDE is not supported")
101 # We don't support separately installed resources yet on Win32
105 # For static builds, arbitrary extra libs might need to be linked
106 # Define a comma-separated list here
107 # e.g. for pgsql, we need -DLINK_EXTRA=pq;crypt
108 set(LINK_EXTRA "" CACHE STRING "Semicolon-separated list of libraries to be linked")
110 string(REPLACE "," ";" LINK_EXTRA ${LINK_EXTRA})
111 link_libraries(${LINK_EXTRA})
118 if(WANT_MONO OR WANT_QTCLIENT)
120 endif(WANT_MONO OR WANT_QTCLIENT)
121 if(WANT_MONO OR WANT_CORE)
123 endif(WANT_MONO OR WANT_CORE)
130 set(QT_MIN_VERSION "5.0.0")
131 add_definitions(-DHAVE_QT5)
133 # Qt5 needs a new enough cmake...
134 cmake_minimum_required(VERSION 2.8.6 FATAL_ERROR)
137 set(CMAKE_AUTOMOC ON)
140 # GUI stuff needs some new features
142 set(QT_MIN_VERSION "4.6.0")
144 set(QT_MIN_VERSION "4.4.0")
153 find_package(Qt5Core ${QT_MIN_VERSION} REQUIRED)
155 set(CLIENT_QT_MODULES ${CLIENT_QT_MODULES} Widgets)
157 # Setup the i18n-related variables
158 find_package(Qt5LinguistTools)
161 # Select a Qt installation here, if you don't want to use system Qt
163 # FindQt4 will look for the qmake binary in $PATH, so we just prepend the Qt dir
164 set(ENV{PATH} ${QT}/bin:$ENV{PATH})
167 # Now that we have the correct $PATH, lets find Qt!
168 find_package(Qt4 ${QT_MIN_VERSION} REQUIRED)
172 # Neither Qt4 nor Qt5 consider lconvert relevant, so they don't support finding it...
173 # Rather than shipping hacked buildsys files, let's just infer the path from lrelease
174 if(QT_LRELEASE_EXECUTABLE)
175 get_filename_component(_lrelease_path ${QT_LRELEASE_EXECUTABLE} PATH)
177 find_program(QT_LCONVERT_EXECUTABLE NAMES lconvert-qt5 lconvert PATHS ${_lrelease_path} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
179 find_program(QT_LCONVERT_EXECUTABLE NAMES lconvert-qt4 lconvert PATHS ${_lrelease_path} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
181 endif(QT_LRELEASE_EXECUTABLE)
184 # zlib for compression, however we can always fall back to miniz
187 message(STATUS "Using system zlib for compression")
188 add_definitions(-DHAVE_ZLIB)
189 include_directories(${ZLIB_INCLUDE_DIRS})
190 set(COMMON_LIBRARIES ${COMMON_LIBRARIES} ${ZLIB_LIBRARIES})
192 message(STATUS "zlib NOT found, using bundled miniz for compression")
193 if(${CMAKE_SIZEOF_VOID_P} EQUAL 4)
194 message(STATUS "WARNING: This may be slow on 32 bit systems!")
199 # Execinfo is needed for generating backtraces
200 find_package(ExecInfo)
202 add_definitions(-DHAVE_EXECINFO)
203 include_directories(${EXECINFO_INCLUDES})
204 link_libraries(${EXECINFO_LIBRARIES})
205 endif(EXECINFO_FOUND)
208 # PkgConfig isn't strictly required.
209 # However, some optional deps might not be found if it's not present, so warn!
210 find_package(PkgConfig)
211 if(NOT PKG_CONFIG_FOUND)
212 message(STATUS "WARNING: PkgConfig not available! Some dependencies for optional features might not be found.")
213 message(STATUS " Affected features might include encryption support, DBus menus and Ayatana notifications.")
214 endif(NOT PKG_CONFIG_FOUND)
218 # We don't link to or include OpenSSL ourselves, but use exclusively the Qt API.
219 # Thus, we simply check if OpenSSL support is present in Qt's config and enable our
220 # own SSL stuff in this case. Qt should care for adding what it needs itself.
222 if(QT_QCONFIG MATCHES "openssl")
223 message(STATUS "Found OpenSSL support in Qt, enabling SSL")
224 add_definitions(-DHAVE_SSL)
226 else(QT_QCONFIG MATCHES "openssl")
227 message(STATUS "No OpenSSL support found in Qt, disabling SSL")
228 add_definitions(-DQT_NO_OPENSSL)
229 endif(QT_QCONFIG MATCHES "openssl")
231 message(STATUS "Not enabling OpenSSL support")
235 # Check for GUI specific stuff
238 # Setup D-Bus support
241 find_package(Qt5DBus ${QT_MIN_VERSION})
242 find_package(Qt5DBusTools)
245 if(QT_QTDBUS_FOUND OR (Qt5DBus_FOUND AND Qt5DBusTools_FOUND))
246 message(STATUS "Found QtDBus, enabling D-Bus support")
247 add_definitions(-DHAVE_DBUS)
249 set(CLIENT_QT_MODULES ${CLIENT_QT_MODULES} DBus)
251 # check if we have dbusmenu as well
253 find_package(DBusMenuQt)
255 message(STATUS "Enabling support for exporting the tray menu via D-Bus")
256 add_definitions(-DHAVE_DBUSMENU)
257 include_directories(${DBUSMENUQT_INCLUDE_DIR})
258 set(CLIENT_LIBRARIES ${CLIENT_LIBRARIES} ${DBUSMENUQT_LIBRARIES})
259 set(CLIENT_COMPILE_FLAGS "${CLIENT_COMPILE_FLAGS} ${DBUSMENUQT_DEFINITIONS}")
260 else(DBUSMENUQT_FOUND)
261 message(STATUS "Disabling support for exporting the tray menu via D-Bus")
262 endif(DBUSMENUQT_FOUND)
265 else(QT_QTDBUS_FOUND OR (Qt5DBus_FOUND AND Qt5DBusTools_FOUND))
266 message(STATUS "QtDBus not found, disabling D-Bus support")
267 endif(QT_QTDBUS_FOUND OR (Qt5DBus_FOUND AND Qt5DBusTools_FOUND))
269 message(STATUS "Not enabling D-Bus support")
272 # Setup QtWebkit support
275 find_package(Qt5Webkit ${QT_MIN_VERSION} QUIET)
277 if(QT_QTWEBKIT_FOUND OR Qt5Webkit_FOUND)
278 message(STATUS "Found QtWebKit, enabling WebKit support")
279 add_definitions(-DHAVE_WEBKIT)
280 set(CLIENT_QT_MODULES ${CLIENT_QT_MODULES} Webkit XmlPatterns)
281 set(HAVE_WEBKIT true)
282 else(QT_QTWEBKIT_FOUND OR Qt5Webkit_FOUND)
283 message(STATUS "QtWebkit not found, disabling Webkit support")
284 endif(QT_QTWEBKIT_FOUND OR Qt5Webkit_FOUND)
286 message(STATUS "Not enabling Webkit support")
290 if(WITH_KDE AND NOT WITH_QT5)
291 # KDE has overzealous CFLAGS making miniz not compile, so save our old flags
292 set(_cflags ${CMAKE_C_FLAGS})
295 message(STATUS "Enabling KDE4 integration")
296 include_directories(${KDE4_INCLUDES})
297 add_definitions(-DHAVE_KDE ${KDE4_DEFINITIONS})
299 set(CLIENT_LIBRARIES ${CLIENT_LIBRARIES} ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBRARY} ${KDE4_SOLID_LIBS} ${KDE4_KNOTIFYCONFIG_LIBRARY})
300 # We always use external icons for KDE4 support, since we use its iconloader rather than our own
302 # Restore our old CFLAGS
303 set(CMAKE_C_FLAGS ${_cflags})
305 message(STATUS "KDE4 not found, disabling KDE integration")
307 else(WITH_KDE AND NOT WITH_QT5)
308 message(STATUS "Not enabling KDE4 integration")
309 endif(WITH_KDE AND NOT WITH_QT5)
311 # Setup Phonon support - we only need this if we don't have or want KDE4
315 find_package(Qt5phonon)
317 message(STATUS "Enabling Phonon support")
318 add_definitions(-DHAVE_PHONON)
319 set(HAVE_PHONON true)
320 set(CLIENT_QT_MODULES ${CLIENT_QT_MODULES} phonon)
321 else(Qt5phonon_FOUND)
322 message(STATUS "Phonon not found, disabling audio notifications")
323 endif(Qt5phonon_FOUND)
327 message(STATUS "Enabling Phonon support")
328 add_definitions(-DHAVE_PHONON)
329 include_directories(${PHONON_INCLUDES})
330 set(CLIENT_LIBRARIES ${CLIENT_LIBRARIES} ${PHONON_LIBS})
331 set(HAVE_PHONON true)
333 message(STATUS "Phonon not found, disabling audio notifications")
337 message(STATUS "Not enabling Phonon support")
340 find_package(Libsnore)
342 add_definitions(-DHAVE_LIBSNORE)
343 set(CLIENT_LIBRARIES ${CLIENT_LIBRARIES} ${LIBSNORE_LIBRARIES})
344 set(HAVE_SNORENOTIFY true)
345 endif(LIBSNORE_FOUND)
348 # Setup libindicate-qt support
349 if(WITH_LIBINDICATE AND NOT WITH_QT5)
350 pkg_check_modules(INDICATEQT QUIET indicate-qt>=0.2.1)
352 message(STATUS "Enabling Ayatana notification support")
353 set(HAVE_INDICATEQT true)
354 add_definitions(-DHAVE_INDICATEQT)
355 link_directories(${INDICATEQT_LIBRARY_DIRS})
356 set(CLIENT_LIBRARIES ${CLIENT_LIBRARIES} ${INDICATEQT_LIBRARIES})
357 else(INDICATEQT_FOUND)
358 message(STATUS "Disabling Ayatana notification support")
359 endif(INDICATEQT_FOUND)
360 else(WITH_LIBINDICATE AND NOT WITH_QT5)
361 message(STATUS "Not enabling Ayatana notification support")
362 # We don't want to link against it even if another package has found it
363 set(INDICATEQT_LIBRARIES "")
364 endif(WITH_LIBINDICATE AND NOT WITH_QT5)
366 # Setup OS X notification center support
367 if(WITH_NOTIFICATION_CENTER AND APPLE)
368 set(HAVE_NOTIFICATION_CENTER true)
369 add_definitions(-DHAVE_NOTIFICATION_CENTER)
370 set(CLIENT_LIBRARIES ${CLIENT_LIBRARIES}
371 /System/Library/Frameworks/Foundation.framework
379 # Setup encryption support
380 if(WITH_CRYPT AND NOT WITH_QT5)
383 message(STATUS "Enabling encryption support")
384 add_definitions(-DHAVE_QCA2)
387 set(MOC_DEFINES ${MOC_DEFINES} -DHAVE_QCA2)
389 message(STATUS "Disabling encryption support")
391 else(WITH_CRYPT AND NOT WITH_QT5)
392 message(STATUS "Not enabling encryption support")
393 endif(WITH_CRYPT AND NOT WITH_QT5)
395 # Setup syslog support
397 check_include_file(syslog.h HAVE_SYSLOG_H)
399 message(STATUS "Enabling syslog support")
400 set(HAVE_SYSLOG true)
401 add_definitions(-DHAVE_SYSLOG)
403 message(STATUS "Disabling syslog support")
406 message(STATUS "Not enabling syslog support")
415 # needed to compile with mingw without kde
416 if(MINGW AND NOT HAVE_KDE)
417 add_definitions(-D_WIN32_WINNT=0x0500)
418 message(STATUS "Added _WIN32_WINNT=0x0500 definition for MinGW")
419 # workaround for bug in mingw gcc 4.0
420 add_definitions(-U__STRICT_ANSI__)
421 endif(MINGW AND NOT HAVE_KDE)
423 # Now set up install locations; those are set by KDE if integration is enabled
426 set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX} CACHE FILEPATH "Install path for binaries")
427 set(DATA_INSTALL_DIR $ENV{APPDATA}/quassel-irc.org/share/apps CACHE FILEPATH "Install path for data files")
428 set(ICON_INSTALL_DIR $ENV{APPDATA}/quassel-irc.org/share/icons CACHE FILEPATH "Global icon install path")
429 set(XDG_APPS_INSTALL_DIR $ENV{APPDATA}/quassel-irc.org/share/applications CACHE FILEPATH "Install path for .desktop files")
431 set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin CACHE FILEPATH "Install path for binaries")
432 set(DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/apps CACHE FILEPATH "Install path for data files")
433 set(ICON_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/icons CACHE FILEPATH "Global icon install path")
434 set(XDG_APPS_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/applications CACHE FILEPATH "Install path for .desktop files")
439 message(STATUS "Embedding data files into the binary")
441 message(STATUS "Installing data files separately")
444 # RPATH needs to be set correctly
445 # Do this down here, since otherwise KDE wants to handle it itself, and fails
446 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH 1)
447 set(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
449 # Set global buildflags
450 # This is very much non-portable, so don't use -DSTATIC until you know what
452 if(STATIC AND CMAKE_COMPILER_IS_GNUCXX)
453 set(CMAKE_CXX_FLAGS "-static-libgcc ${CMAKE_CXX_FLAGS}")
454 link_directories(${CMAKE_BINARY_DIR}/staticlibs) # override dynamic libs
456 set(QUASSEL_SSL_LIBRARIES ssl crypto) # these miss in static builds
458 endif(STATIC AND CMAKE_COMPILER_IS_GNUCXX)
461 link_libraries(imm32 winmm dbghelp Secur32) # missing by default :/
463 set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBUGINFO "/debug /INCREMENTAL:YES /NODEFAULTLIB:libcmt /DEFAULTLIB:msvcrt")
464 set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:YES /NODEFAULTLIB:libcmt")
465 set(CMAKE_EXE_LINKER_FLAGS_DEBUGFULL "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
466 link_libraries(Version dwmapi shlwapi)
468 if(HAVE_SSL AND STATIC)
469 find_package(OpenSSL REQUIRED)
470 link_libraries(${OPENSSL_LIBRARIES} ${OPENSSL_EAY_LIBRARIES})
471 endif(HAVE_SSL AND STATIC)
475 add_definitions(-DXDG_APPS_INSTALL_DIR=${XDG_APPS_INSTALL_DIR})
476 endif(HAVE_INDICATEQT)
479 check_function_exists(umask HAVE_UMASK)
481 add_definitions(-DHAVE_UMASK)
485 # Generate version information from Git
486 include(GetGitRevisionDescription)
487 get_git_head_revision(GIT_REFSPEC GIT_HEAD)
488 git_describe(GIT_DESCRIBE --long)
490 # Sanitize things if we're not in a Git repo
491 if(NOT GIT_HEAD OR NOT GIT_DESCRIBE)
496 configure_file(version.h.in ${CMAKE_BINARY_DIR}/version.h @ONLY)
498 # These variables will be added to the main targets (CORE, QTCLIENT, MONO)
499 set(COMMON_DEPS ${RC_WIN32})
503 # Add needed subdirs - the order is important, since src needs some vars set by other dirs
504 add_subdirectory(data)
505 add_subdirectory(icons)
506 add_subdirectory(pics)
508 add_subdirectory(src)