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_KDE=ON : Enable KDE4 support
12 # -DEMBED_DATA=ON : Embed all data files in icons the binary, rather than installing them separately
14 # -DQT=/path/to/qt : Choose a Qt4 installation to use instead of the system Qt4
15 # -DSTATIC=ON : Enable static building of Quassel. Use with care.
16 # -DDEPLOY=ON : Mac OS X only. Use only for creating Quassel Packages!
18 # NOTE: You should remove CMakeCache.txt if you plan to change any of these values!
22 cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR)
24 if(COMMAND cmake_policy)
25 cmake_policy(SET CMP0003 NEW)
26 endif(COMMAND cmake_policy)
28 # Use our own (well, and KDE's) version of some modules
29 # In particular cmake's own FindQt4 and FindOpenSSL are quite buggy
30 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
31 include(QuasselMacros)
33 # Various options and variables that can be set on the command line
34 option(WANT_CORE "Build the core (server) binary" ON)
35 option(WANT_QTCLIENT "Build the Qt4 GUI client binary" ON)
36 option(WANT_MONO "Build the monolithic (all-in-one) binary" ON)
38 option(WITH_OPENSSL "Enable OpenSSL support if present on the system" ON)
39 option(WITH_DBUS "Enable D-Bus support if present on the system" ON)
40 option(WITH_WEBKIT "Enable WebKit support (for link previews)" ON)
41 option(WITH_PHONON "Enable Phonon support (for audio notifications)" ON)
42 option(WITH_KDE "Enable KDE4 integration" OFF)
44 # We use icon paths from KDE 4.3 trunk, which are partially invalid on older and possibly
45 # even on newer KDE versions. Do not disable this unless you are sure that your Quassel will
46 # run on a matching KDE version only.
47 option(WITH_OXYGEN "Install Oxygen icons. Heavily recommended unless you use KDE 4.3" ON)
49 option(STATIC "Enable static building (might not be portable)" OFF)
52 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)
55 # Default to embedding data in the static case
59 set(EMBED_DEFAULT ON) # should be OFF as soon as everything works
60 endif(STATIC OR WIN32)
62 option(EMBED_DATA "Embed all data files in the binary (rather than installing them separately)" ${EMBED_DEFAULT})
64 set(QT "" CACHE STRING "Path to a Qt installation to use instead of the system Qt (e.g. for static builds)")
65 set(LINGUAS "" CACHE STRING "Comma-separated list of locales specifying languages that should be compiled")
67 # Some settings imply others
69 add_definitions(-DSTATIC)
70 set(WITH_KDE OFF CACHE BOOL "Static building with KDE is not supported")
74 # We don't support separately installed resources yet on Win32
79 # We need to make sure it's not empty
80 # Supported: Release, RelWithDebugInfo, Debug, Debugfull
82 # On WIN32, only Release seems to work correctly (?)
84 set(DEFAULT_BUILD_TYPE "Release")
86 set(DEFAULT_BUILD_TYPE "RelWithDebugInfo")
89 set(CMAKE_BUILD_TYPE ${DEFAULT_BUILD_TYPE} CACHE STRING "CMake Build Type")
90 if(NOT CMAKE_BUILD_TYPE)
91 set(CMAKE_BUILD_TYPE ${DEFAULT_BUILD_TYPE} CACHE STRING "CMake Build Type" FORCE)
92 endif(NOT CMAKE_BUILD_TYPE)
94 # Enable various flags on gcc
95 if(CMAKE_COMPILER_IS_GNUCXX)
96 # Let's just hope that all gccs support these options and skip the tests...
97 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ansi -Wall -Wextra -Wnon-virtual-dtor")
98 set(CMAKE_CXX_FLAGS_RELWITHDEBUGINFO "-O2")
99 set(CMAKE_CXX_FLAGS_DEBUG "-g -fno-reorder-blocks -fno-schedule-insns -fno-inline")
100 set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3")
101 endif(CMAKE_COMPILER_IS_GNUCXX)
103 if(WANT_MONO OR WANT_QTCLIENT)
104 set(QT_MIN_VERSION "4.4.1") # Client crashes often with 4.4.0
105 else(WANT_MONO OR WANT_QTCLIENT)
106 set(QT_MIN_VERSION "4.4.0")
107 endif(WANT_MONO OR WANT_QTCLIENT)
110 set(CMAKE_OSX_ARCHITECTURES "i386;ppc")
111 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.4")
112 set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/")
113 add_definitions(-DMAC_10_4_SDK)
114 endif(APPLE AND DEPLOY)
116 # Execinfo is needed for generating backtraces
117 find_package(ExecInfo)
119 add_definitions(-DHAVE_EXECINFO)
120 include_directories(${EXECINFO_INCLUDES})
121 link_libraries(${EXECINFO_LIBRARIES})
122 endif(EXECINFO_FOUND)
124 # Select a Qt installation here, if you don't want to use system Qt
126 # FindQt4 will look for the qmake binary in $PATH, so we just prepend the Qt dir
127 set(ENV{PATH} ${QT}/bin:$ENV{PATH})
130 # Now that we have the correct $PATH, lets find Qt!
131 find_package(Qt4 REQUIRED)
133 set(QT_DONT_USE_QTGUI 1)
134 include(${QT_USE_FILE})
135 include_directories(${QT_INCLUDES})
139 find_package(OpenSSL)
141 message(STATUS "Disabling OpenSSL support")
145 if(NOT QT_DEFINITIONS MATCHES "QT_NO_OPENSSL")
146 message(STATUS "Found OpenSSL support in Qt")
147 add_definitions(-DHAVE_SSL)
149 set(MOC_DEFINES ${MOC_DEFINES} -DHAVE_SSL)
150 else(NOT QT_DEFINITIONS MATCHES "QT_NO_OPENSSL")
151 message(STATUS "No OpenSSL support found in Qt, disabling")
152 endif(NOT QT_DEFINITIONS MATCHES "QT_NO_OPENSSL")
154 add_definitions(-DQT_NO_OPENSSL)
157 # Setup D-Bus support
160 message(STATUS "Found QtDBus, enabling D-Bus support")
161 add_definitions(-DHAVE_DBUS)
164 set(MOC_DEFINES ${MOC_DEFINES} -DHAVE_DBUS)
165 else(QT_QTDBUS_FOUND)
166 message(STATUS "QtDBus not found, disabling D-Bus support")
167 endif(QT_QTDBUS_FOUND)
169 message(STATUS "Disabling D-Bus support")
172 # Setup QtWebKit support
174 if(QT_QTWEBKIT_FOUND)
175 message(STATUS "Found QtWebKit, enabling WebKit support")
176 add_definitions(-DHAVE_WEBKIT)
177 set(LINK_WEBKIT WEBKIT)
178 set(HAVE_WEBKIT true)
179 set(MOC_DEFINES ${MOC_DEFINES} -DHAVE_WEBKIT)
180 else(QT_QTWEBKIT_FOUND)
181 message(STATUS "QtWebKit not found, disabling WebKit support")
182 endif(QT_QTWEBKIT_FOUND)
184 message(STATUS "Disabling WebKit support")
191 message(STATUS "Enabling KDE4 integration")
192 include_directories(${KDE4_INCLUDES})
193 add_definitions(-DHAVE_KDE ${KDE4_DEFINITIONS})
195 set(MOC_DEFINES ${MOC_DEFINES} -DHAVE_KDE)
196 set(QUASSEL_KDE_LIBRARIES ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBRARY} knotifyconfig)
197 # We always use external icons for KDE4 support, since we use its iconloader rather than our own
200 message(STATUS "KDE4 not found, disabling KDE integration")
203 message(STATUS "Disabling KDE4 integration")
206 # Setup Phonon support - we only need this if we don't have or want KDE4
211 message(STATUS "Enabling Phonon support")
212 add_definitions(-DHAVE_PHONON)
213 set(HAVE_PHONON true)
214 set(MOC_DEFINES ${MOC_DEFINES} -DHAVE_PHONON)
216 message(STATUS "Phonon not found, disabling audio notifications")
219 message(STATUS "Disabling Phonon support")
223 # Now set up install locations; those are set by KDE if integration is enabled
226 set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX} CACHE FILEPATH "Install path for binaries")
227 set(DATA_INSTALL_DIR $ENV{APPDATA}/quassel-irc.org/share/apps CACHE FILEPATH "Install path for data files")
228 set(ICON_INSTALL_DIR $ENV{APPDATA}/quassel-irc.org/share/icons CACHE FILEPATH "Global icon install path")
229 set(XDG_APPS_INSTALL_DIR $ENV{APPDATA}/quassel-irc.org/share/applications CACHE FILEPATH "Install path for .desktop files")
231 set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin CACHE FILEPATH "Install path for binaries")
232 set(DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/apps CACHE FILEPATH "Install path for data files")
233 set(ICON_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/icons CACHE FILEPATH "Global icon install path")
234 set(XDG_APPS_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/applications CACHE FILEPATH "Install path for .desktop files")
238 # RPATH needs to be set correctly
239 # Do this down here, since otherwise KDE wants to handle it itself, and fails
240 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH 1)
241 set(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
243 # Set global buildflags
244 # This is very much non-portable, so don't use -DSTATIC until you know what
246 if(STATIC AND CMAKE_COMPILER_IS_GNUCXX)
247 set(CMAKE_CXX_FLAGS "-static-libgcc ${CMAKE_CXX_FLAGS}")
248 link_directories(${CMAKE_BINARY_DIR}/staticlibs) # override dynamic libs
250 set(QUASSEL_SSL_LIBRARIES ssl crypto) # these miss in static builds
252 endif(STATIC AND CMAKE_COMPILER_IS_GNUCXX)
255 link_libraries(imm32 winmm dbghelp Secur32) # missing by default :/
258 link_libraries(${OPENSSL_LIBRARIES} libeay32MD)
261 set(RC_WIN32 ../pics/win32.rc) # for app icons on windows
264 # We need to create a version.gen
265 # For this, we create our genversion binary and make sure it is run every time.
266 add_executable(genversion ${CMAKE_SOURCE_DIR}/src/common/genversion.cpp)
267 target_link_libraries(genversion ${QT_LIBRARIES} ${QT_CORE_LIB_DEPENDENCIES})
269 get_target_property(GENVERSION_EXECUTABLE genversion LOCATION)
270 add_custom_target(genversion_run ALL ${GENVERSION_EXECUTABLE}
271 ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/src/version.gen)
272 add_dependencies(genversion_run genversion)
274 # These variables will be added to the main targets (CORE, QTCLIENT, MONO)
275 set(COMMON_DEPS ${RC_WIN32})
279 # Add needed subdirs - the order is important, since src needs some vars set by other dirs
280 add_subdirectory(data)
281 add_subdirectory(icons)
282 add_subdirectory(pics)
283 add_subdirectory(i18n)
284 add_subdirectory(src)