+cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR)
+
+if(COMMAND cmake_policy)
+ cmake_policy(SET CMP0003 NEW)
+endif(COMMAND cmake_policy)
+
+# Use our own (well, and KDE's) version of some modules
+# In particular cmake's FindQt4 and FindOpenSSL are quite buggy
+set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
+
+# Various options and variables that can be set on the command line
+option(WANT_CORE "Build the core (server) binary" ON)
+option(WANT_QTCLIENT "Build the Qt4 GUI client binary" ON)
+option(WANT_MONO "Build the monolithic (all-in-one) binary" OFF)
+
+option(WITH_OPENSSL "Enable OpenSSL support if present on the system" ON)
+option(WITH_DBUS "Enable D-Bus support if present on the system" ON)
+option(WITH_WEBKIT "Enable WebKit support if present on the system" ON)
+
+option(STATIC "Enable static building (might not be portable)" OFF)
+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)
+option(SPUTDEV "Do not use!" OFF)
+
+set(OXYGEN_ICONS "Builtin" CACHE STRING "Builtin: Compile Oxygen icons into the binary; External: Use system-installed Oxygen")
+set(QUASSEL_ICONS "Builtin" CACHE STRING "Builtin: Compile Quassel icons into the binary; External: Install them separately")
+
+set(QT "" CACHE STRING "Path to a Qt installation to use instead of the system Qt")
+set(LINGUAS "" CACHE STRING "Space-separated List of locales specifying languages that should be compiled")
+
+if(STATIC)
+ set(CMAKE_BUILD_TYPE Release)
+ set(OXYGEN_ICONS "Builtin")
+ set(QUASSEL_ICONS "Builtin")
+endif(STATIC)
+
+# RPATH needs to be set correctly
+set(CMAKE_INSTALL_RPATH_USE_LINK_PATH 1)
+set(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
+
+# Define install locations. Using variables will allow overriding this by the KDE macros later.
+set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin)
+set(DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/apps)
+set(ICON_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/icons)
+set(XDG_APPS_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/applications)
+
+# Enable various flags on gcc
+if(CMAKE_COMPILER_IS_GNUCXX)
+ # Let's just hope that all gccs support these options and skip the tests...
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ansi -Wall -Wextra -Wnon-virtual-dtor")
+endif(CMAKE_COMPILER_IS_GNUCXX)