+# Additional compile settings
+#####################################################################
+
+# This sets -fPIC and friends if required by the installed Qt5 library
+if (USE_QT5 AND Qt5_POSITION_INDEPENDENT_CODE)
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+endif()
+
+# Needed to compile with mingw without kde
+if (MINGW AND NOT KDE4_FOUND)
+ add_definitions(-D_WIN32_WINNT=0x0500)
+ message(STATUS "Added _WIN32_WINNT=0x0500 definition for MinGW")
+ # workaround for bug in mingw gcc 4.0
+ add_definitions(-U__STRICT_ANSI__)
+endif()
+
+# Sanitize compiler flags - old versions of KDE set -ansi, which breaks -std=c++11
+if (CMAKE_COMPILER_IS_GNUCXX)
+ string(REPLACE "-ansi" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
+endif()
+
+
+# Setup KDE / KDE Frameworks
+#####################################################################
+
+# We want to do this up here, so we have the necessary variables and defines set before
+# compiling anything
+
+if (KDE4_FOUND)
+ # We always use external icons for KDE4 support, since we use its iconloader rather than Qt's
+ set(EMBED_DATA OFF)
+
+ # Better have the compile flags global, even for the core, to avoid problems with linking the mono client
+ add_definitions(-DHAVE_KDE -DHAVE_KDE4 ${KDE4_DEFINITIONS})
+ set(WITH_KDE4 TRUE)
+endif()
+
+if (USE_QT5 AND WITH_KDE)
+ # If KDE Frameworks are present, they're most probably providing Qt5 integration including icon loading
+ set(EMBED_DATA OFF)
+
+ include(KDEInstallDirs)
+ include(KDECompilerSettings)
+ include(KDECMakeSettings)
+
+ add_definitions(-DHAVE_KDE -DHAVE_KF5)
+ set(WITH_KF5 TRUE)
+endif()
+
+# This needs to come after setting up KDE integration, so we can use KDE-specific paths
+include(QuasselInstallDirs)
+
+# Various config-dependent checks and settings
+#####################################################################
+
+if (NOT ZLIB_FOUND)
+ message(STATUS "zlib NOT found, using bundled miniz for compression")
+ if (${CMAKE_SIZEOF_VOID_P} EQUAL 4)
+ message(STATUS "WARNING: This may be slow on 32 bit systems!")
+ endif()
+endif()
+