1 # This is the cmake-based build system for Quassel IRC.
3 # You may pass various options to cmake:
4 # -DWANT_(CORE|QTCLIENT|MONO)=(ON|OFF)
5 # : select binaries to build
6 # -DWITH_OPENSSL=OFF : Disable OpenSSL support
7 # -DWITH_DBUS=OFF : Disable D-Bus support (dbus notifications)
8 # -DWITH_WEBKIT=OFF : Disable WebKit support (link previews)
9 # -DWITH_PHONON=OFF : Disable Phonon support (audio notifications)
10 # -DWITH_LIBINDICATE=OFF : Disable libindicate support (Ayatana notifications)
11 # -DWITH_KDE=ON : Enable KDE4 support
12 # -DWITH_CRYPT=OFF : Disable encryption support
13 # -DWITH_OXYGEN=(ON|OFF) : Whether to install Oxygen icons (default: yes, unless KDE > 4.3.0 is present and enabled)
14 # -DWITH_SYSLOG=OFF : Disable syslog support
16 # -DEMBED_DATA=ON : Embed all data files in icons the binary, rather than installing them separately
18 # -DQT=/path/to/qt : Choose a Qt4 installation to use instead of the system Qt4
19 # -DSTATIC=ON : Enable static building of Quassel. Use with care.
20 # -DDEPLOY=ON : Mac OS X only. Use only for creating Quassel Packages!
22 # NOTE: You should remove CMakeCache.txt if you plan to change any of these values!
26 include(CheckIncludeFile)
28 # cmake 2.6.2 is required for KDE >=4.2 and should be widespread enough now
29 cmake_minimum_required(VERSION 2.6.2 FATAL_ERROR)
31 if(COMMAND cmake_policy)
32 cmake_policy(SET CMP0003 NEW)
33 endif(COMMAND cmake_policy)
35 # Use our own (well, and KDE's) version of some modules
36 # In particular cmake's own FindQt4 and FindOpenSSL are quite buggy
37 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
38 include(QuasselMacros)
40 # Various options and variables that can be set on the command line
41 option(WANT_CORE "Build the core (server) binary" ON)
42 option(WANT_QTCLIENT "Build the Qt4 GUI client binary" ON)
43 option(WANT_MONO "Build the monolithic (all-in-one) binary" ON)
45 option(WITH_OPENSSL "Enable OpenSSL support if present on the system" ON)
46 option(WITH_DBUS "Enable D-Bus support if present on the system" ON)
47 option(WITH_WEBKIT "Enable WebKit support (for link previews)" ON)
48 option(WITH_PHONON "Enable Phonon support (for audio notifications)" ON)
49 option(WITH_LIBINDICATE "Enable Ayatana notification support" ON)
50 option(WITH_KDE "Enable KDE4 integration" OFF)
51 option(WITH_CRYPT "Enable encryption support if present on system" ON)
52 option(WITH_SYSLOG "Use syslog for storing log data" ON)
54 # We use icon paths from KDE 4.3.x, which are partially invalid on older and possibly
55 # even on newer KDE versions. Do not disable this unless you are sure that your Quassel will
56 # run on a matching KDE version only.
57 set(WITH_OXYGEN AUTO CACHE STRING "Install Oxygen icons (default is \"AUTO\" to install when KDE 4.3 or later is present")
59 option(STATIC "Enable static building (might not be portable)" OFF)
62 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)
65 # Default to embedding data in the static case
69 set(EMBED_DEFAULT ON) # should be OFF as soon as everything works
70 endif(STATIC OR WIN32)
72 option(EMBED_DATA "Embed all data files in the binary (rather than installing them separately)" ${EMBED_DEFAULT})
74 set(QT "" CACHE STRING "Path to a Qt installation to use instead of the system Qt (e.g. for static builds)")
76 # Some settings imply others
78 add_definitions(-DSTATIC)
79 set(WITH_KDE OFF CACHE BOOL "Static building with KDE is not supported")
83 # We don't support separately installed resources yet on Win32
87 # For static builds, arbitrary extra libs might need to be linked
88 # Define a comma-separated list here
89 # e.g. for pgsql, we need -DLINK_EXTRA=pq;crypt
90 set(LINK_EXTRA "" CACHE STRING "Semicolon-separated list of libraries to be linked")
92 string(REPLACE "," ";" LINK_EXTRA ${LINK_EXTRA})
93 link_libraries(${LINK_EXTRA})
97 # We need to make sure it's not empty
98 # Supported: Release, RelWithDebugInfo, Debug, Debugfull
100 # On WIN32, only Release seems to work correctly (?)
102 set(DEFAULT_BUILD_TYPE "Release")
104 set(DEFAULT_BUILD_TYPE "RelWithDebugInfo")
107 set(CMAKE_BUILD_TYPE ${DEFAULT_BUILD_TYPE} CACHE STRING "CMake Build Type")
108 if(NOT CMAKE_BUILD_TYPE)
109 set(CMAKE_BUILD_TYPE ${DEFAULT_BUILD_TYPE} CACHE STRING "CMake Build Type" FORCE)
110 endif(NOT CMAKE_BUILD_TYPE)
112 # Enable various flags on gcc
113 if(CMAKE_COMPILER_IS_GNUCXX)
114 # Let's just hope that all gccs support these options and skip the tests...
115 # -fno-strict-aliasing is needed apparently for Qt < 4.6
116 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ansi -Wall -Wextra -Wnon-virtual-dtor -fno-strict-aliasing")
117 set(CMAKE_CXX_FLAGS_RELEASE "-O2 ${CMAKE_CXX_FLAGS}")
118 set(CMAKE_CXX_FLAGS_RELWITHDEBUGINFO "-g -O2 ${CMAKE_CXX_FLAGS}")
119 set(CMAKE_CXX_FLAGS_DEBUG "-g -ggdb -fno-reorder-blocks -fno-schedule-insns -fno-inline ${CMAKE_CXX_FLAGS}")
120 set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3 ${CMAKE_CXX_FLAGS_DEBUG}")
121 endif(CMAKE_COMPILER_IS_GNUCXX)
123 string(TOUPPER ${CMAKE_BUILD_TYPE} upper_build_type)
124 if(upper_build_type STREQUAL "RELEASE" OR upper_build_type STREQUAL "RELWITHDEBUGINFO")
125 add_definitions(-DNDEBUG -DQT_NO_DEBUG)
126 else(upper_build_type STREQUAL "RELEASE" OR upper_build_type STREQUAL "RELWITHDEBUGINFO")
128 endif(upper_build_type STREQUAL "RELEASE" OR upper_build_type STREQUAL "RELWITHDEBUGINFO")
131 set(CMAKE_OSX_ARCHITECTURES "i386;ppc")
132 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.4")
133 set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/")
134 add_definitions(-DMAC_10_4_SDK)
135 endif(APPLE AND DEPLOY)
138 if(WANT_MONO OR WANT_QTCLIENT)
140 endif(WANT_MONO OR WANT_QTCLIENT)
141 if(WANT_MONO OR WANT_CORE)
143 endif(WANT_MONO OR WANT_CORE)
148 # GUI stuff needs some new features
150 set(QT_MIN_VERSION "4.6.0")
152 set(QT_MIN_VERSION "4.4.0")
155 # Execinfo is needed for generating backtraces
156 find_package(ExecInfo)
158 add_definitions(-DHAVE_EXECINFO)
159 include_directories(${EXECINFO_INCLUDES})
160 link_libraries(${EXECINFO_LIBRARIES})
161 endif(EXECINFO_FOUND)
163 # Select a Qt installation here, if you don't want to use system Qt
165 # FindQt4 will look for the qmake binary in $PATH, so we just prepend the Qt dir
166 set(ENV{PATH} ${QT}/bin:$ENV{PATH})
169 # Now that we have the correct $PATH, lets find Qt!
170 find_package(Qt4 REQUIRED)
172 set(QT_DONT_USE_QTGUI 1)
173 include(${QT_USE_FILE})
174 include_directories(${QT_INCLUDES})
176 # PkgConfig isn't strictly required.
177 # However, some optional deps might not be found if it's not present, so warn!
178 find_package(PkgConfig)
179 if(NOT PKG_CONFIG_FOUND)
180 message(STATUS "WARNING: PkgConfig not available! Some dependencies for optional features might not be found.")
181 message(STATUS " Affected features might include encryption support, DBus menus and Ayatana notifications.")
182 endif(NOT PKG_CONFIG_FOUND)
185 # We don't link to or include OpenSSL ourselves, but use exclusively the Qt API.
186 # Thus, we simply check if OpenSSL support is present in Qt's config and enable our
187 # own SSL stuff in this case. Qt should care for adding what it needs itself.
189 if(QT_QCONFIG MATCHES "openssl")
190 message(STATUS "Found OpenSSL support in Qt, enabling SSL")
191 add_definitions(-DHAVE_SSL)
193 else(QT_QCONFIG MATCHES "openssl")
194 message(STATUS "No OpenSSL support found in Qt, disabling SSL")
195 add_definitions(-DQT_NO_OPENSSL)
196 endif(QT_QCONFIG MATCHES "openssl")
198 message(STATUS "Not enabling OpenSSL support")
201 # Check for GUI specific stuff
204 # Setup D-Bus support
207 message(STATUS "Found QtDBus, enabling D-Bus support")
208 add_definitions(-DHAVE_DBUS)
209 set(CLIENT_QT4_VARS ${CLIENT_QT4_VARS} DBUS)
210 set(CLIENT_COMPILE_FLAGS "${CLIENT_COMPILE_FLAGS} -DQT_DBUS_LIB")
213 # check if we have dbusmenu as well
214 find_package(DBusMenuQt)
216 message(STATUS "Enabling support for exporting the tray menu via D-Bus")
217 add_definitions(-DHAVE_DBUSMENU)
218 include_directories(${DBUSMENUQT_INCLUDE_DIR})
219 set(CLIENT_LIBRARIES ${CLIENT_LIBRARIES} ${DBUSMENUQT_LIBRARIES})
220 set(CLIENT_COMPILE_FLAGS "${CLIENT_COMPILE_FLAGS} ${DBUSMENUQT_DEFINITIONS}")
221 else(DBUSMENUQT_FOUND)
222 message(STATUS "Disabling support for exporting the tray menu via D-Bus")
223 endif(DBUSMENUQT_FOUND)
225 else(QT_QTDBUS_FOUND)
226 message(STATUS "QtDBus not found, disabling D-Bus support")
227 endif(QT_QTDBUS_FOUND)
229 message(STATUS "Not enabling D-Bus support")
232 # Setup QtWebKit support
234 if(QT_QTWEBKIT_FOUND)
235 message(STATUS "Found QtWebKit, enabling WebKit support")
236 add_definitions(-DHAVE_WEBKIT)
237 set(CLIENT_QT4_VARS ${CLIENT_QT4_VARS} WEBKIT XMLPATTERNS)
238 set(CLIENT_COMPILE_FLAGS "${CLIENT_COMPILE_FLAGS} -DQT_WEBKIT_LIB -DQT_XMLPATTERNS_LIB")
239 set(HAVE_WEBKIT true)
240 else(QT_QTWEBKIT_FOUND)
241 message(STATUS "QtWebKit not found, disabling WebKit support")
242 endif(QT_QTWEBKIT_FOUND)
244 message(STATUS "Not enabling WebKit support")
251 message(STATUS "Enabling KDE4 integration")
252 include_directories(${KDE4_INCLUDES})
253 add_definitions(-DHAVE_KDE ${KDE4_DEFINITIONS})
255 set(CLIENT_LIBRARIES ${CLIENT_LIBRARIES} ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBRARY} ${KDE4_SOLID_LIBS} knotifyconfig)
256 # We always use external icons for KDE4 support, since we use its iconloader rather than our own
259 message(STATUS "KDE4 not found, disabling KDE integration")
262 message(STATUS "Not enabling KDE4 integration")
265 # Setup Phonon support - we only need this if we don't have or want KDE4
270 message(STATUS "Enabling Phonon support")
271 add_definitions(-DHAVE_PHONON)
272 include_directories(${PHONON_INCLUDES})
273 set(CLIENT_LIBRARIES ${CLIENT_LIBRARIES} ${PHONON_LIBS})
274 set(HAVE_PHONON true)
276 message(STATUS "Phonon not found, disabling audio notifications")
279 message(STATUS "Not enabling Phonon support")
283 # Setup libindicate-qt support
285 pkg_check_modules(INDICATEQT QUIET indicate-qt>=0.2.1)
287 message(STATUS "Enabling Ayatana notification support")
288 set(HAVE_INDICATEQT true)
289 add_definitions(-DHAVE_INDICATEQT)
290 link_directories(${INDICATEQT_LIBRARY_DIRS})
291 set(CLIENT_LIBRARIES ${CLIENT_LIBRARIES} ${INDICATEQT_LIBRARIES})
292 else(INDICATEQT_FOUND)
293 message(STATUS "Disabling Ayatana notification support")
294 endif(INDICATEQT_FOUND)
295 else(WITH_LIBINDICATE)
296 message(STATUS "Not enabling Ayatana notification support")
297 # We don't want to link against it even if another package has found it
298 set(INDICATEQT_LIBRARIES "")
299 endif(WITH_LIBINDICATE)
306 # Setup encryption support
310 message(STATUS "Found QCA2, enabling encryption support")
311 add_definitions(-DHAVE_QCA2)
314 set(MOC_DEFINES ${MOC_DEFINES} -DHAVE_QCA2)
316 message(STATUS "QCA2 not found, disabling encryption support")
319 message(STATUS "Not enabling encryption support")
322 # Setup syslog support
324 check_include_file(syslog.h HAVE_SYSLOG_H)
326 message(STATUS "Enabling syslog support")
327 set(HAVE_SYSLOG true)
328 add_definitions(-DHAVE_SYSLOG)
330 message(STATUS "Disabling syslog support")
333 message(STATUS "Not enabling syslog support")
338 # needed to compile with mingw without kde
339 if(MINGW AND NOT HAVE_KDE)
340 add_definitions(-D_WIN32_WINNT=0x0500)
341 message(STATUS "Added _WIN32_WINNT=0x0500 definition for MinGW")
342 # workaround for bug in mingw gcc 4.0
343 add_definitions(-U__STRICT_ANSI__)
344 endif(MINGW AND NOT HAVE_KDE)
346 # Now set up install locations; those are set by KDE if integration is enabled
349 set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX} CACHE FILEPATH "Install path for binaries")
350 set(DATA_INSTALL_DIR $ENV{APPDATA}/quassel-irc.org/share/apps CACHE FILEPATH "Install path for data files")
351 set(ICON_INSTALL_DIR $ENV{APPDATA}/quassel-irc.org/share/icons CACHE FILEPATH "Global icon install path")
352 set(XDG_APPS_INSTALL_DIR $ENV{APPDATA}/quassel-irc.org/share/applications CACHE FILEPATH "Install path for .desktop files")
354 set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin CACHE FILEPATH "Install path for binaries")
355 set(DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/apps CACHE FILEPATH "Install path for data files")
356 set(ICON_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/icons CACHE FILEPATH "Global icon install path")
357 set(XDG_APPS_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/applications CACHE FILEPATH "Install path for .desktop files")
362 message(STATUS "Embedding data files into the binary")
364 message(STATUS "Installing data files separately")
367 # RPATH needs to be set correctly
368 # Do this down here, since otherwise KDE wants to handle it itself, and fails
369 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH 1)
370 set(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
372 # Set global buildflags
373 # This is very much non-portable, so don't use -DSTATIC until you know what
375 if(STATIC AND CMAKE_COMPILER_IS_GNUCXX)
376 set(CMAKE_CXX_FLAGS "-static-libgcc ${CMAKE_CXX_FLAGS}")
377 link_directories(${CMAKE_BINARY_DIR}/staticlibs) # override dynamic libs
379 set(QUASSEL_SSL_LIBRARIES ssl crypto) # these miss in static builds
381 endif(STATIC AND CMAKE_COMPILER_IS_GNUCXX)
384 link_libraries(imm32 winmm dbghelp Secur32) # missing by default :/
386 set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBUGINFO "/debug /INCREMENTAL:YES /NODEFAULTLIB:libcmt /DEFAULTLIB:msvcrt")
387 set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBUGINFO}")
388 set(CMAKE_EXE_LINKER_FLAGS_DEBUGFULL "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBUGINFO}")
389 link_libraries(Version dwmapi shlwapi)
391 if(HAVE_SSL AND STATIC)
392 find_package(OpenSSL REQUIRED)
393 link_libraries(${OPENSSL_LIBRARIES} ${OPENSSL_EAY_LIBRARIES})
394 endif(HAVE_SSL AND STATIC)
398 add_definitions(-DXDG_APPS_INSTALL_DIR=${XDG_APPS_INSTALL_DIR})
399 endif(HAVE_INDICATEQT)
401 # We need to create a version.gen
402 # For this, we create our genversion binary and make sure it is run every time.
403 add_executable(genversion ${CMAKE_SOURCE_DIR}/src/common/genversion.cpp)
404 target_link_libraries(genversion ${QT_LIBRARIES} ${QT_CORE_LIB_DEPENDENCIES})
406 get_target_property(GENVERSION_EXECUTABLE genversion LOCATION)
407 add_custom_target(genversion_run ALL ${GENVERSION_EXECUTABLE}
408 ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/src/version.gen)
409 add_dependencies(genversion_run genversion)
411 # These variables will be added to the main targets (CORE, QTCLIENT, MONO)
412 set(COMMON_DEPS ${RC_WIN32})
416 # Add needed subdirs - the order is important, since src needs some vars set by other dirs
417 add_subdirectory(data)
418 add_subdirectory(icons)
419 add_subdirectory(pics)
421 add_subdirectory(src)