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")
59 # RPATH needs to be set correctly
60 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH 1)
61 set(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
63 # Define install locations. Using variables will allow overriding this by the KDE macros later.
64 set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin)
65 set(DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/apps)
66 set(ICON_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/icons)
67 set(XDG_APPS_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/applications)
69 # Enable various flags on gcc
70 if(CMAKE_COMPILER_IS_GNUCXX)
71 # Let's just hope that all gccs support these options and skip the tests...
72 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ansi -Wall -Wextra -Wnon-virtual-dtor")
73 endif(CMAKE_COMPILER_IS_GNUCXX)
75 set(QT_MIN_VERSION "4.4.0")
78 set(CMAKE_OSX_ARCHITECTURES "i386;ppc")
79 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.4")
80 set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/")
81 add_definitions(-DMAC_10_4_SDK)
82 endif(APPLE AND DEPLOY)
84 include(QuasselMacros)
86 # Execinfo is needed for generating backtraces
87 find_package(ExecInfo)
89 add_definitions(-DHAVE_EXECINFO)
90 include_directories(${EXECINFO_INCLUDES})
91 link_libraries(${EXECINFO_LIBRARIES})
94 # Select a Qt installation here, if you don't want to use system Qt
96 # FindQt4 will look for the qmake binary in $PATH, so we just prepend the Qt dir
97 set(ENV{PATH} ${QT}/bin:$ENV{PATH})
100 # Now that we have the correct $PATH, lets find Qt!
101 find_package(Qt4 REQUIRED)
103 set(QT_DONT_USE_QTGUI 1)
104 include(${QT_USE_FILE})
105 include_directories(${QT_INCLUDES})
109 find_package(OpenSSL)
111 message(STATUS "Disabling OpenSSL support")
115 if(NOT QT_DEFINITIONS MATCHES "QT_NO_OPENSSL")
116 message(STATUS "Found OpenSSL support in Qt")
117 add_definitions(-DHAVE_SSL)
119 set(MOC_DEFINES ${MOC_DEFINES} -DHAVE_SSL)
120 else(NOT QT_DEFINITIONS MATCHES "QT_NO_OPENSSL")
121 message(STATUS "No OpenSSL support found in Qt, disabling")
122 endif(NOT QT_DEFINITIONS MATCHES "QT_NO_OPENSSL")
124 add_definitions(-DQT_NO_OPENSSL)
127 # Setup D-Bus support
130 message(STATUS "Found QtDBus, enabling D-Bus support")
131 add_definitions(-DHAVE_DBUS)
134 set(MOC_DEFINES ${MOC_DEFINES} -DHAVE_DBUS)
135 else(QT_QTDBUS_FOUND)
136 message(STATUS "QtDBus not found, disabling D-Bus support")
137 endif(QT_QTDBUS_FOUND)
139 message(STATUS "Disabling D-Bus support")
142 # Setup QtWebKit support
144 if(QT_QTWEBKIT_FOUND)
145 message(STATUS "Found QtWebKit, enabling WebKit support")
146 add_definitions(-DHAVE_WEBKIT)
147 set(LINK_WEBKIT WEBKIT)
148 set(HAVE_WEBKIT true)
149 set(MOC_DEFINES ${MOC_DEFINES} -DHAVE_WEBKIT)
150 else(QT_QTWEBKIT_FOUND)
151 message(STATUS "QtWebKit not found, disabling D-Bus support")
152 endif(QT_QTWEBKIT_FOUND)
154 message(STATUS "Disabling WebKit support")
157 # Setup Phonon support
161 message(STATUS "Enabling Phonon support")
162 add_definitions(-DHAVE_PHONON)
163 set(HAVE_PHONON true)
164 set(MOC_DEFINES ${MOC_DEFINES} -DHAVE_PHONON)
166 message(STATUS "Phonon not found, disabling audio notifications")
169 message(STATUS "Disabling Phonon support")
176 message(STATUS "Enabling KDE4 integration")
177 include_directories(${KDE4_INCLUDES})
178 add_definitions(-DHAVE_KDE ${KDE4_DEFINITIONS})
180 set(MOC_DEFINES ${MOC_DEFINES} -DHAVE_KDE)
181 set(QUASSEL_KDE_LIBRARIES ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBRARY})
183 message(STATUS "KDE4 not found, disabling KDE integration")
186 message(STATUS "Disabling KDE4 integration")
189 # Set global buildflags
190 # This is very much non-portable, so don't use -DSTATIC until you know what
192 if(STATIC AND CMAKE_COMPILER_IS_GNUCXX)
193 set(CMAKE_CXX_FLAGS "-static-libgcc ${CMAKE_CXX_FLAGS}")
194 link_directories(${CMAKE_BINARY_DIR}/staticlibs) # override dynamic libs
196 set(QUASSEL_SSL_LIBRARIES ssl crypto) # these miss in static builds
198 endif(STATIC AND CMAKE_COMPILER_IS_GNUCXX)
202 link_libraries(imm32 winmm dbghelp) # missing by default :/
205 link_libraries(${OPENSSL_LIBRARIES} libeay32MD)
210 set(RC_WIN32 ../pics/win32.rc) # for app icons on windows
213 # This is dirty, but I haven't found a cleaner way to ensure that the generated .qrc files
214 # (which will be removed with make clean) are regenerated :/
215 set_directory_properties(PROPERTIES
216 ADDITIONAL_MAKE_CLEAN_FILES CMakeCache.txt)
218 # We need to create a version.gen
219 # For this, we create our genversion binary and make sure it is run every time.
220 add_executable(genversion ${CMAKE_SOURCE_DIR}/src/common/genversion.cpp)
221 target_link_libraries(genversion ${QT_LIBRARIES} ${QT_CORE_LIB_DEPENDENCIES})
223 get_target_property(GENVERSION_EXECUTABLE genversion LOCATION)
224 add_custom_target(genversion_run ALL ${GENVERSION_EXECUTABLE}
225 ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/src/version.gen)
226 add_dependencies(genversion_run genversion)
228 # Decide what to do with icons
229 if(WANT_QTCLIENT OR WANT_MONO)
230 if(QUASSEL_ICONS MATCHES "External")
231 message(STATUS "Install Quassel icons to ${CMAKE_INSTALL_PREFIX}/share/apps/quassel")
232 else(QUASSEL_ICONS MATCHES "External")
233 set(QUASSEL_ICONS "Builtin")
234 message(STATUS "Compile Quassel icons into the binary")
235 endif(QUASSEL_ICONS MATCHES "External")
237 if(OXYGEN_ICONS MATCHES "External")
238 message(STATUS "Use system-installed Oxygen icon theme")
239 else(OXYGEN_ICONS MATCHES "External")
240 set(OXYGEN_ICONS "Builtin")
241 message(STATUS "Compile Oxygen icon theme subset into the binary")
242 endif(OXYGEN_ICONS MATCHES "External")
243 endif(WANT_QTCLIENT OR WANT_MONO)
245 # These variables will be added to the main targets (CORE, QTCLIENT, MONO)
247 set(COMMON_DEPS ${RC_WIN32})
252 # Add needed subdirs - the order is important, since src needs some vars set by other dirs
253 add_subdirectory(data)
254 add_subdirectory(icons)
255 #add_subdirectory(pics)
256 add_subdirectory(i18n)
257 add_subdirectory(src)