From 7babebf0f9769bead8ffece92bb3117ea22d16ba Mon Sep 17 00:00:00 2001 From: Robert Adam Date: Thu, 29 Oct 2020 11:45:11 +0100 Subject: [PATCH] BUILD(cmake): Only install shared libraries Libraries should only be installed if they are built as shared libraries. Static libraries should only be needed during Mumble's compilation and are therefore no required dependencies that have to be installed alongside Mumble. --- cmake/install-library.cmake | 17 +++++++++++++++++ src/mumble/CMakeLists.txt | 17 +++++++++-------- 2 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 cmake/install-library.cmake diff --git a/cmake/install-library.cmake b/cmake/install-library.cmake new file mode 100644 index 000000000..8a57de7b8 --- /dev/null +++ b/cmake/install-library.cmake @@ -0,0 +1,17 @@ +# Copyright 2020 The Mumble Developers. All rights reserved. +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file at the root of the +# Mumble source tree or at . + +function(install_library lib component) + get_target_property(lib_type ${lib} TYPE) + + if(NOT lib_type STREQUAL "STATIC_LIBRARY") + # only install non-static libraries + if(WIN32) + install(TARGETS ${lib} RUNTIME DESTINATION "${MUMBLE_INSTALL_LIBDIR}" COMPONENT "${component}") + else() + install(TARGETS ${lib} LIBRARY DESTINATION "${MUMBLE_INSTALL_LIBDIR}" COMPONENT "${component}") + endif() + endif() +endfunction() diff --git a/src/mumble/CMakeLists.txt b/src/mumble/CMakeLists.txt index e0d32087a..7fc604127 100644 --- a/src/mumble/CMakeLists.txt +++ b/src/mumble/CMakeLists.txt @@ -15,6 +15,7 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mumble_dll.rc.in" "${MUMBLE_DLL_RC}" configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mumble.plist.in" "${MUMBLE_PLIST}") include(qt-utils) +include(install-library) option(update "Check for updates by default." ON) @@ -516,12 +517,12 @@ if(bundled-opus) if(WIN32) # Shared library on Windows (e.g. ".dll") set_target_properties(opus PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) - install(TARGETS opus RUNTIME DESTINATION "${MUMBLE_INSTALL_LIBDIR}" COMPONENT mumble_client) else() # Shared library on UNIX (e.g. ".so") set_target_properties(opus PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) - install(TARGETS opus LIBRARY DESTINATION "${MUMBLE_INSTALL_LIBDIR}") endif() + + install_library(opus mumble_client) else() find_pkg(opus REQUIRED) target_include_directories(mumble PRIVATE ${opus_INCLUDE_DIRS}) @@ -554,12 +555,12 @@ if(bundled-celt) if(WIN32) # Shared library on Windows (e.g. ".dll") set_target_properties(celt PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) - install(TARGETS celt RUNTIME DESTINATION "${MUMBLE_INSTALL_LIBDIR}" COMPONENT mumble_client) else() # Shared library on UNIX (e.g. ".so") set_target_properties(celt PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) - install(TARGETS celt LIBRARY DESTINATION "${MUMBLE_INSTALL_LIBDIR}") endif() + + install_library(celt mumble_client) else() find_pkg(celt REQUIRED) target_include_directories(mumble PRIVATE ${celt_INCLUDE_DIRS}) @@ -576,12 +577,12 @@ if(bundled-speex) if(WIN32) # Shared library on Windows (e.g. ".dll") set_target_properties(speex PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) - install(TARGETS speex RUNTIME DESTINATION "${MUMBLE_INSTALL_LIBDIR}" COMPONENT mumble_client) else() # Shared library on UNIX (e.g. ".so") set_target_properties(speex PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) - install(TARGETS speex LIBRARY DESTINATION "${MUMBLE_INSTALL_LIBDIR}" COMPONENT mumble_client) endif() + + install_library(speex mumble_client) else() find_pkg(speex REQUIRED) find_pkg(speexdsp REQUIRED) @@ -605,12 +606,12 @@ if(rnnoise) if(WIN32) # Shared library on Windows (e.g. ".dll") set_target_properties(rnnoise PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) - install(TARGETS rnnoise RUNTIME DESTINATION "${MUMBLE_INSTALL_LIBDIR}" COMPONENT mumble_client) else() # Shared library on UNIX (e.g. ".so") set_target_properties(rnnoise PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) - install(TARGETS rnnoise LIBRARY DESTINATION "${MUMBLE_INSTALL_LIBDIR}" COMPONENT mumble_client) endif() + + install_library(rnnoise mumble_client) endif() if(qtspeech)