From c59b130569e28e3bb04ee9464e4cdf6f2ef18dcd Mon Sep 17 00:00:00 2001 From: Casey Langen Date: Thu, 10 Feb 2022 18:34:07 -0800 Subject: [PATCH] Introduced add_plugin() to CMake build system to ensure dependencies are properly configured for musikcube and musikcubed targets. --- .cmake/AddOsSpecificPlugins.cmake | 23 ++++++++++------------- .cmake/AddPlugin.cmake | 6 ++++++ CMakeLists.txt | 18 ++++++++++-------- 3 files changed, 26 insertions(+), 21 deletions(-) create mode 100644 .cmake/AddPlugin.cmake diff --git a/.cmake/AddOsSpecificPlugins.cmake b/.cmake/AddOsSpecificPlugins.cmake index 3abf16d73..8886ddd4c 100644 --- a/.cmake/AddOsSpecificPlugins.cmake +++ b/.cmake/AddOsSpecificPlugins.cmake @@ -1,10 +1,7 @@ # libopenmpt detection find_library(LIBOPENMPT NAMES openmpt) -if ("${LIBOPENMPT}" STREQUAL "LIBOPENMPT-NOTFOUND") - message(STATUS "[libopenmpt] *not* found! plugin will not be built.") -else() - message(STATUS "[libopenmpt] enabled = true; found library at ${LIBOPENMPT}") - add_subdirectory(src/plugins/libopenmptdecoder) +if (NOT "${LIBOPENMPT}" STREQUAL "LIBOPENMPT-NOTFOUND") + add_plugin(libopenmptdecoder) endif() # systemd / MPRIS detection @@ -24,28 +21,28 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux") add_subdirectory(src/plugins/alsaout) add_subdirectory(src/plugins/pulseout) if (${ENABLE_PIPEWIRE} MATCHES "true") - add_subdirectory(src/plugins/pipewireout) + add_plugin(pipewireout) endif() if (${ENABLE_MPRIS} MATCHES "true") - add_subdirectory(src/plugins/mpris) + add_plugin(mpris) endif() if (${ENABLE_SNDIO} MATCHES "true") - add_subdirectory(src/plugins/sndioout) + add_plugin(sndioout) endif() elseif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD") add_subdirectory(src/plugins/sndioout) if (${ENABLE_PULSEAUDIO} MATCHES "true") - add_subdirectory(src/plugins/pulseout) # disabled by default + add_plugin(pulseout) endif() elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") add_subdirectory(src/plugins/sndioout) if (${ENABLE_PULSEAUDIO} MATCHES "true") - add_subdirectory(src/plugins/pulseout) # disabled by default + add_plugin(pulseout) endif() if (${ENABLE_ALSA} MATCHES "true") - add_subdirectory(src/plugins/alsaout) # disabled by default + add_plugin(alsaout) endif() elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin") - add_subdirectory(src/plugins/coreaudioout) - add_subdirectory(src/plugins/macosmediakeys) + add_plugin(coreaudioout) + add_plugin(macosmediakeys) endif() \ No newline at end of file diff --git a/.cmake/AddPlugin.cmake b/.cmake/AddPlugin.cmake new file mode 100644 index 000000000..831fc84ed --- /dev/null +++ b/.cmake/AddPlugin.cmake @@ -0,0 +1,6 @@ +function(add_plugin plugin_name) + message(STATUS "[add-plugin] adding '${plugin_name}' to musikcube and musikcubed targets") + add_subdirectory("src/plugins/${plugin_name}") + add_dependencies(musikcube plugin_name) + add_dependencies(musikcubed plugin_name) +endfunction(add_plugin) \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 4720a8ce9..b1dffff4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,7 @@ set (EXECUTABLE_OUTPUT_PATH ${musikcube_SOURCE_DIR}/bin) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/.cmake) include(CMakeToolsHelpers OPTIONAL) include(CheckAtomic) +include(AddPlugin) include(ConfigureRpath) include(ConfigureStandalone) include(ConfigureBsdPaths) @@ -72,18 +73,19 @@ add_subdirectory(src/musikcore) add_subdirectory(src/core_c_demo) add_subdirectory(src/musikcube) add_subdirectory(src/musikcubed) -add_subdirectory(src/plugins/taglib_plugin) -add_subdirectory(src/plugins/nullout) -add_subdirectory(src/plugins/server) -add_subdirectory(src/plugins/httpdatastream) -add_subdirectory(src/plugins/stockencoders) -add_subdirectory(src/plugins/supereqdsp) -add_subdirectory(src/plugins/gmedecoder) -add_subdirectory(src/plugins/ffmpegdecoder) add_dependencies(musikcube musikcore) add_dependencies(musikcubed musikcore) +add_plugin(taglib_plugin) +add_plugin(nullout) +add_plugin(server) +add_plugin(httpdatastream) +add_plugin(stockencoders) +add_plugin(supereqdsp) +add_plugin(gmedecoder) +add_plugin(ffmpegdecoder) + include(AddOsSpecificPlugins) include(InstallFiles) include(GenerateDeb)