-############################
-# Macros for dealing with Qt
-############################
-
-# CMake gained this function in 2.8.10. To be able to use older versions, we've copied
-# this here. If present, the function from CMake will take precedence and our copy will be ignored.
-function(quassel_qt4_use_modules _target _link_type)
- message("SPUT calling")
- if ("${_link_type}" STREQUAL "LINK_PUBLIC" OR "${_link_type}" STREQUAL "LINK_PRIVATE")
- set(modules ${ARGN})
- set(link_type ${_link_type})
+###################################################################################################
+# Adds a library target for a Quassel module.
+#
+# quassel_add_module(Module [STATIC] [EXPORT])
+#
+# The function expects the (CamelCased) module name as a parameter, and derives various
+# strings from it. For example, quassel_add_module(Client) produces
+# - a library target named quassel_client with output name (lib)quassel-client(.so)
+# - an alias target named Quassel::Client in global scope
+#
+# If the optional argument STATIC is given, a static library is built; otherwise, on
+# platforms other than Windows, a shared library is created. For shared libraries, also
+# an install rule is added.
+#
+# To generate an export header for the library, specify EXPORT. The header will be named
+# ${module}-export.h (where ${module} is the lower-case name of the module).
+#
+# The function exports the TARGET variable which can be used in the current scope
+# for setting source files, properties, link dependencies and so on.
+# To refer to the target outside of the current scope, e.g. for linking, use
+# the alias name.
+#
+function(quassel_add_module _module)
+ set(options EXPORT STATIC)
+ set(oneValueArgs )
+ set(multiValueArgs )
+ cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ # Derive target, alias target, output name from the given module name
+ set(alias "Quassel::${_module}")
+ set(target ${alias})
+ string(TOLOWER ${target} target)
+ string(REPLACE "::" "_" target ${target})
+ string(REPLACE "_" "-" output_name ${target})
+
+ if (ARG_STATIC)
+ set(buildmode STATIC)