X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=cmake%2FQuasselMacros.cmake;h=f6d4ea69bb3f25e234454b2b473ec4606fb05639;hb=efe4239f96f0cf10b1c94e87f8fdd21f3bdbe10e;hp=62ad20c7c729b6604e38987fcde969f974d7f067;hpb=8f2ee00f4edef1693628d3af0bdee84d725eb754;p=quassel.git diff --git a/cmake/QuasselMacros.cmake b/cmake/QuasselMacros.cmake index 62ad20c7..f6d4ea69 100644 --- a/cmake/QuasselMacros.cmake +++ b/cmake/QuasselMacros.cmake @@ -1,6 +1,6 @@ # This file contains various functions and macros useful for building Quassel. # -# (C) 2014-2018 by the Quassel Project +# (C) 2014-2020 by the Quassel Project # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. @@ -20,9 +20,9 @@ include(QuasselCompileFeatures) # - 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). @@ -45,7 +45,7 @@ function(quassel_add_module _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) @@ -143,7 +143,7 @@ function(quassel_add_resource _name) # # 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) @@ -200,6 +200,7 @@ function(quassel_add_test _target) list(APPEND ARG_LIBRARIES Qt5::Test Quassel::Common + Quassel::Test::Global Quassel::Test::Main ) @@ -261,3 +262,19 @@ function(target_link_if_exists _target) endforeach() endif() endfunction() + +################################################################################################### +# process_cmake_cxx_flags() +# +# Append the options declared CMAKE_CXX_FLAGS and CMAKE_CXX_FLAGS_ 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()