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.
This commit is contained in:
Robert Adam 2020-10-29 11:45:11 +01:00
parent f5489231a9
commit 7babebf0f9
2 changed files with 26 additions and 8 deletions

View File

@ -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 <https://www.mumble.info/LICENSE>.
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()

View File

@ -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)