Some CMake cleanup. Marching towards static linking...

This commit is contained in:
casey langen 2022-02-07 17:22:51 -08:00
parent 41228f82b0
commit 35c8e1df02
22 changed files with 371 additions and 436 deletions

View File

@ -0,0 +1,51 @@
# 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)
endif()
# systemd / MPRIS detection
if (NOT ENABLE_MPRIS MATCHES "false")
find_library(LIB_SYSTEMD NAMES systemd)
if (NOT LIB_SYSTEMD MATCHES "LIB_SYSTEMD-NOTFOUND")
message(STATUS "[mpris] systemd found at " ${LIB_SYSTEMD})
message(STATUS "[mpris] setting ENABLE_MPRIS=true")
set(ENABLE_MPRIS "true")
else()
message(STATUS "[mpris] systemd *not* found. MPRIS plugin not enabled")
set(ENABLE_MPRIS "false")
endif()
endif()
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)
endif()
if (${ENABLE_MPRIS} MATCHES "true")
add_subdirectory(src/plugins/mpris)
endif()
if (${ENABLE_SNDIO} MATCHES "true")
add_subdirectory(src/plugins/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
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
endif()
if (${ENABLE_ALSA} MATCHES "true")
add_subdirectory(src/plugins/alsaout) # disabled by default
endif()
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_subdirectory(src/plugins/coreaudioout)
add_subdirectory(src/plugins/macosmediakeys)
endif()

View File

@ -0,0 +1,18 @@
if (CMAKE_SYSTEM_NAME MATCHES "Darwin" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
set(BSD_PATH_PREFIX "/usr/local")
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
execute_process(
COMMAND brew config
COMMAND grep -i HOMEBREW_PREFIX
COMMAND awk "{print $2}"
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE BSD_PATH_PREFIX)
endif()
message(STATUS "resolved BSD_PATH_PREFIX to: '${BSD_PATH_PREFIX}'")
link_directories ("${BSD_PATH_PREFIX}/lib")
link_directories ("${BSD_PATH_PREFIX}/opt/openssl/lib")
link_directories ("${BSD_PATH_PREFIX}/opt/ncurses/lib")
include_directories("${BSD_PATH_PREFIX}/include")
include_directories("${BSD_PATH_PREFIX}/opt/openssl/include")
include_directories("${BSD_PATH_PREFIX}/opt/ncurses/include")
endif ()

View File

@ -0,0 +1,10 @@
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wno-unused-result -Wno-deprecated-declarations")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -g -frtti -fexceptions")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
# enable for additional memory checking with fsanitize
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3 -fsanitize=address,undefined")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -frtti -fexceptions")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2")
add_definitions(-DHAVE_BOOST -D_FILE_OFFSET_BITS=64 -DSIGSLOT_USE_POSIX_THREADS)

View File

@ -0,0 +1,5 @@
if (EXISTS "/etc/arch-release" OR EXISTS "/etc/manjaro-release" OR NO_NCURSESW)
add_definitions (-DNO_NCURSESW)
elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR CMAKE_SYSTEM_NAME MATCHES "OpenBSD" )
add_definitions (-DNO_NCURSESW)
endif()

View File

@ -0,0 +1,10 @@
# ensure the binaries can find libmusikcore.so, which lives in the same directory.
if (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
# in Linux/BSD distributions we can specify the magic "$ORIGIN" value for
# the rpath for the dymamic linker to search the executable's directory
set(CMAKE_INSTALL_RPATH "$ORIGIN")
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
# note: macOS does not use $ORIGIN, and uses @executable_path/ instead. we
# add a custom post build step at the bottom of this file to add this value
# to macOS binaries.
endif()

View File

@ -0,0 +1,24 @@
if (${LINK_STATICALLY} MATCHES "true")
message(STATUS "[static linking] enabling static linking...")
set(BOOST_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/vendor/boost-bin")
set(BOOST_INCLUDEDIR "${CMAKE_CURRENT_SOURCE_DIR}/vendor/boost-bin/include")
set(BOOST_LIBRARYDIR "${CMAKE_CURRENT_SOURCE_DIR}/vendor/boost-bin/lib")
set(Boost_NO_SYSTEM_PATHS ON)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_NO_BOOST_CMAKE ON)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/vendor/ffmpeg-bin/include")
link_directories("${CMAKE_CURRENT_SOURCE_DIR}/vendor/ffmpeg-bin/lib")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/vendor/lame-bin/include")
link_directories("${CMAKE_CURRENT_SOURCE_DIR}/vendor/lame-bin/lib")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/vendor/libmicrohttpd-bin/include")
link_directories("${CMAKE_CURRENT_SOURCE_DIR}/vendor/libmicrohttpd-bin/lib")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/vendor/zlib-bin/include")
link_directories("${CMAKE_CURRENT_SOURCE_DIR}/vendor/zlib-bin/lib")
else()
message(STATUS "[static linking] static linking NOT enabled!")
endif()

View File

@ -0,0 +1,9 @@
# we default to using a bundled version of taglib because the latest release
# is from 2016, and the upstream git repo is hundreds of commits ahead and
# has a number of important bugfixes.
if (NOT DEFINED ENABLE_BUNDLED_TAGLIB)
message(STATUS "[build] ENABLE_BUNDLED_TAGLIB not defined, setting to 'true'")
set(ENABLE_BUNDLED_TAGLIB "true")
else()
message(STATUS "[build] ENABLE_BUNDLED_TAGLIB specified as '${ENABLE_BUNDLED_TAGLIB}'")
endif()

68
.cmake/GenerateDeb.cmake Normal file
View File

@ -0,0 +1,68 @@
if (GENERATE_DEB MATCHES "1")
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
set(DEB_BOOST_VERSION "1.55.0")
set(DEB_MICROHTTPD_VERSION "10")
set(DEB_LIBCURL_VERSION "3")
set(DEB_AVUTIL_VERSION "55")
set(DEB_AVFORMAT_VERSION "57")
set(DEB_SWRESAMPLE_VERSION "2")
set(DEB_NCURSES_VERSION "5")
if (DEB_DISTRO MATCHES "artful")
set(DEB_BOOST_VERSION "1.63.0")
set(DEB_MICROHTTPD_VERSION "12")
elseif (DEB_DISTRO MATCHES "bionic")
set(DEB_BOOST_VERSION "1.65.1")
set(DEB_MICROHTTPD_VERSION "12")
set(DEB_LIBCURL_VERSION "4")
elseif (DEB_DISTRO MATCHES "cosmic" OR DEB_DISTRO MATCHES "disco" OR DEB_DISTRO MATCHES "eoan" OR DEB_DISTRO MATCHES "buster")
set(DEB_BOOST_VERSION "1.67.0")
set(DEB_MICROHTTPD_VERSION "12")
set(DEB_LIBCURL_VERSION "4")
set(DEB_AVUTIL_VERSION "56")
set(DEB_AVFORMAT_VERSION "58")
set(DEB_SWRESAMPLE_VERSION "3")
elseif (DEB_DISTRO MATCHES "focal" OR DEB_DISTRO MATCHES "groovy" OR DEB_DISTRO MATCHES "ulyssa")
set(DEB_BOOST_VERSION "1.71.0")
set(DEB_MICROHTTPD_VERSION "12")
set(DEB_LIBCURL_VERSION "4")
set(DEB_AVUTIL_VERSION "56")
set(DEB_AVFORMAT_VERSION "58")
set(DEB_SWRESAMPLE_VERSION "3")
set(DEB_NCURSES_VERSION "6")
elseif (DEB_DISTRO MATCHES "hirsute")
set(DEB_BOOST_VERSION "1.71.0")
set(DEB_MICROHTTPD_VERSION "12")
set(DEB_LIBCURL_VERSION "4")
set(DEB_AVUTIL_VERSION "56")
set(DEB_AVFORMAT_VERSION "58")
set(DEB_SWRESAMPLE_VERSION "3")
set(DEB_NCURSES_VERSION "6")
elseif (DEB_DISTRO MATCHES "impish" OR DEB_DISTRO MATCHES "bullseye")
set(DEB_BOOST_VERSION "1.74.0")
set(DEB_MICROHTTPD_VERSION "12")
set(DEB_LIBCURL_VERSION "4")
set(DEB_AVUTIL_VERSION "56")
set(DEB_AVFORMAT_VERSION "58")
set(DEB_SWRESAMPLE_VERSION "3")
set(DEB_NCURSES_VERSION "6")
endif()
set(DEPENDENCIES "libboost-thread${DEB_BOOST_VERSION}, libboost-system${DEB_BOOST_VERSION}, libboost-chrono${DEB_BOOST_VERSION}, libboost-filesystem${DEB_BOOST_VERSION}, libboost-date-time${DEB_BOOST_VERSION}, libmicrohttpd${DEB_MICROHTTPD_VERSION}, libcurl${DEB_LIBCURL_VERSION}, libogg0, libvorbis0a, libvorbisfile3, libncursesw${DEB_NCURSES_VERSION}, libasound2, libpulse0, pulseaudio, libmp3lame0, libev4, libopenmpt0, libssl1.1")
set(DEPENDENCIES "${DEPENDENCIES}, libavcodec-extra, libavutil${DEB_AVUTIL_VERSION}, libavformat${DEB_AVFORMAT_VERSION}, libswresample${DEB_SWRESAMPLE_VERSION}")
if (${ENABLE_BUNDLED_TAGLIB} MATCHES "false")
set(DEPENDENCIES "${DEPENDENCIES}, libtag1v5")
endif()
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_DESCRIPTION "musikcube, a terminal-based music player and library")
set(CPACK_PACKAGE_VERSION_MAJOR "${musikcube_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${musikcube_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${musikcube_VERSION_PATCH}")
set(CPACK_DEBIAN_PACKAGE_DEPENDS ${DEPENDENCIES})
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "casey langen")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${DEB_ARCHITECTURE})
set(CPACK_PACKAGE_FILE_NAME "musikcube_${musikcube_VERSION}_${DEB_PLATFORM}_${DEB_DISTRO}_${DEB_ARCHITECTURE}")
include(CPack)
endif()
endif()

74
.cmake/InstallFiles.cmake Normal file
View File

@ -0,0 +1,74 @@
# plugin dynamic libraries
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
file(GLOB plugins "bin/plugins/*.dylib")
install(FILES ${plugins} DESTINATION share/musikcube/plugins)
else ()
file(GLOB plugins "bin/plugins/*.so")
install(FILES ${plugins} DESTINATION share/musikcube/plugins)
endif ()
# sdk header files
file(GLOB sdk_headers "src/musikcore/sdk/*.h")
install(FILES ${sdk_headers} DESTINATION include/musikcube/musikcore/sdk)
# resources
file(GLOB themes "src/musikcube/data/themes/*.json")
file(COPY ${themes} DESTINATION bin/themes)
install(FILES ${themes} DESTINATION share/musikcube/themes)
file(GLOB locales "src/musikcube/data/locales/*.json")
file(COPY ${locales} DESTINATION bin/locales)
install(FILES ${locales} DESTINATION share/musikcube/locales)
# linux desktop shortcuts
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
file(GLOB linux_share_applications "src/musikcube/data/linux/share/applications/musikcube.desktop")
install(FILES ${linux_share_applications} DESTINATION share/applications/)
file(GLOB linux_share_icons_48 "src/musikcube/data/linux/share/icons/hicolor/48x48/apps/*")
install(FILES ${linux_share_icons_48} DESTINATION share/icons/hicolor/48x48/apps/)
file(GLOB linux_share_icons_64 "src/musikcube/data/linux/share/icons/hicolor/64x64/apps/*")
install(FILES ${linux_share_icons_64} DESTINATION share/icons/hicolor/64x64/apps/)
file(GLOB linux_share_icons_128 "src/musikcube/data/linux/share/icons/hicolor/128x128/apps/*")
install(FILES ${linux_share_icons_128} DESTINATION share/icons/hicolor/128x128/apps/)
endif()
# libmusikcore shared library
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
install(FILES "bin/libmusikcore.dylib" DESTINATION share/musikcube)
else()
install(FILES "bin/libmusikcore.so" DESTINATION share/musikcube)
endif()
# executable and shell script for musikcube
install(
FILES bin/musikcube
DESTINATION share/musikcube
PERMISSIONS
OWNER_EXECUTE OWNER_READ OWNER_WRITE
GROUP_EXECUTE GROUP_READ GROUP_WRITE
WORLD_EXECUTE WORLD_READ)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/src/musikcube/musikcube"
DESTINATION bin/
PERMISSIONS
OWNER_EXECUTE OWNER_READ OWNER_WRITE
GROUP_EXECUTE GROUP_READ GROUP_WRITE
WORLD_EXECUTE WORLD_READ)
# executable and shell script for daemon
install(
FILES bin/musikcubed
DESTINATION share/musikcube
PERMISSIONS
OWNER_EXECUTE OWNER_READ OWNER_WRITE
GROUP_EXECUTE GROUP_READ GROUP_WRITE
WORLD_EXECUTE WORLD_READ)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/src/musikcubed/musikcubed"
DESTINATION bin/
PERMISSIONS
OWNER_EXECUTE OWNER_READ OWNER_WRITE
GROUP_EXECUTE GROUP_READ GROUP_WRITE
WORLD_EXECUTE WORLD_READ)

21
.cmake/PostBuild.cmake Normal file
View File

@ -0,0 +1,21 @@
# run `cmake .` again to pick up build plugin build artifacts that we need
# to file glob in. these won't be picked up on the initial build because
# they don't yet exist!
add_custom_target(postbuild ALL DEPENDS musikcube musikcubed)
add_custom_command(TARGET postbuild POST_BUILD COMMAND cmake .)
# strip binaries in release mode
if (CMAKE_BUILD_TYPE MATCHES Release)
if ((NOT DEFINED DISABLE_STRIP) OR (NOT ${DISABLE_STRIP} MATCHES "true"))
message(STATUS "[build] binary stripping enabled for ${CMAKE_CURRENT_SOURCE_DIR}")
add_custom_command(TARGET postbuild POST_BUILD COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/script/strip-nix.sh" ${CMAKE_CURRENT_SOURCE_DIR})
else()
message(STATUS "[build] DISABLE_STRIP=true, *NOT* stripping binaries.")
endif()
endif()
# ensure the binaries can find libmusikcore.so, which lives in the same directory.
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_custom_command(TARGET postbuild POST_BUILD COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/script/patch-macos-rpath.sh")
endif()

View File

@ -10,20 +10,19 @@ set (musikcube_VERSION_MAJOR 0)
set (musikcube_VERSION_MINOR 96) set (musikcube_VERSION_MINOR 96)
set (musikcube_VERSION_PATCH 11) set (musikcube_VERSION_PATCH 11)
set (musikcube_VERSION "${musikcube_VERSION_MAJOR}.${musikcube_VERSION_MINOR}.${musikcube_VERSION_PATCH}") set (musikcube_VERSION "${musikcube_VERSION_MAJOR}.${musikcube_VERSION_MINOR}.${musikcube_VERSION_PATCH}")
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) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/.cmake)
include(CMakeToolsHelpers OPTIONAL) include(CMakeToolsHelpers OPTIONAL)
include(CheckDependencies) include(CheckDependencies)
include(CheckAtomic) include(CheckAtomic)
include(ConfigureCurses)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wno-unused-result -Wno-deprecated-declarations") include(ConfigureRpath)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -g -frtti -fexceptions") include(ConfigureTaglib)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG") include(ConfigureBsdPaths)
include(ConfigureCompilerFlags)
# enable for additional memory checking with fsanitize include(ConfigureStaticLinking)
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3 -fsanitize=address,undefined")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -frtti -fexceptions")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2")
# our include directories # our include directories
include_directories( include_directories(
@ -36,57 +35,25 @@ include_directories (
# our library directories # our library directories
link_directories("${musikcube_SOURCE_DIR}/bin/plugins") link_directories("${musikcube_SOURCE_DIR}/bin/plugins")
# custom include/library directories for BSDs find_package(Boost 1.55.0 REQUIRED system filesystem thread)
if (CMAKE_SYSTEM_NAME MATCHES "Darwin" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR CMAKE_SYSTEM_NAME MATCHES "OpenBSD") include_directories(${Boost_INCLUDE_DIRS})
set(BSD_PATH_PREFIX "/usr/local") message(STATUS "[boost] libs: " ${Boost_LIBRARIES})
if (CMAKE_SYSTEM_NAME MATCHES "Darwin") message(STATUS "[boost] includes: " ${Boost_INCLUDE_DIRS})
execute_process(
COMMAND brew config
COMMAND grep -i HOMEBREW_PREFIX
COMMAND awk "{print $2}"
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE BSD_PATH_PREFIX)
endif()
message(STATUS "resolved BSD_PATH_PREFIX to: '${BSD_PATH_PREFIX}'")
link_directories ("${BSD_PATH_PREFIX}/lib")
link_directories ("${BSD_PATH_PREFIX}/opt/openssl/lib")
link_directories ("${BSD_PATH_PREFIX}/opt/ncurses/lib")
include_directories("${BSD_PATH_PREFIX}/include")
include_directories("${BSD_PATH_PREFIX}/opt/openssl/include")
include_directories("${BSD_PATH_PREFIX}/opt/ncurses/include")
endif ()
if (${LINK_STATICALLY} MATCHES "true")
set(Boost_USE_STATIC_LIBS ON)
endif()
set (BOOST_LIBS system filesystem thread)
find_package(Boost 1.55.0 REQUIRED ${BOOST_LIBS})
add_definitions (-DHAVE_BOOST -D_FILE_OFFSET_BITS=64 -DSIGSLOT_USE_POSIX_THREADS)
set (BOOST_LINK_LIBS ${Boost_LIBRARIES})
#message(STATUS "boost libs: " ${BOOST_LINK_LIBS})
#message(STATUS "boost includes: " ${Boost_INCLUDE_DIRS})
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/Modules)
# SET (CMAKE_BUILD_TYPE DEBUG)
set (LIBRARY_OUTPUT_PATH ${musikcube_SOURCE_DIR}/bin/plugins)
set (EXECUTABLE_OUTPUT_PATH ${musikcube_SOURCE_DIR}/bin)
ensure_library_exists(curl) ensure_library_exists(curl)
ensure_library_exists(pthread) ensure_library_exists(pthread)
ensure_library_exists(ssl) ensure_library_exists(ssl)
ensure_library_exists(crypto) ensure_library_exists(crypto)
ensure_library_exists(z) ensure_library_exists(z)
set(COMMON_LINK_LIBS ${BOOST_LINK_LIBS} curl pthread ssl crypto) find_library(LIBCURL NAMES curl)
find_library(LIBPTHREAD NAMES pthread)
find_library(LIBSSL NAMES ssl)
find_library(LIBCRYPTO NAMES crypto)
set(COMMON_LINK_LIBS ${Boost_LIBRARIES} ${LIBCURL} ${LIBPTHREAD} ${LIBSSL} ${LIBCRYPTO})
if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR CMAKE_SYSTEM_NAME MATCHES "OpenBSD") if (CMAKE_SYSTEM_NAME MATCHES "Linux")
set (musikcube_LINK_LIBS ${COMMON_LINK_LIBS}) find_library(LIBDL NAMES dl)
else() set (musikcube_LINK_LIBS ${COMMON_LINK_LIBS} ${LIBDL})
set (musikcube_LINK_LIBS ${COMMON_LINK_LIBS} dl)
endif() endif()
if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB) if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB)
@ -96,36 +63,8 @@ if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB)
endif() endif()
endif() endif()
# we default to using a bundled version of taglib because the latest release
# is from 2016, and the upstream git repo is hundreds of commits ahead and
# has a number of important bugfixes.
if (NOT DEFINED ENABLE_BUNDLED_TAGLIB)
message(STATUS "[build] ENABLE_BUNDLED_TAGLIB not defined, setting to 'true'")
set(ENABLE_BUNDLED_TAGLIB "true")
else()
message(STATUS "[build] ENABLE_BUNDLED_TAGLIB specified as '${ENABLE_BUNDLED_TAGLIB}'")
endif()
message(STATUS "[build] link libraries are: ${musikcube_LINK_LIBS}") message(STATUS "[build] link libraries are: ${musikcube_LINK_LIBS}")
# ensure the binaries can find libmusikcore.so, which lives in the same directory.
if (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
# in Linux/BSD distributions we can specify the magic "$ORIGIN" value for
# the rpath for the dymamic linker to search the executable's directory
set(CMAKE_INSTALL_RPATH "$ORIGIN")
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
# note: macOS does not use $ORIGIN, and uses @executable_path/ insetad. we
# add a custom post build step at the bottom of this file to add this value
# to macOS binaries.
endif()
if (EXISTS "/etc/arch-release" OR EXISTS "/etc/manjaro-release" OR NO_NCURSESW)
add_definitions (-DNO_NCURSESW)
elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR CMAKE_SYSTEM_NAME MATCHES "OpenBSD" )
add_definitions (-DNO_NCURSESW)
endif()
add_subdirectory(src/musikcore) add_subdirectory(src/musikcore)
add_subdirectory(src/core_c_demo) add_subdirectory(src/core_c_demo)
add_subdirectory(src/musikcube) add_subdirectory(src/musikcube)
@ -137,250 +76,12 @@ add_subdirectory(src/plugins/httpdatastream)
add_subdirectory(src/plugins/stockencoders) add_subdirectory(src/plugins/stockencoders)
add_subdirectory(src/plugins/supereqdsp) add_subdirectory(src/plugins/supereqdsp)
add_subdirectory(src/plugins/gmedecoder) add_subdirectory(src/plugins/gmedecoder)
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)
endif()
if (${ENABLE_FFMPEG} MATCHES "false")
message(STATUS "[ffmpeg] enabled = false")
add_subdirectory(src/plugins/m4adecoder)
add_subdirectory(src/plugins/oggdecoder)
add_subdirectory(src/plugins/nomaddecoder)
add_subdirectory(src/plugins/flacdecoder)
add_dependencies(musikcube m4adecoder oggdecoder nomaddecoder flacdecoder)
else()
message(STATUS "[ffmpeg] enabled = true")
add_subdirectory(src/plugins/ffmpegdecoder) add_subdirectory(src/plugins/ffmpegdecoder)
add_dependencies(musikcube ffmpegdecoder)
endif()
# systemd / MPRIS detection add_dependencies(musikcube musikcore)
add_dependencies(musikcubed musikcore)
if (NOT ENABLE_MPRIS MATCHES "false") include(AddOsSpecificPlugins)
find_library(LIB_SYSTEMD NAMES systemd) include(InstallFiles)
if (NOT LIB_SYSTEMD MATCHES "LIB_SYSTEMD-NOTFOUND") include(GenerateDeb)
message(STATUS "[mpris] systemd found at " ${LIB_SYSTEMD}) include(PostBuild)
message(STATUS "[mpris] setting ENABLE_MPRIS=true")
set(ENABLE_MPRIS "true")
else()
message(STATUS "[mpris] systemd *not* found. MPRIS plugin not enabled")
set(ENABLE_MPRIS "false")
endif()
endif()
#end systemd / MPRIS detection
add_dependencies(musikcube musikcore taglibreader nullout server httpdatastream stockencoders)
add_dependencies(musikcubed musikcube)
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_dependencies(musikcube pipewireout)
endif()
if (${ENABLE_MPRIS} MATCHES "true")
add_subdirectory(src/plugins/mpris)
add_dependencies(musikcube mpris)
endif()
if (${ENABLE_SNDIO} MATCHES "true")
add_subdirectory(src/plugins/sndioout)
add_dependencies(musikcube sndioout)
endif()
elseif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
add_subdirectory(src/plugins/sndioout)
add_dependencies(musikcube sndioout)
if (${ENABLE_PULSEAUDIO} MATCHES "true")
add_subdirectory(src/plugins/pulseout) # disabled by default
add_dependencies(musikcube pulseout)
endif()
elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
add_subdirectory(src/plugins/sndioout)
add_dependencies(musikcube sndioout)
if (${ENABLE_PULSEAUDIO} MATCHES "true")
add_subdirectory(src/plugins/pulseout) # disabled by default
add_dependencies(musikcube pulseout)
endif()
if (${ENABLE_ALSA} MATCHES "true")
add_subdirectory(src/plugins/alsaout) # disabled by default
add_dependencies(musikcube alsaout)
endif()
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_subdirectory(src/plugins/coreaudioout)
add_dependencies(musikcube coreaudioout)
add_subdirectory(src/plugins/macosmediakeys)
add_dependencies(musikcube macosmediakeys)
endif()
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
file(GLOB plugins "bin/plugins/*.dylib")
install(FILES ${plugins} DESTINATION share/musikcube/plugins)
else ()
file(GLOB plugins "bin/plugins/*.so")
install(FILES ${plugins} DESTINATION share/musikcube/plugins)
endif ()
file(GLOB sdk_headers "src/musikcore/sdk/*.h")
install(FILES ${sdk_headers} DESTINATION include/musikcube/musikcore/sdk)
file(GLOB themes "src/musikcube/data/themes/*.json")
file(COPY ${themes} DESTINATION bin/themes)
install(FILES ${themes} DESTINATION share/musikcube/themes)
file(GLOB locales "src/musikcube/data/locales/*.json")
file(COPY ${locales} DESTINATION bin/locales)
install(FILES ${locales} DESTINATION share/musikcube/locales)
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
file(GLOB linux_share_applications "src/musikcube/data/linux/share/applications/musikcube.desktop")
install(FILES ${linux_share_applications} DESTINATION share/applications/)
file(GLOB linux_share_icons_48 "src/musikcube/data/linux/share/icons/hicolor/48x48/apps/*")
install(FILES ${linux_share_icons_48} DESTINATION share/icons/hicolor/48x48/apps/)
file(GLOB linux_share_icons_64 "src/musikcube/data/linux/share/icons/hicolor/64x64/apps/*")
install(FILES ${linux_share_icons_64} DESTINATION share/icons/hicolor/64x64/apps/)
file(GLOB linux_share_icons_128 "src/musikcube/data/linux/share/icons/hicolor/128x128/apps/*")
install(FILES ${linux_share_icons_128} DESTINATION share/icons/hicolor/128x128/apps/)
endif()
# libmusikcore sshared library
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
install(FILES "bin/libmusikcore.dylib" DESTINATION share/musikcube)
else()
install(FILES "bin/libmusikcore.so" DESTINATION share/musikcube)
endif()
# executable and shell script for musikcube
install(
FILES bin/musikcube
DESTINATION share/musikcube
PERMISSIONS
OWNER_EXECUTE OWNER_READ OWNER_WRITE
GROUP_EXECUTE GROUP_READ GROUP_WRITE
WORLD_EXECUTE WORLD_READ)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/src/musikcube/musikcube"
DESTINATION bin/
PERMISSIONS
OWNER_EXECUTE OWNER_READ OWNER_WRITE
GROUP_EXECUTE GROUP_READ GROUP_WRITE
WORLD_EXECUTE WORLD_READ)
# executable and shell script for daemon
install(
FILES bin/musikcubed
DESTINATION share/musikcube
PERMISSIONS
OWNER_EXECUTE OWNER_READ OWNER_WRITE
GROUP_EXECUTE GROUP_READ GROUP_WRITE
WORLD_EXECUTE WORLD_READ)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/src/musikcubed/musikcubed"
DESTINATION bin/
PERMISSIONS
OWNER_EXECUTE OWNER_READ OWNER_WRITE
GROUP_EXECUTE GROUP_READ GROUP_WRITE
WORLD_EXECUTE WORLD_READ)
# deb generation
if (GENERATE_DEB MATCHES "1")
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
set(DEB_BOOST_VERSION "1.55.0")
set(DEB_MICROHTTPD_VERSION "10")
set(DEB_LIBCURL_VERSION "3")
set(DEB_AVUTIL_VERSION "55")
set(DEB_AVFORMAT_VERSION "57")
set(DEB_SWRESAMPLE_VERSION "2")
set(DEB_NCURSES_VERSION "5")
if (DEB_DISTRO MATCHES "artful")
set(DEB_BOOST_VERSION "1.63.0")
set(DEB_MICROHTTPD_VERSION "12")
elseif (DEB_DISTRO MATCHES "bionic")
set(DEB_BOOST_VERSION "1.65.1")
set(DEB_MICROHTTPD_VERSION "12")
set(DEB_LIBCURL_VERSION "4")
elseif (DEB_DISTRO MATCHES "cosmic" OR DEB_DISTRO MATCHES "disco" OR DEB_DISTRO MATCHES "eoan" OR DEB_DISTRO MATCHES "buster")
set(DEB_BOOST_VERSION "1.67.0")
set(DEB_MICROHTTPD_VERSION "12")
set(DEB_LIBCURL_VERSION "4")
set(DEB_AVUTIL_VERSION "56")
set(DEB_AVFORMAT_VERSION "58")
set(DEB_SWRESAMPLE_VERSION "3")
elseif (DEB_DISTRO MATCHES "focal" OR DEB_DISTRO MATCHES "groovy" OR DEB_DISTRO MATCHES "ulyssa")
set(DEB_BOOST_VERSION "1.71.0")
set(DEB_MICROHTTPD_VERSION "12")
set(DEB_LIBCURL_VERSION "4")
set(DEB_AVUTIL_VERSION "56")
set(DEB_AVFORMAT_VERSION "58")
set(DEB_SWRESAMPLE_VERSION "3")
set(DEB_NCURSES_VERSION "6")
elseif (DEB_DISTRO MATCHES "hirsute")
set(DEB_BOOST_VERSION "1.71.0")
set(DEB_MICROHTTPD_VERSION "12")
set(DEB_LIBCURL_VERSION "4")
set(DEB_AVUTIL_VERSION "56")
set(DEB_AVFORMAT_VERSION "58")
set(DEB_SWRESAMPLE_VERSION "3")
set(DEB_NCURSES_VERSION "6")
elseif (DEB_DISTRO MATCHES "impish" OR DEB_DISTRO MATCHES "bullseye")
set(DEB_BOOST_VERSION "1.74.0")
set(DEB_MICROHTTPD_VERSION "12")
set(DEB_LIBCURL_VERSION "4")
set(DEB_AVUTIL_VERSION "56")
set(DEB_AVFORMAT_VERSION "58")
set(DEB_SWRESAMPLE_VERSION "3")
set(DEB_NCURSES_VERSION "6")
endif()
set(DEPENDENCIES "libboost-thread${DEB_BOOST_VERSION}, libboost-system${DEB_BOOST_VERSION}, libboost-chrono${DEB_BOOST_VERSION}, libboost-filesystem${DEB_BOOST_VERSION}, libboost-date-time${DEB_BOOST_VERSION}, libmicrohttpd${DEB_MICROHTTPD_VERSION}, libcurl${DEB_LIBCURL_VERSION}, libogg0, libvorbis0a, libvorbisfile3, libncursesw${DEB_NCURSES_VERSION}, libasound2, libpulse0, pulseaudio, libmp3lame0, libev4, libopenmpt0, libssl1.1")
if (${ENABLE_FFMPEG} MATCHES "false")
set(DEPENDENCIES "${DEPENDENCIES}, libflac8, libfaad2")
else()
set(DEPENDENCIES "${DEPENDENCIES}, libavcodec-extra, libavutil${DEB_AVUTIL_VERSION}, libavformat${DEB_AVFORMAT_VERSION}, libswresample${DEB_SWRESAMPLE_VERSION}")
endif()
if (${ENABLE_BUNDLED_TAGLIB} MATCHES "false")
set(DEPENDENCIES "${DEPENDENCIES}, libtag1v5")
endif()
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_DESCRIPTION "musikcube, a terminal-based music player and library")
set(CPACK_PACKAGE_VERSION_MAJOR "${musikcube_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${musikcube_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${musikcube_VERSION_PATCH}")
set(CPACK_DEBIAN_PACKAGE_DEPENDS ${DEPENDENCIES})
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "casey langen")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${DEB_ARCHITECTURE})
set(CPACK_PACKAGE_FILE_NAME "musikcube_${musikcube_VERSION}_${DEB_PLATFORM}_${DEB_DISTRO}_${DEB_ARCHITECTURE}")
include(CPack)
endif()
endif()
# run `cmake .` again to pick up build plugin build artifacts that we need
# to file glob in. these won't be picked up on the initial build because
# they don't yet exist!
add_custom_target(postbuild ALL DEPENDS musikcube musikcubed)
add_custom_command(TARGET postbuild POST_BUILD COMMAND cmake .)
# strip binaries in release mode
if (CMAKE_BUILD_TYPE MATCHES Release)
if ((NOT DEFINED DISABLE_STRIP) OR (NOT ${DISABLE_STRIP} MATCHES "true"))
message(STATUS "[build] binary stripping enabled for ${CMAKE_CURRENT_SOURCE_DIR}")
add_custom_command(TARGET postbuild POST_BUILD COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/script/strip-nix.sh" ${CMAKE_CURRENT_SOURCE_DIR})
else()
message(STATUS "[build] DISABLE_STRIP=true, *NOT* stripping binaries.")
endif()
endif()
# ensure the binaries can find libmusikcore.so, which lives in the same directory.
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_custom_command(TARGET postbuild POST_BUILD COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/script/patch-macos-rpath.sh")
endif()

View File

@ -12,7 +12,7 @@ SCRIPTDIR=`dirname "$0"`
rm -rf bin/ rm -rf bin/
${SCRIPTDIR}/clean-nix.sh ${SCRIPTDIR}/clean-nix.sh
cmake -DCMAKE_BUILD_TYPE=Release -DLINK_STATICALLY=true -DENABLE_FFMPEG=false . cmake -DCMAKE_BUILD_TYPE=Release -DLINK_STATICALLY=true .
make -j7 make -j7
DIRNAME="musikcube_macos_$VERSION" DIRNAME="musikcube_macos_$VERSION"

View File

@ -1,20 +1,29 @@
# libresample2 libavcodec-extra57 libavutil55 libavformat57
# libavcodec-dev libavformat-dev libavutil-dev libswresample-dev
set (ffmpegdecoder_SOURCES set (ffmpegdecoder_SOURCES
plugin.cpp plugin.cpp
FfmpegDecoder.cpp FfmpegDecoder.cpp
) )
add_library(ffmpegdecoder SHARED ${ffmpegdecoder_SOURCES})
if (${LINK_STATICALLY} MATCHES "true")
find_library(LIBAVCODEC NAMES libavcodec-musikcube.a PATHS "/home/clangen/src/musikcube/vendor/ffmpeg-bin/lib/")
find_library(LIBAVUTIL NAMES libavutil-musikcube.a PATHS "/home/clangen/src/musikcube/vendor/ffmpeg-bin/lib/")
find_library(LIBAVFORMAT NAMES libavformat-musikcube.a PATHS "/home/clangen/src/musikcube/vendor/ffmpeg-bin/lib/")
find_library(LIBSWRESAMPLE NAMES libswresample-musikcube.a PATHS "/home/clangen/src/musikcube/vendor/ffmpeg-bin/lib/")
target_link_libraries(ffmpegdecoder ${LIBAVCODEC} ${LIBAVUTIL} ${LIBAVFORMAT} ${LIBSWRESAMPLE})
#target_link_libraries(ffmpegdecoder -Wl,-Bdynamic libavcodec-musikcube.a libavutil-musikcube.a libavformat-musikcube.a libswresample-musikcube.a)
else()
# fedora (and probably other RPM-based distros) put ffmpeg includes here... # fedora (and probably other RPM-based distros) put ffmpeg includes here...
include_directories("/usr/include/ffmpeg") include_directories("/usr/include/ffmpeg")
include_directories("/usr/local/include/ffmpeg") include_directories("/usr/local/include/ffmpeg")
ensure_library_exists(avcodec) ensure_library_exists(avcodec)
ensure_library_exists(avutil) ensure_library_exists(avutil)
ensure_library_exists(avformat) ensure_library_exists(avformat)
ensure_library_exists(swresample) ensure_library_exists(swresample)
target_link_libraries(ffmpegdecoder avcodec avutil avformat swresample)
endif()
# note: static linking is a no-go (too many dependencies). sorry macOS. message(STATUS "clclcl ${LIBAVCODEC} ${LIBAVUTIL} ${LIBAVFORMAT} ${LIBSWRESAMPLE}")
add_library(ffmpegdecoder SHARED ${ffmpegdecoder_SOURCES})
target_link_libraries(ffmpegdecoder ${musikcube_LINK_LIBS} avcodec avutil avformat swresample) #target_link_libraries(ffmpegdecoder ${musikcube_LINK_LIBS})

View File

@ -6,5 +6,4 @@ set (httpdatastream_SOURCES
) )
add_library(httpdatastream SHARED ${httpdatastream_SOURCES}) add_library(httpdatastream SHARED ${httpdatastream_SOURCES})
target_link_libraries(httpdatastream ${musikcube_LINK_LIBS})
target_link_libraries(httpdatastream ${musikcube_LINK_LIBS} -lcurl)

View File

@ -8,46 +8,18 @@ set (server_SOURCES
Util.cpp Util.cpp
WebSocketServer.cpp) WebSocketServer.cpp)
set (BOOST_LIBS
system
filesystem
thread)
find_package(Boost 1.55.0 REQUIRED ${BOOST_LIBS})
add_definitions (-DHAVE_BOOST -D_FILE_OFFSET_BITS=64)
set (BOOST_LINK_LIBS ${Boost_LIBRARIES})
add_library(server SHARED ${server_SOURCES}) add_library(server SHARED ${server_SOURCES})
set (server_LINK_LIBS ${BOOST_LINK_LIBS}) set (server_LINK_LIBS ${Boost_LIBRARIES})
include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/include") include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/include")
include_directories(${Boost_INCLUDE_DIRS})
ensure_library_exists(microhttpd) ensure_library_exists(microhttpd)
if (${LINK_STATICALLY} MATCHES "true") if (${LINK_STATICALLY} MATCHES "true")
# libmicrohttpd on macOS now depends on `gnutls`. when we build statically, find_library(MICROHTTPDLIB NAMES libmicrohttpd.a)
# we also need to build libmicrohttpd ourselves and disable TLS to avoid this target_link_libraries(server ${server_LINK_LIBS} ${MICROHTTPDLIB})
# homebrew-only dependency
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
include (ExternalProject)
ExternalProject_Add(libmicrohttpd
URL https://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-0.9.71.tar.gz
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND ./configure --enable-https=no --disable-curl --prefix=${CMAKE_CURRENT_SOURCE_DIR}/microhttpd/.libs/
BUILD_COMMAND make
INSTALL_COMMAND make install
TEST_COMMAND "")
add_dependencies(server libmicrohttpd)
include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/microhttpd/include")
file(GLOB EXTRA_OBJS "${CMAKE_CURRENT_SOURCE_DIR}/libmicrohttpd-prefix/src/libmicrohttpd/src/microhttpd/*.o")
target_link_libraries(server ${server_LINK_LIBS} z crypto ${EXTRA_OBJS})
else()
find_library(MICROHTTPDLIB NAMES libmicrohttpd.a microhttpd)
target_link_libraries(server ${server_LINK_LIBS} ${MICROHTTPDLIB} z)
endif()
else() else()
set(EXTRA_LIBS "") set(EXTRA_LIBS "")
if (CMAKE_SYSTEM_NAME MATCHES "Darwin") if (CMAKE_SYSTEM_NAME MATCHES "Darwin")

View File

@ -8,29 +8,29 @@ add_library(stockencoders SHARED ${stockencoders_SOURCES})
ensure_library_exists(mp3lame) ensure_library_exists(mp3lame)
if (${ENABLE_FFMPEG} MATCHES "false") if (${LINK_STATICALLY} MATCHES "true")
message(STATUS "[stockencoders] *not* defining ENABLE_FFMPEG") ensure_library_exists(avcodec-musikcube)
ensure_library_exists(avutil-musikcube)
ensure_library_exists(avformat-musikcube)
ensure_library_exists(swresample-musikcube)
target_link_libraries(stockencoders ${musikcube_LINK_LIBS} libavcodec-musikcube.a libavutil-musikcube.a libavformat-musikcube.a libswresample-musikcube.a)
else() else()
message(STATUS "[stockencoders] defining ENABLE_FFMPEG")
add_definitions(-DENABLE_FFMPEG)
# fedora (and probably other RPM-based distros) put ffmpeg includes here... # fedora (and probably other RPM-based distros) put ffmpeg includes here...
include_directories("/usr/include/ffmpeg") include_directories("/usr/include/ffmpeg")
include_directories("/usr/local/include/ffmpeg") include_directories("/usr/local/include/ffmpeg")
ensure_library_exists(avcodec) ensure_library_exists(avcodec)
ensure_library_exists(avutil) ensure_library_exists(avutil)
ensure_library_exists(avformat) ensure_library_exists(avformat)
ensure_library_exists(swresample) ensure_library_exists(swresample)
target_link_libraries(stockencoders ${musikcube_LINK_LIBS} avcodec avutil avformat swresample)
# note: static linking is a no-go (too many dependencies). sorry macOS.
target_link_libraries(stockencoders avcodec avutil avformat swresample)
endif() endif()
# prefer static libraries on mac to make redist easier # prefer static libraries on mac to make redist easier
if (${LINK_STATICALLY} MATCHES "true") if (${LINK_STATICALLY} MATCHES "true")
find_library(MP3LAMELIB NAMES libmp3lame.a mp3lame) find_library(MP3LAMELIB NAMES libmp3lame.a)
target_link_libraries(stockencoders ${musikcube_LINK_LIBS} ${MP3LAMELIB}) target_link_libraries(stockencoders ${MP3LAMELIB})
else() else()
target_link_libraries(stockencoders ${musikcube_LINK_LIBS} mp3lame) target_link_libraries(stockencoders mp3lame)
endif() endif()
target_link_libraries(stockencoders ${musikcube_LINK_LIBS})

View File

@ -34,8 +34,6 @@
#include "FfmpegEncoder.h" #include "FfmpegEncoder.h"
#ifdef ENABLE_FFMPEG
#include "shared.h" #include "shared.h"
#include <algorithm> #include <algorithm>
#include <random> #include <random>
@ -633,5 +631,3 @@ AVFrame* FfmpegEncoder::ReallocFrame(
} }
return original; return original;
} }
#endif // ENABLE_FFMPEG

View File

@ -34,12 +34,6 @@
#pragma once #pragma once
#ifdef WIN32
#define ENABLE_FFMPEG
#endif
#ifdef ENABLE_FFMPEG
#include <musikcore/sdk/IBlockingEncoder.h> #include <musikcore/sdk/IBlockingEncoder.h>
#include <musikcore/sdk/DataBuffer.h> #include <musikcore/sdk/DataBuffer.h>
#include <string> #include <string>
@ -104,5 +98,3 @@ class FfmpegEncoder : public musik::core::sdk::IBlockingEncoder {
int inputChannelCount; int inputChannelCount;
int inputSampleRate; int inputSampleRate;
}; };
#endif // ENABLE_FFMPEG

View File

@ -62,7 +62,6 @@ static IEnvironment* environment = nullptr;
static std::set<std::string> supportedFormats = { static std::set<std::string> supportedFormats = {
".mp3", ".mp3",
#ifdef ENABLE_FFMPEG
"audio/mpeg", "audio/mpeg",
".ogg", ".ogg",
"audio/ogg", "audio/ogg",
@ -77,7 +76,6 @@ static std::set<std::string> supportedFormats = {
".wma", ".wma",
"audio/x-ms-wma", "audio/x-ms-wma",
".wv" ".wv"
#endif
}; };
static class Plugin : public IPlugin { static class Plugin : public IPlugin {
@ -86,11 +84,7 @@ static class Plugin : public IPlugin {
} }
virtual void Release() { } virtual void Release() { }
#if defined(ENABLE_FFMPEG) || defined(WIN32)
virtual const char* Name() { return "Stock Encoders (lame + ffmpeg)"; } virtual const char* Name() { return "Stock Encoders (lame + ffmpeg)"; }
#else
virtual const char* Name() { return "Stock Encoders (lame)"; }
#endif
virtual const char* Version() { return "0.7.0"; } virtual const char* Version() { return "0.7.0"; }
virtual const char* Author() { return "clangen"; } virtual const char* Author() { return "clangen"; }
virtual const char* Guid() { return "d4d13803-a285-4481-ad1e-106131e0d523"; } virtual const char* Guid() { return "d4d13803-a285-4481-ad1e-106131e0d523"; }
@ -116,11 +110,9 @@ static class EncoderFactory: public IEncoderFactory {
if (isMp3(lowerType)) { if (isMp3(lowerType)) {
return new LameEncoder(); return new LameEncoder();
} }
#ifdef ENABLE_FFMPEG
else if (supportedFormats.find(lowerType) != supportedFormats.end()) { else if (supportedFormats.find(lowerType) != supportedFormats.end()) {
return new FfmpegEncoder(lowerType); return new FfmpegEncoder(lowerType);
} }
#endif
return nullptr; return nullptr;
} }

View File

@ -3,14 +3,8 @@ set (taglibreader_SOURCES
TaglibMetadataReader.cpp TaglibMetadataReader.cpp
) )
if (${ENABLE_FFMPEG} MATCHES "false")
message(STATUS "[taglibmetadatareader] *not* defining ENABLE_FFMPEG")
else()
message(STATUS "[taglibmetadatareader] defining ENABLE_FFMPEG")
add_definitions(-DENABLE_FFMPEG)
endif()
add_library(taglibreader SHARED ${taglibreader_SOURCES}) add_library(taglibreader SHARED ${taglibreader_SOURCES})
include_directories(${Boost_INCLUDE_DIRS})
if (NOT ${ENABLE_BUNDLED_TAGLIB} MATCHES "false") if (NOT ${ENABLE_BUNDLED_TAGLIB} MATCHES "false")
message(STATUS "[taglibmetadatareader] using bundled taglib = true") message(STATUS "[taglibmetadatareader] using bundled taglib = true")
@ -27,10 +21,10 @@ if (NOT ${ENABLE_BUNDLED_TAGLIB} MATCHES "false")
include_directories("${musikcube_SOURCE_DIR}/src/plugins/taglib_plugin/taglib-1.11/stage/include") include_directories("${musikcube_SOURCE_DIR}/src/plugins/taglib_plugin/taglib-1.11/stage/include")
add_dependencies(taglibreader taglib) add_dependencies(taglibreader taglib)
target_link_libraries(taglibreader ${BOOST_LINK_LIBS} "${musikcube_SOURCE_DIR}/src/plugins/taglib_plugin/taglib-1.11/stage/lib/libtag.a" z) target_link_libraries(taglibreader ${Boost_LIBRARIES} "${musikcube_SOURCE_DIR}/src/plugins/taglib_plugin/taglib-1.11/stage/lib/libtag.a" z)
message(STATUS "[taglibmetadatareader] using ${musikcube_SOURCE_DIR}/src/plugins/taglib_plugin/taglib-1.11/stage/lib/libtag.a") message(STATUS "[taglibmetadatareader] using ${musikcube_SOURCE_DIR}/src/plugins/taglib_plugin/taglib-1.11/stage/lib/libtag.a")
else() else()
message(STATUS "[taglibmetadatareader] using bundled taglib = false") message(STATUS "[taglibmetadatareader] using bundled taglib = false")
ensure_library_exists(tag) ensure_library_exists(tag)
target_link_libraries(taglibreader ${BOOST_LINK_LIBS} tag z) target_link_libraries(taglibreader ${Boost_LIBRARIES} tag z)
endif() endif()

View File

@ -92,10 +92,6 @@
#include <algorithm> #include <algorithm>
#include <string.h> #include <string.h>
#ifdef WIN32
#define ENABLE_FFMPEG
#endif
using namespace musik::core::sdk; using namespace musik::core::sdk;
namespace str { namespace str {
@ -243,7 +239,6 @@ bool TaglibMetadataReader::CanRead(const char *extension) {
if (extension && strlen(extension)) { if (extension && strlen(extension)) {
std::string ext(str::lower(extension[0] == '.' ? &extension[1] : extension)); std::string ext(str::lower(extension[0] == '.' ? &extension[1] : extension));
return return
#ifdef ENABLE_FFMPEG
ext.compare("opus") == 0 || ext.compare("opus") == 0 ||
ext.compare("wv") == 0 || ext.compare("wv") == 0 ||
ext.compare("wma") == 0 || ext.compare("wma") == 0 ||
@ -255,7 +250,6 @@ bool TaglibMetadataReader::CanRead(const char *extension) {
ext.compare("wave") == 0 || ext.compare("wave") == 0 ||
ext.compare("aif") == 0 || ext.compare("aif") == 0 ||
ext.compare("aiff") == 0 || ext.compare("aiff") == 0 ||
#endif
ext.compare("mp3") == 0 || ext.compare("mp3") == 0 ||
ext.compare("ogg") == 0 || ext.compare("ogg") == 0 ||
ext.compare("m4a") == 0 || ext.compare("m4a") == 0 ||

View File

@ -52,11 +52,7 @@
class TaglibPlugin : public musik::core::sdk::IPlugin { class TaglibPlugin : public musik::core::sdk::IPlugin {
public: public:
virtual void Release() { delete this; } virtual void Release() { delete this; }
#if defined(ENABLE_FFMPEG) || defined(WIN32)
virtual const char* Name() { return "Taglib 1.11 ITagReader (+ffmpeg)"; } virtual const char* Name() { return "Taglib 1.11 ITagReader (+ffmpeg)"; }
#else
virtual const char* Name() { return "Taglib 1.11 ITagReader"; }
#endif
virtual const char* Version() { return "0.6.0"; } virtual const char* Version() { return "0.6.0"; }
virtual const char* Author() { return "Daniel Önnerby, clangen"; } virtual const char* Author() { return "Daniel Önnerby, clangen"; }
virtual const char* Guid() { return "c77ea7a4-5d57-4f17-8521-aba8eeadeda7"; } virtual const char* Guid() { return "c77ea7a4-5d57-4f17-8521-aba8eeadeda7"; }