Skip to content

Commit

Permalink
Improve the way we scan for and add plugin, and also add the ability to
Browse files Browse the repository at this point in the history
log colors.
  • Loading branch information
clangen committed Mar 13, 2022
1 parent 090c5f2 commit 120b6fe
Show file tree
Hide file tree
Showing 12 changed files with 108 additions and 79 deletions.
33 changes: 0 additions & 33 deletions .cmake/AddOsSpecificPlugins.cmake

This file was deleted.

12 changes: 9 additions & 3 deletions .cmake/AddPlugin.cmake
Original file line number Diff line number Diff line change
@@ -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 changes: 20 additions & 0 deletions .cmake/Colors.cmake
Original file line number Diff line number Diff line change
@@ -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()
21 changes: 18 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
# 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")
add_plugin("src/plugins/gmedecoder" "gmedecoder")
add_plugin("src/plugins/ffmpegdecoder" "ffmpegdecoder")

include(AddOsSpecificPlugins)
include(InstallFiles)
include(GeneratePackage)
include(PostBuild)
9 changes: 6 additions & 3 deletions src/plugins/alsaout/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
22 changes: 12 additions & 10 deletions src/plugins/coreaudioout/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
16 changes: 10 additions & 6 deletions src/plugins/libopenmptdecoder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()


15 changes: 9 additions & 6 deletions src/plugins/macosmediakeys/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
7 changes: 3 additions & 4 deletions src/plugins/mpris/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
12 changes: 7 additions & 5 deletions src/plugins/pipewireout/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
10 changes: 7 additions & 3 deletions src/plugins/pulseout/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
10 changes: 7 additions & 3 deletions src/plugins/sndioout/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 120b6fe

Please sign in to comment.