From d83fe8c7400978a7abc911b3c55ff51516b83211 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Wed, 29 Aug 2018 18:10:56 +0200 Subject: [PATCH] cmake: Add support for static libs to quassel_add_module We'll need this for building resource libraries, which we can't easily export symbols from (and which also are not used more than once). --- cmake/QuasselMacros.cmake | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/cmake/QuasselMacros.cmake b/cmake/QuasselMacros.cmake index e2825061..3851d1bc 100644 --- a/cmake/QuasselMacros.cmake +++ b/cmake/QuasselMacros.cmake @@ -12,17 +12,30 @@ include(QuasselCompileFeatures) ################################################################################################### # Adds a library target for a Quassel module. # -# It expects the (CamelCased) module name as a parameter, and derives various +# quassel_add_module(Module +# [STATIC] +# ) +# +# 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. +# # 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 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}) @@ -32,7 +45,7 @@ function(quassel_add_module _module) # On Windows, building shared libraries requires export headers. # Let's bother with that later. - if (WIN32) + if (ARG_STATIC OR WIN32) set(buildmode STATIC) else() set(buildmode SHARED) -- 2.20.1