Improve the way we scan for and add plugin, and also add the ability to

log colors.
This commit is contained in:
casey langen 2022-03-13 16:52:18 -07:00
parent 090c5f288d
commit 120b6fec0b
12 changed files with 109 additions and 80 deletions

View File

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

View File

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

20
.cmake/Colors.cmake Normal file
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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