+# Additional compile settings
+#####################################################################
+
+# Needed to compile with mingw without kde
+if (MINGW AND NOT WITH_KDE)
+ 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()
+
+# Setup support for KDE Frameworks
+#####################################################################
+
+# We want to do this up here, so we have the necessary variables and defines set before
+# compiling anything
+
+if (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)
+
+ kde_enable_exceptions()
+ 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)
+
+# RPATH and output settings
+#####################################################################
+
+# Build artifacts in a well-known location; especially important for Windows DLLs
+# (which go into RUNTIME_OUTPUT_DIRECTORY and can thus be found by executables)
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
+
+# These RPATH settings allow for running directly from the build dir
+set(CMAKE_SKIP_BUILD_RPATH FALSE)
+set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
+set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
+
+# Set install RPATH only if libdir isn't a system directory
+if (IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
+ set(libdir "${CMAKE_INSTALL_LIBDIR}")
+else()
+ set(libdir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
+endif()
+list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${libdir}" is_systemdir)
+if ("${is_systemdir}" STREQUAL "-1")
+ set(CMAKE_INSTALL_RPATH "${libdir}")
+endif()
+
+# Various config-dependent checks and settings
+#####################################################################
+