From 120b6fec0b73e43cb81d44bee539b8f2714d1cfc Mon Sep 17 00:00:00 2001 From: casey langen Date: Sun, 13 Mar 2022 16:52:18 -0700 Subject: [PATCH] Improve the way we scan for and add plugin, and also add the ability to log colors. --- .cmake/AddOsSpecificPlugins.cmake | 33 -------------------- .cmake/AddPlugin.cmake | 12 +++++-- .cmake/Colors.cmake | 20 ++++++++++++ CMakeLists.txt | 23 +++++++++++--- src/plugins/alsaout/CMakeLists.txt | 9 ++++-- src/plugins/coreaudioout/CMakeLists.txt | 22 +++++++------ src/plugins/libopenmptdecoder/CMakeLists.txt | 16 ++++++---- src/plugins/macosmediakeys/CMakeLists.txt | 15 +++++---- src/plugins/mpris/CMakeLists.txt | 7 ++--- src/plugins/pipewireout/CMakeLists.txt | 12 ++++--- src/plugins/pulseout/CMakeLists.txt | 10 ++++-- src/plugins/sndioout/CMakeLists.txt | 10 ++++-- 12 files changed, 109 insertions(+), 80 deletions(-) delete mode 100644 .cmake/AddOsSpecificPlugins.cmake create mode 100644 .cmake/Colors.cmake diff --git a/.cmake/AddOsSpecificPlugins.cmake b/.cmake/AddOsSpecificPlugins.cmake deleted file mode 100644 index 34774e677..000000000 --- a/.cmake/AddOsSpecificPlugins.cmake +++ /dev/null @@ -1,33 +0,0 @@ -# libopenmpt detection -find_library(LIBOPENMPT NAMES openmpt) -if (NOT "${LIBOPENMPT}" STREQUAL "LIBOPENMPT-NOTFOUND") - add_plugin("src/plugins/libopenmptdecoder" "openmptdecoder") -endif() - -if (CMAKE_SYSTEM_NAME MATCHES "Linux") - add_plugin("src/plugins/alsaout" "alsaout") - add_plugin("src/plugins/pulseout" "pulseout") - add_plugin("src/plugins/mpris" "mpris") - if (${ENABLE_PIPEWIRE} MATCHES "true") - add_plugin("src/plugins/pipewireout" "pipewireout") - endif() - if (${ENABLE_SNDIO} MATCHES "true") - add_plugin("src/plugins/sndioout" "sndioout") - endif() -elseif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD") - add_subdirectory(src/plugins/sndioout) - if (${ENABLE_PULSEAUDIO} MATCHES "true") - add_plugin("src/plugins/pulseout" "pulseout") - endif() -elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") - add_subdirectory(src/plugins/sndioout) - if (${ENABLE_PULSEAUDIO} MATCHES "true") - add_plugin("src/plugins/pulseout" "pulseout") - endif() - if (${ENABLE_ALSA} MATCHES "true") - add_plugin("src/plugins/alsaout" "alsaout") - endif() -elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin") - add_plugin("src/plugins/coreaudioout" "coreaudioout") - add_plugin("src/plugins/macosmediakeys" "macosmediakeys") -endif() \ No newline at end of file diff --git a/.cmake/AddPlugin.cmake b/.cmake/AddPlugin.cmake index 1222b1147..00f9d1e5f 100644 --- a/.cmake/AddPlugin.cmake +++ b/.cmake/AddPlugin.cmake @@ -1,12 +1,18 @@ macro(add_plugin plugin_dir plugin_name) - message(STATUS "[add-plugin] adding '${plugin_name}' at path '${plugin_dir}") add_subdirectory(${plugin_dir}) get_property(PLUGIN_DISABLED GLOBAL PROPERTY "DISABLE_${plugin_name}") if (NOT PLUGIN_DISABLED STREQUAL "true") + message(STATUS "[add-plugin] ${BoldGreen}added ${plugin_name}${ColorReset}") add_dependencies(musikcube ${plugin_name}) add_dependencies(musikcubed ${plugin_name}) add_dependencies(core_c_demo ${plugin_name}) else() - message(STATUS "[add-plugin] *** WARNING! *** ${plugin_name} not found.") + message(STATUS "[add-plugin] ${BoldRed}skipped ${plugin_name}${ColorReset}") endif() -endmacro(add_plugin) \ No newline at end of file +endmacro(add_plugin) + +macro(disable_plugin plugin_name) + set(PROPERTY_NAME "DISABLE_${plugin_name}") + set_property(GLOBAL PROPERTY ${PROPERTY_NAME} "true") + get_property(PLUGIN_DISABLED GLOBAL PROPERTY "DISABLE_${plugin_name}") +endmacro(disable_plugin) diff --git a/.cmake/Colors.cmake b/.cmake/Colors.cmake new file mode 100644 index 000000000..e7576742e --- /dev/null +++ b/.cmake/Colors.cmake @@ -0,0 +1,20 @@ +# https://stackoverflow.com/a/19578320 +if (NOT WIN32) + string(ASCII 27 Esc) + set(ColorReset "${Esc}[m") + set(ColorBold "${Esc}[1m") + set(Red "${Esc}[31m") + set(Green "${Esc}[32m") + set(Yellow "${Esc}[33m") + set(Blue "${Esc}[34m") + set(Magenta "${Esc}[35m") + set(Cyan "${Esc}[36m") + set(White "${Esc}[37m") + set(BoldRed "${Esc}[1;31m") + set(BoldGreen "${Esc}[1;32m") + set(BoldYellow "${Esc}[1;33m") + set(BoldBlue "${Esc}[1;34m") + set(BoldMagenta "${Esc}[1;35m") + set(BoldCyan "${Esc}[1;36m") + set(BoldWhite "${Esc}[1;37m") +endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index f9a47891f..65a354cfb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,7 @@ set (LIBRARY_OUTPUT_PATH ${musikcube_SOURCE_DIR}/bin/plugins) set (EXECUTABLE_OUTPUT_PATH ${musikcube_SOURCE_DIR}/bin) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/.cmake) +include(Colors) include(CMakeToolsHelpers OPTIONAL) include(CheckAtomic) include(AddPlugin) @@ -85,16 +86,30 @@ add_subdirectory(src/musikcubed) add_dependencies(musikcube musikcore) add_dependencies(musikcubed musikcore) +# tag readers add_plugin("src/plugins/taglib_plugin" "taglibreader") +# outputs add_plugin("src/plugins/nullout" "nullout") +add_plugin("src/plugins/alsaout" "alsaout") +add_plugin("src/plugins/pulseout" "pulseout") +add_plugin("src/plugins/pipewireout" "pipewireout") +add_plugin("src/plugins/sndioout" "sndioout") +add_plugin("src/plugins/coreaudioout" "coreaudioout") +# remotes add_plugin("src/plugins/server" "server") +add_plugin("src/plugins/mpris" "mpris") +add_plugin("src/plugins/macosmediakeys" "macosmediakeys") +# streams add_plugin("src/plugins/httpdatastream" "httpdatastream") -add_plugin("src/plugins/stockencoders" "stockencoders") -add_plugin("src/plugins/supereqdsp" "supereqdsp") -add_plugin("src/plugins/gmedecoder" "gmedecoder") +# decoders add_plugin("src/plugins/ffmpegdecoder" "ffmpegdecoder") +add_plugin("src/plugins/libopenmptdecoder" "openmptdecoder") +add_plugin("src/plugins/gmedecoder" "gmedecoder") +# encoders +add_plugin("src/plugins/stockencoders" "stockencoders") +# dsps +add_plugin("src/plugins/supereqdsp" "supereqdsp") -include(AddOsSpecificPlugins) include(InstallFiles) include(GeneratePackage) include(PostBuild) diff --git a/src/plugins/alsaout/CMakeLists.txt b/src/plugins/alsaout/CMakeLists.txt index 28b05c2a8..f72dbe13c 100755 --- a/src/plugins/alsaout/CMakeLists.txt +++ b/src/plugins/alsaout/CMakeLists.txt @@ -3,8 +3,11 @@ set (alsaout_SOURCES AlsaOut.cpp ) -add_library(alsaout SHARED ${alsaout_SOURCES}) - find_library(LIBASOUND asound) -target_link_libraries(alsaout ${LIBASOUND}) +if ("${LIBASOUND}" STREQUAL "LIBASOUND-NOTFOUND") + disable_plugin(alsaout) +else() + add_library(alsaout SHARED ${alsaout_SOURCES}) + target_link_libraries(alsaout ${LIBASOUND}) +endif() diff --git a/src/plugins/coreaudioout/CMakeLists.txt b/src/plugins/coreaudioout/CMakeLists.txt index 44f860350..17fb2bd1d 100644 --- a/src/plugins/coreaudioout/CMakeLists.txt +++ b/src/plugins/coreaudioout/CMakeLists.txt @@ -4,14 +4,16 @@ set (coreaudioout_SOURCES ) if (APPLE) - find_library(CORE_FOUNDATION_LIBRARY CoreFoundation) - find_library(CORE_AUDIO_LIBRARY CoreAudio) - find_library(AUDIO_TOOLBOX_LIBRARY AudioToolbox) - mark_as_advanced(CORE_FOUNDATION_LIBRARY - CORE_AUDIO_LIBRARY - AUDIO_TOOLBOX_LIBRARY) - set(FRAMEWORK_LIBS ${CORE_FOUNDATION_LIBRARY} ${CORE_AUDIO_LIBRARY} ${AUDIO_TOOLBOX_LIBRARY}) + find_library(CORE_FOUNDATION_LIBRARY CoreFoundation) + find_library(CORE_AUDIO_LIBRARY CoreAudio) + find_library(AUDIO_TOOLBOX_LIBRARY AudioToolbox) + mark_as_advanced(CORE_FOUNDATION_LIBRARY + CORE_AUDIO_LIBRARY + AUDIO_TOOLBOX_LIBRARY) + set(FRAMEWORK_LIBS ${CORE_FOUNDATION_LIBRARY} ${CORE_AUDIO_LIBRARY} ${AUDIO_TOOLBOX_LIBRARY}) - add_library(coreaudioout SHARED ${coreaudioout_SOURCES}) - target_link_libraries(coreaudioout ${FRAMEWORK_LIBS}) -endif (APPLE) + add_library(coreaudioout SHARED ${coreaudioout_SOURCES}) + target_link_libraries(coreaudioout ${FRAMEWORK_LIBS}) +else() + disable_plugin(coreaudioout) +endif() diff --git a/src/plugins/libopenmptdecoder/CMakeLists.txt b/src/plugins/libopenmptdecoder/CMakeLists.txt index 93f834a4f..f68eaa69d 100644 --- a/src/plugins/libopenmptdecoder/CMakeLists.txt +++ b/src/plugins/libopenmptdecoder/CMakeLists.txt @@ -9,13 +9,17 @@ add_library(openmptdecoder SHARED ${openmptdecoder_SOURCES}) if (${BUILD_STANDALONE} MATCHES "true") target_include_directories(openmptdecoder BEFORE PRIVATE ${VENDOR_INCLUDE_DIRECTORIES}) - find_vendor_library(OPENMPTLIB openmpt) - target_link_libraries(openmptdecoder ${OPENMPTLIB}) + find_vendor_library(LIBOPENMPT openmpt) + target_link_libraries(openmptdecoder ${LIBOPENMPT}) else() - find_library(OPENMPTLIB NAMES openmpt) - find_library(MPG123LIB NAMES mpg123) - find_library(ZLIB NAMES z) - target_link_libraries(openmptdecoder ${OPENMPTLIB} ${MPG123LIB} ${ZLIB}) + find_library(LIBOPENMPT NAMES openmpt) + find_library(LIBMPG123 NAMES mpg123) + find_library(LIBZ NAMES z) + if ("${LIBOPENMPT}" STREQUAL "LIBOPENMPT-NOTFOUND") + disable_plugin(openmptdecoder) + else() + target_link_libraries(openmptdecoder ${LIBOPENMPT} ${LIBMPG123} ${LIBZ}) + endif() endif() diff --git a/src/plugins/macosmediakeys/CMakeLists.txt b/src/plugins/macosmediakeys/CMakeLists.txt index 3a60aa384..e0cfd26e4 100644 --- a/src/plugins/macosmediakeys/CMakeLists.txt +++ b/src/plugins/macosmediakeys/CMakeLists.txt @@ -4,9 +4,12 @@ set (macosmediakeys_SOURCES SPMediaKeyTap.m ) -FIND_LIBRARY(APP_KIT_LIBRARY AppKit) -FIND_LIBRARY(CARBON_LIBRARY Carbon) -MARK_AS_ADVANCED (APP_KIT_LIBRARY CARBON_LIBRARY) - -add_library(macosmediakeys SHARED ${macosmediakeys_SOURCES}) -target_link_libraries(macosmediakeys ${APP_KIT_LIBRARY} ${CARBON_LIBRARY}) +if (APPLE) + FIND_LIBRARY(APP_KIT_LIBRARY AppKit) + FIND_LIBRARY(CARBON_LIBRARY Carbon) + MARK_AS_ADVANCED (APP_KIT_LIBRARY CARBON_LIBRARY) + add_library(macosmediakeys SHARED ${macosmediakeys_SOURCES}) + target_link_libraries(macosmediakeys ${APP_KIT_LIBRARY} ${CARBON_LIBRARY}) +else() + disable_plugin(macosmediakeys) +endif() \ No newline at end of file diff --git a/src/plugins/mpris/CMakeLists.txt b/src/plugins/mpris/CMakeLists.txt index 8b40511fc..1180d1cc8 100644 --- a/src/plugins/mpris/CMakeLists.txt +++ b/src/plugins/mpris/CMakeLists.txt @@ -13,11 +13,10 @@ endif() find_package(PkgConfig) pkg_check_modules(SDBUS IMPORTED_TARGET ${SDBUS}) -if (SDBUS_LINK_LIBRARIES STREQUAL "") +if (NOT DEFINED SDBUS_LINK_LIBRARIES) + disable_plugin(mpris) +else() message(STATUS "[mpris] plugin enabled. using " ${SDBUS_LINK_LIBRARIES}) add_library(mpris SHARED ${mpris_SOURCES}) target_link_libraries(mpris PkgConfig::SDBUS) -else() - set_property(GLOBAL PROPERTY DISABLE_mpris "true") - message(STATUS "[mpris] plugin *not* enabled. setting 'DISABLE_mpris=true'") endif() diff --git a/src/plugins/pipewireout/CMakeLists.txt b/src/plugins/pipewireout/CMakeLists.txt index 1d957836a..836b53c27 100644 --- a/src/plugins/pipewireout/CMakeLists.txt +++ b/src/plugins/pipewireout/CMakeLists.txt @@ -3,10 +3,12 @@ set (pipewireout_SOURCES PipeWireOut.cpp ) -message(STATUS "[pipewireout] plugin enabled") - find_package(PkgConfig) -pkg_check_modules(PIPEWIRE REQUIRED IMPORTED_TARGET libpipewire-0.3) +pkg_check_modules(PIPEWIRE IMPORTED_TARGET libpipewire-0.3) -add_library(pipewireout SHARED ${pipewireout_SOURCES}) -target_link_libraries(pipewireout PkgConfig::PIPEWIRE) +if (NOT DEFINED PIPEWIRE_LINK_LIBRARIES) + disable_plugin(pipewireout) +else() + add_library(pipewireout SHARED ${pipewireout_SOURCES}) + target_link_libraries(pipewireout PkgConfig::PIPEWIRE) +endif() diff --git a/src/plugins/pulseout/CMakeLists.txt b/src/plugins/pulseout/CMakeLists.txt index a42277d3f..7f9a23354 100755 --- a/src/plugins/pulseout/CMakeLists.txt +++ b/src/plugins/pulseout/CMakeLists.txt @@ -4,7 +4,11 @@ set (pulseout_SOURCES PulseOut.cpp ) -add_library(pulseout SHARED ${pulseout_SOURCES}) - find_library(LIBPULSE pulse) -target_link_libraries(pulseout ${LIBPULSE}) + +if ("${LIBPULSE}" STREQUAL "LIBPULSE-NOTFOUND") + disable_plugin(pulseout) +else() + add_library(pulseout SHARED ${pulseout_SOURCES}) + target_link_libraries(pulseout ${LIBPULSE}) +endif() diff --git a/src/plugins/sndioout/CMakeLists.txt b/src/plugins/sndioout/CMakeLists.txt index 28f7432fd..12cfd7e2c 100644 --- a/src/plugins/sndioout/CMakeLists.txt +++ b/src/plugins/sndioout/CMakeLists.txt @@ -3,7 +3,11 @@ set (sndioout_SOURCES SndioOut.cpp ) -add_library(sndioout SHARED ${sndioout_SOURCES}) - find_library(LIBSNDIO sndio) -target_link_libraries(sndioout ${LIBSNDIO}) + +if ("${LIBSNDIO}" STREQUAL "LIBSNDIO-NOTFOUND") + disable_plugin(sndioout) +else() + add_library(sndioout SHARED ${sndioout_SOURCES}) + target_link_libraries(sndioout ${LIBSNDIO}) +endif()