1 # This is the cmake-based build system for Quassel IRC.
2 # You may pass various options to cmake:
3 # -DWANT_(CORE|QTCLIENT|MONO)=(ON|OFF)
4 # : select binaries to build
5 # -DWITH_OPENSSL=OFF : Disable OpenSSL support
6 # -DWITH_DBUS=OFF : Disable D-Bus support (dbus notifications)
7 # -DWITH_WEBKIT=OFF : Disable WebKit support (link previews)
8 # -DWITH_PHONON=OFF : Disable Phonon support (audio notifications)
9 # -DWITH_KDE=ON : Enable KDE4 support
10 # -DOXYGEN_ICONS=(Builtin|External) : If "Builtin" (the default), compile our Oxygen Icon Theme subset into the binary
11 # : If "External", we assume Oxygen is already installed on the system
12 # -DQUASSEL_ICONS=(Builtin|External) : If "Builtin" (the default), put our own icons into the binary
13 # : If "External", we install our icons into $PREFIX/share/apps/quassel (UNIX only)
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 need to 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 FindQt4 and FindOpenSSL are quite buggy
30 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
32 # Various options and variables that can be set on the command line
33 option(WANT_CORE "Build the core (server) binary" ON)
34 option(WANT_QTCLIENT "Build the Qt4 GUI client binary" ON)
35 option(WANT_MONO "Build the monolithic (all-in-one) binary" ON)
37 option(WITH_OPENSSL "Enable OpenSSL support if present on the system" ON)
38 option(WITH_DBUS "Enable D-Bus support if present on the system" ON)
39 option(WITH_WEBKIT "Enable WebKit support (for link previews)" ON)
40 option(WITH_PHONON "Enable Phonon support (for audio notifications)" ON)
41 option(WITH_KDE "Enable KDE4 integration" OFF)
43 option(STATIC "Enable static building (might not be portable)" OFF)
44 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)
45 option(SPUTDEV "Do not use!" OFF)
47 set(OXYGEN_ICONS "Builtin" CACHE STRING "Builtin: Compile Oxygen icons into the binary; External: Use system-installed Oxygen")
48 set(QUASSEL_ICONS "Builtin" CACHE STRING "Builtin: Compile Quassel icons into the binary; External: Install them separately")
50 set(QT "" CACHE STRING "Path to a Qt installation to use instead of the system Qt")
51 set(LINGUAS "" CACHE STRING "Space-separated List of locales specifying languages that should be compiled")
54 set(CMAKE_BUILD_TYPE Release)
55 set(OXYGEN_ICONS "Builtin")
56 set(QUASSEL_ICONS "Builtin")
60 # Define install locations. Using variables will allow overriding this by the KDE macros later.
61 set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin)
62 set(DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/apps)
63 set(ICON_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/icons)
64 set(XDG_APPS_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/applications)
66 # Enable various flags on gcc
67 if(CMAKE_COMPILER_IS_GNUCXX)
68 # Let's just hope that all gccs support these options and skip the tests...
69 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ansi -Wall -Wextra -Wnon-virtual-dtor")
70 endif(CMAKE_COMPILER_IS_GNUCXX)
72 set(QT_MIN_VERSION "4.4.0")
75 set(CMAKE_OSX_ARCHITECTURES "i386;ppc")
76 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.4")
77 set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/")
78 add_definitions(-DMAC_10_4_SDK)
79 endif(APPLE AND DEPLOY)
81 include(QuasselMacros)
83 # Execinfo is needed for generating backtraces
84 find_package(ExecInfo)
86 add_definitions(-DHAVE_EXECINFO)
87 include_directories(${EXECINFO_INCLUDES})
88 link_libraries(${EXECINFO_LIBRARIES})
91 # Select a Qt installation here, if you don't want to use system Qt
93 # FindQt4 will look for the qmake binary in $PATH, so we just prepend the Qt dir
94 set(ENV{PATH} ${QT}/bin:$ENV{PATH})
97 # Now that we have the correct $PATH, lets find Qt!
98 find_package(Qt4 REQUIRED)
100 set(QT_DONT_USE_QTGUI 1)
101 include(${QT_USE_FILE})
102 include_directories(${QT_INCLUDES})
106 find_package(OpenSSL)
108 message(STATUS "Disabling OpenSSL support")
112 if(NOT QT_DEFINITIONS MATCHES "QT_NO_OPENSSL")
113 message(STATUS "Found OpenSSL support in Qt")
114 add_definitions(-DHAVE_SSL)
116 set(MOC_DEFINES ${MOC_DEFINES} -DHAVE_SSL)
117 else(NOT QT_DEFINITIONS MATCHES "QT_NO_OPENSSL")
118 message(STATUS "No OpenSSL support found in Qt, disabling")
119 endif(NOT QT_DEFINITIONS MATCHES "QT_NO_OPENSSL")
121 add_definitions(-DQT_NO_OPENSSL)
124 # Setup D-Bus support
127 message(STATUS "Found QtDBus, enabling D-Bus support")
128 add_definitions(-DHAVE_DBUS)
131 set(MOC_DEFINES ${MOC_DEFINES} -DHAVE_DBUS)
132 else(QT_QTDBUS_FOUND)
133 message(STATUS "QtDBus not found, disabling D-Bus support")
134 endif(QT_QTDBUS_FOUND)
136 message(STATUS "Disabling D-Bus support")
139 # Setup QtWebKit support
141 if(QT_QTWEBKIT_FOUND)
142 message(STATUS "Found QtWebKit, enabling WebKit support")
143 add_definitions(-DHAVE_WEBKIT)
144 set(LINK_WEBKIT WEBKIT)
145 set(HAVE_WEBKIT true)
146 set(MOC_DEFINES ${MOC_DEFINES} -DHAVE_WEBKIT)
147 else(QT_QTWEBKIT_FOUND)
148 message(STATUS "QtWebKit not found, disabling WebKit support")
149 endif(QT_QTWEBKIT_FOUND)
151 message(STATUS "Disabling WebKit support")
158 message(STATUS "Enabling KDE4 integration")
159 include_directories(${KDE4_INCLUDES})
160 add_definitions(-DHAVE_KDE ${KDE4_DEFINITIONS})
162 set(MOC_DEFINES ${MOC_DEFINES} -DHAVE_KDE)
163 set(QUASSEL_KDE_LIBRARIES ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBRARY} knotifyconfig)
164 # We always use external icons for KDE4 support, since we use its iconloader rather than our own
165 set(OXYGEN_ICONS "External")
166 set(QUASSEL_ICONS "External")
168 message(STATUS "KDE4 not found, disabling KDE integration")
171 message(STATUS "Disabling KDE4 integration")
174 # Setup Phonon support - we only need this if we don't have or want KDE4
179 message(STATUS "Enabling Phonon support")
180 add_definitions(-DHAVE_PHONON)
181 set(HAVE_PHONON true)
182 set(MOC_DEFINES ${MOC_DEFINES} -DHAVE_PHONON)
184 message(STATUS "Phonon not found, disabling audio notifications")
187 message(STATUS "Disabling Phonon support")
191 # RPATH needs to be set correctly
192 # Do this down here, since otherwise KDE wants to handle it itself, and fails
193 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH 1)
194 set(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
196 # Set global buildflags
197 # This is very much non-portable, so don't use -DSTATIC until you know what
199 if(STATIC AND CMAKE_COMPILER_IS_GNUCXX)
200 set(CMAKE_CXX_FLAGS "-static-libgcc ${CMAKE_CXX_FLAGS}")
201 link_directories(${CMAKE_BINARY_DIR}/staticlibs) # override dynamic libs
203 set(QUASSEL_SSL_LIBRARIES ssl crypto) # these miss in static builds
205 endif(STATIC AND CMAKE_COMPILER_IS_GNUCXX)
209 link_libraries(imm32 winmm dbghelp) # missing by default :/
212 link_libraries(${OPENSSL_LIBRARIES} libeay32MD)
217 set(RC_WIN32 ../pics/win32.rc) # for app icons on windows
220 # This is dirty, but I haven't found a cleaner way to ensure that the generated .qrc files
221 # (which will be removed with make clean) are regenerated :/
222 set_directory_properties(PROPERTIES
223 ADDITIONAL_MAKE_CLEAN_FILES CMakeCache.txt)
225 # We need to create a version.gen
226 # For this, we create our genversion binary and make sure it is run every time.
227 add_executable(genversion ${CMAKE_SOURCE_DIR}/src/common/genversion.cpp)
228 target_link_libraries(genversion ${QT_LIBRARIES} ${QT_CORE_LIB_DEPENDENCIES})
230 get_target_property(GENVERSION_EXECUTABLE genversion LOCATION)
231 add_custom_target(genversion_run ALL ${GENVERSION_EXECUTABLE}
232 ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/src/version.gen)
233 add_dependencies(genversion_run genversion)
235 # Decide what to do with icons
236 if(WANT_QTCLIENT OR WANT_MONO)
237 if(QUASSEL_ICONS MATCHES "External")
238 message(STATUS "Install Quassel icons to ${CMAKE_INSTALL_PREFIX}/share/apps/quassel")
239 else(QUASSEL_ICONS MATCHES "External")
240 set(QUASSEL_ICONS "Builtin")
241 message(STATUS "Compile Quassel icons into the binary")
242 endif(QUASSEL_ICONS MATCHES "External")
244 if(OXYGEN_ICONS MATCHES "External")
245 message(STATUS "Use system-installed icon theme")
246 else(OXYGEN_ICONS MATCHES "External")
247 set(OXYGEN_ICONS "Builtin")
248 message(STATUS "Compile Oxygen icon theme subset into the binary")
249 endif(OXYGEN_ICONS MATCHES "External")
250 endif(WANT_QTCLIENT OR WANT_MONO)
252 # These variables will be added to the main targets (CORE, QTCLIENT, MONO)
254 set(COMMON_DEPS ${RC_WIN32})
259 # Add needed subdirs - the order is important, since src needs some vars set by other dirs
260 add_subdirectory(data)
261 add_subdirectory(icons)
262 #add_subdirectory(pics)
263 add_subdirectory(i18n)
264 add_subdirectory(src)