+###################################################################################################
+
+###################################################################################################
+# Adds a library target for a Quassel module.
+#
+# It 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
+#
+# 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)
+ # 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})
+
+ add_library(${target} STATIC "")
+ add_library(${alias} ALIAS ${target})