mumble/plugins/CMakeLists.txt
Robert Adam 27dbee8e62 FEAT(client): Plugin framework
This commit introduces a new plugin framework into the codebase of the
Mumble client. Note that "plugin" here really refers to a (more or less)
general purpose plugin and is therefore not to be confused with the
previously available positional data plugins (only responsible for
fetching positional data from a running game and passing that to
Mumble).

The plugin interface is written in C, removing the compiler-dependence
the old "plugins" had. Instead plugins can now be written in an
arbitrary language as long as that language is capable of being compiled
into a shared library and also being capable of being C-compatible.

As already indicated a plugin is essentially a shared library that
provides certain functions that allow Mumble to interface with it.

Inside Mumble the so-called PluginManager is responsible for managing
the plugins and relaying events to the respective callbacks. Plugins
themselves can also interact with Mumble on their own initiative by
using the provided API functions.

Fixes #2455
Fixes #2148
Fixes #1594
Fixes #2051
Fixes #3742
Fixes #4575
Fixes #4751
2021-04-16 20:15:44 +02:00

68 lines
2.3 KiB
CMake

# Copyright 2020-2021 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>.
option(retracted-plugins "Build redacted (outdated) plugins as well" OFF)
if(retracted-plugins)
message(STATUS "Including retracted plugins")
endif()
set(CMAKE_INCLUDE_CURRENT_DIR ON)
if(NOT WIN32 AND NOT (${CMAKE_SYSTEM_NAME} STREQUAL "Linux"))
add_subdirectory(link)
# Shared library on UNIX (e.g. ".so")
set_target_properties(link PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins")
return()
endif()
file(GLOB ITEMS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/*")
foreach(ITEM ${ITEMS})
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${ITEM}")
set(PLUGIN_RETRACTED OFF)
# If the plugin is retracted the corresponding CMakeLists.txt is supposed to set the
# PLUGIN_RETRACTED variable in the parent scope so that we can access it here
add_subdirectory(${ITEM})
if(${ITEM} STREQUAL "testPlugin" AND NOT ${CMAKE_BUILD_TYPE} MATCHES Debug)
# The testPlugin is only included in Debug builds
continue()
endif()
if(PLUGIN_RETRACTED AND NOT retracted-plugins)
# The included subdir didn't actually add a target since the associated plugin is retracted
# and therefore it should not be built.
continue()
endif()
target_include_directories(${ITEM} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
if(WIN32)
target_compile_definitions(${ITEM} PRIVATE "OS_WINDOWS")
target_link_libraries(${ITEM} user32.lib)
# Shared library on Windows (e.g. ".dll")
set_target_properties(${ITEM} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins")
install(TARGETS ${ITEM} RUNTIME DESTINATION "${MUMBLE_INSTALL_PLUGINDIR}" COMPONENT mumble_client)
else()
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
target_compile_definitions(${ITEM} PRIVATE "OS_LINUX")
endif()
# Shared library on UNIX (e.g. ".so")
set_target_properties(${ITEM} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins")
install(TARGETS ${ITEM} LIBRARY DESTINATION "${MUMBLE_INSTALL_PLUGINDIR}" COMPONENT mumble_client)
endif()
if(packaging)
add_dependencies(mumble ${ITEM})
endif()
endif()
endforeach()