# This file contains various functions and macros useful for building Quassel.
#
-# (C) 2014-2018 by the Quassel Project <devel@quassel-irc.org>
+# (C) 2014-2019 by the Quassel Project <devel@quassel-irc.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
# - 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.
+# If the optional argument STATIC is given, or the ENABLE_SHARED option is OFF,
+# a static library is built; otherwise a shared library is created. For shared
+# libraries, an install rule is also 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).
string(REPLACE "::" "_" target ${target})
string(REPLACE "_" "-" output_name ${target})
- if (ARG_STATIC)
+ if (ARG_STATIC OR NOT ENABLE_SHARED)
set(buildmode STATIC)
else()
set(buildmode SHARED)
#
# On Windows, input redirection apparently doesn't work, however piping does. Use this for all platforms for
# consistency, accommodating for the fact that the 'cat' equivalent on Windows is 'type'.
- if (WIN32)
+ if (WIN32 AND NOT MSYS)
set(cat_cmd type)
else()
set(cat_cmd cat)
endforeach()
endif()
endfunction()
+
+###################################################################################################
+# process_cmake_cxx_flags()
+#
+# Append the options declared CMAKE_CXX_FLAGS and CMAKE_CXX_FLAGS_<BUILD_TYPE> to the global
+# compile options.
+# Unset the variables afterwards to avoid duplication.
+#
+function(process_cmake_cxx_flags)
+ string(TOUPPER ${CMAKE_BUILD_TYPE} upper_build_type)
+ set(cxx_flags "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${upper_build_type}}")
+ separate_arguments(sep_cxx_flags UNIX_COMMAND ${cxx_flags})
+ add_compile_options(${sep_cxx_flags})
+ set(CMAKE_CXX_FLAGS "" PARENT_SCOPE)
+ set(CMAKE_CXX_FLAGS_${upper_build_type} "" PARENT_SCOPE)
+endfunction()