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)