diff --git a/.cmake/AddOsSpecificPlugins.cmake b/.cmake/AddOsSpecificPlugins.cmake new file mode 100644 index 000000000..3abf16d73 --- /dev/null +++ b/.cmake/AddOsSpecificPlugins.cmake @@ -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() \ No newline at end of file diff --git a/.cmake/ConfigureBsdPaths.cmake b/.cmake/ConfigureBsdPaths.cmake new file mode 100644 index 000000000..82f44d28d --- /dev/null +++ b/.cmake/ConfigureBsdPaths.cmake @@ -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 () \ No newline at end of file diff --git a/.cmake/ConfigureCompilerFlags.cmake b/.cmake/ConfigureCompilerFlags.cmake new file mode 100644 index 000000000..e8ccfaeab --- /dev/null +++ b/.cmake/ConfigureCompilerFlags.cmake @@ -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) \ No newline at end of file diff --git a/.cmake/ConfigureCurses.cmake b/.cmake/ConfigureCurses.cmake new file mode 100644 index 000000000..d2d1d0776 --- /dev/null +++ b/.cmake/ConfigureCurses.cmake @@ -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() \ No newline at end of file diff --git a/.cmake/ConfigureRpath.cmake b/.cmake/ConfigureRpath.cmake new file mode 100644 index 000000000..a3f28d7ba --- /dev/null +++ b/.cmake/ConfigureRpath.cmake @@ -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() \ No newline at end of file diff --git a/.cmake/ConfigureStaticLinking.cmake b/.cmake/ConfigureStaticLinking.cmake new file mode 100644 index 000000000..e7cf4d3e5 --- /dev/null +++ b/.cmake/ConfigureStaticLinking.cmake @@ -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() \ No newline at end of file diff --git a/.cmake/ConfigureTaglib.cmake b/.cmake/ConfigureTaglib.cmake new file mode 100644 index 000000000..614a07d1f --- /dev/null +++ b/.cmake/ConfigureTaglib.cmake @@ -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() diff --git a/.cmake/GenerateDeb.cmake b/.cmake/GenerateDeb.cmake new file mode 100644 index 000000000..363bc46d5 --- /dev/null +++ b/.cmake/GenerateDeb.cmake @@ -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() \ No newline at end of file diff --git a/.cmake/InstallFiles.cmake b/.cmake/InstallFiles.cmake new file mode 100644 index 000000000..05601c00f --- /dev/null +++ b/.cmake/InstallFiles.cmake @@ -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) \ No newline at end of file diff --git a/.cmake/PostBuild.cmake b/.cmake/PostBuild.cmake new file mode 100644 index 000000000..80292253f --- /dev/null +++ b/.cmake/PostBuild.cmake @@ -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() + diff --git a/CMakeLists.txt b/CMakeLists.txt index f6067dd90..c3324a243 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,23 +10,22 @@ set (musikcube_VERSION_MAJOR 0) set (musikcube_VERSION_MINOR 96) set (musikcube_VERSION_PATCH 11) 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) include(CMakeToolsHelpers OPTIONAL) include(CheckDependencies) include(CheckAtomic) - -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") +include(ConfigureCurses) +include(ConfigureRpath) +include(ConfigureTaglib) +include(ConfigureBsdPaths) +include(ConfigureCompilerFlags) +include(ConfigureStaticLinking) # our include directories -include_directories ( +include_directories( "${musikcube_SOURCE_DIR}/src" "${musikcube_SOURCE_DIR}/src/musikcore" "${musikcube_SOURCE_DIR}/src/musikcube" @@ -34,59 +33,27 @@ include_directories ( "${musikcube_SOURCE_DIR}/src/3rdparty/include") # our library directories -link_directories ("${musikcube_SOURCE_DIR}/bin/plugins") +link_directories("${musikcube_SOURCE_DIR}/bin/plugins") -# custom include/library directories for BSDs -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 () - -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) +find_package(Boost 1.55.0 REQUIRED system filesystem thread) +include_directories(${Boost_INCLUDE_DIRS}) +message(STATUS "[boost] libs: " ${Boost_LIBRARIES}) +message(STATUS "[boost] includes: " ${Boost_INCLUDE_DIRS}) ensure_library_exists(curl) ensure_library_exists(pthread) ensure_library_exists(ssl) ensure_library_exists(crypto) 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") - set (musikcube_LINK_LIBS ${COMMON_LINK_LIBS}) -else() - set (musikcube_LINK_LIBS ${COMMON_LINK_LIBS} dl) +if (CMAKE_SYSTEM_NAME MATCHES "Linux") + find_library(LIBDL NAMES dl) + set (musikcube_LINK_LIBS ${COMMON_LINK_LIBS} ${LIBDL}) endif() if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB) @@ -96,36 +63,8 @@ if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB) 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}") -# 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/core_c_demo) add_subdirectory(src/musikcube) @@ -137,250 +76,12 @@ 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) -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() +add_dependencies(musikcube musikcore) +add_dependencies(musikcubed musikcore) -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_dependencies(musikcube ffmpegdecoder) -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() - -#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() \ No newline at end of file +include(AddOsSpecificPlugins) +include(InstallFiles) +include(GenerateDeb) +include(PostBuild) diff --git a/script/archive-macos.sh b/script/archive-macos.sh index 8b9c4c426..fccd0e6c2 100755 --- a/script/archive-macos.sh +++ b/script/archive-macos.sh @@ -12,7 +12,7 @@ SCRIPTDIR=`dirname "$0"` rm -rf bin/ ${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 DIRNAME="musikcube_macos_$VERSION" diff --git a/src/plugins/ffmpegdecoder/CMakeLists.txt b/src/plugins/ffmpegdecoder/CMakeLists.txt index b33c8f065..9a595e314 100644 --- a/src/plugins/ffmpegdecoder/CMakeLists.txt +++ b/src/plugins/ffmpegdecoder/CMakeLists.txt @@ -1,20 +1,29 @@ -# libresample2 libavcodec-extra57 libavutil55 libavformat57 -# libavcodec-dev libavformat-dev libavutil-dev libswresample-dev - set (ffmpegdecoder_SOURCES plugin.cpp FfmpegDecoder.cpp ) -# fedora (and probably other RPM-based distros) put ffmpeg includes here... -include_directories("/usr/include/ffmpeg") -include_directories("/usr/local/include/ffmpeg") - -ensure_library_exists(avcodec) -ensure_library_exists(avutil) -ensure_library_exists(avformat) -ensure_library_exists(swresample) - -# note: static linking is a no-go (too many dependencies). sorry macOS. add_library(ffmpegdecoder SHARED ${ffmpegdecoder_SOURCES}) -target_link_libraries(ffmpegdecoder ${musikcube_LINK_LIBS} avcodec avutil avformat swresample) + +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... + include_directories("/usr/include/ffmpeg") + include_directories("/usr/local/include/ffmpeg") + ensure_library_exists(avcodec) + ensure_library_exists(avutil) + ensure_library_exists(avformat) + ensure_library_exists(swresample) + target_link_libraries(ffmpegdecoder avcodec avutil avformat swresample) +endif() + +message(STATUS "clclcl ${LIBAVCODEC} ${LIBAVUTIL} ${LIBAVFORMAT} ${LIBSWRESAMPLE}") + +#target_link_libraries(ffmpegdecoder ${musikcube_LINK_LIBS}) diff --git a/src/plugins/httpdatastream/CMakeLists.txt b/src/plugins/httpdatastream/CMakeLists.txt index 6c9094fc3..9a9a6b786 100644 --- a/src/plugins/httpdatastream/CMakeLists.txt +++ b/src/plugins/httpdatastream/CMakeLists.txt @@ -6,5 +6,4 @@ set (httpdatastream_SOURCES ) add_library(httpdatastream SHARED ${httpdatastream_SOURCES}) - -target_link_libraries(httpdatastream ${musikcube_LINK_LIBS} -lcurl) +target_link_libraries(httpdatastream ${musikcube_LINK_LIBS}) diff --git a/src/plugins/server/CMakeLists.txt b/src/plugins/server/CMakeLists.txt index f8cf04a6a..b9acaac29 100644 --- a/src/plugins/server/CMakeLists.txt +++ b/src/plugins/server/CMakeLists.txt @@ -8,46 +8,18 @@ set (server_SOURCES Util.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}) -set (server_LINK_LIBS ${BOOST_LINK_LIBS}) +set (server_LINK_LIBS ${Boost_LIBRARIES}) include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/include") +include_directories(${Boost_INCLUDE_DIRS}) ensure_library_exists(microhttpd) if (${LINK_STATICALLY} MATCHES "true") - # libmicrohttpd on macOS now depends on `gnutls`. when we build statically, - # we also need to build libmicrohttpd ourselves and disable TLS to avoid this - # 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() + find_library(MICROHTTPDLIB NAMES libmicrohttpd.a) + target_link_libraries(server ${server_LINK_LIBS} ${MICROHTTPDLIB}) else() set(EXTRA_LIBS "") if (CMAKE_SYSTEM_NAME MATCHES "Darwin") diff --git a/src/plugins/stockencoders/CMakeLists.txt b/src/plugins/stockencoders/CMakeLists.txt index f1e41020b..88de7086d 100644 --- a/src/plugins/stockencoders/CMakeLists.txt +++ b/src/plugins/stockencoders/CMakeLists.txt @@ -8,29 +8,29 @@ add_library(stockencoders SHARED ${stockencoders_SOURCES}) ensure_library_exists(mp3lame) -if (${ENABLE_FFMPEG} MATCHES "false") - message(STATUS "[stockencoders] *not* defining ENABLE_FFMPEG") +if (${LINK_STATICALLY} MATCHES "true") + 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() - message(STATUS "[stockencoders] defining ENABLE_FFMPEG") - add_definitions(-DENABLE_FFMPEG) - - # fedora (and probably other RPM-based distros) put ffmpeg includes here... - include_directories("/usr/include/ffmpeg") - include_directories("/usr/local/include/ffmpeg") - - ensure_library_exists(avcodec) - ensure_library_exists(avutil) - ensure_library_exists(avformat) - ensure_library_exists(swresample) - - # note: static linking is a no-go (too many dependencies). sorry macOS. - target_link_libraries(stockencoders avcodec avutil avformat swresample) + # fedora (and probably other RPM-based distros) put ffmpeg includes here... + include_directories("/usr/include/ffmpeg") + include_directories("/usr/local/include/ffmpeg") + ensure_library_exists(avcodec) + ensure_library_exists(avutil) + ensure_library_exists(avformat) + ensure_library_exists(swresample) + target_link_libraries(stockencoders ${musikcube_LINK_LIBS} avcodec avutil avformat swresample) endif() # prefer static libraries on mac to make redist easier if (${LINK_STATICALLY} MATCHES "true") - find_library(MP3LAMELIB NAMES libmp3lame.a mp3lame) - target_link_libraries(stockencoders ${musikcube_LINK_LIBS} ${MP3LAMELIB}) + find_library(MP3LAMELIB NAMES libmp3lame.a) + target_link_libraries(stockencoders ${MP3LAMELIB}) else() - target_link_libraries(stockencoders ${musikcube_LINK_LIBS} mp3lame) + target_link_libraries(stockencoders mp3lame) endif() + +target_link_libraries(stockencoders ${musikcube_LINK_LIBS}) diff --git a/src/plugins/stockencoders/FfmpegEncoder.cpp b/src/plugins/stockencoders/FfmpegEncoder.cpp index bf2a8a9ff..26c6015d9 100644 --- a/src/plugins/stockencoders/FfmpegEncoder.cpp +++ b/src/plugins/stockencoders/FfmpegEncoder.cpp @@ -34,8 +34,6 @@ #include "FfmpegEncoder.h" -#ifdef ENABLE_FFMPEG - #include "shared.h" #include #include @@ -633,5 +631,3 @@ AVFrame* FfmpegEncoder::ReallocFrame( } return original; } - -#endif // ENABLE_FFMPEG diff --git a/src/plugins/stockencoders/FfmpegEncoder.h b/src/plugins/stockencoders/FfmpegEncoder.h index de47b87f3..c13520865 100644 --- a/src/plugins/stockencoders/FfmpegEncoder.h +++ b/src/plugins/stockencoders/FfmpegEncoder.h @@ -34,12 +34,6 @@ #pragma once -#ifdef WIN32 -#define ENABLE_FFMPEG -#endif - -#ifdef ENABLE_FFMPEG - #include #include #include @@ -104,5 +98,3 @@ class FfmpegEncoder : public musik::core::sdk::IBlockingEncoder { int inputChannelCount; int inputSampleRate; }; - -#endif // ENABLE_FFMPEG diff --git a/src/plugins/stockencoders/main.cpp b/src/plugins/stockencoders/main.cpp index 3457af7a8..8428d85ad 100644 --- a/src/plugins/stockencoders/main.cpp +++ b/src/plugins/stockencoders/main.cpp @@ -62,7 +62,6 @@ static IEnvironment* environment = nullptr; static std::set supportedFormats = { ".mp3", -#ifdef ENABLE_FFMPEG "audio/mpeg", ".ogg", "audio/ogg", @@ -77,7 +76,6 @@ static std::set supportedFormats = { ".wma", "audio/x-ms-wma", ".wv" -#endif }; static class Plugin : public IPlugin { @@ -86,11 +84,7 @@ static class Plugin : public IPlugin { } virtual void Release() { } -#if defined(ENABLE_FFMPEG) || defined(WIN32) 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* Author() { return "clangen"; } virtual const char* Guid() { return "d4d13803-a285-4481-ad1e-106131e0d523"; } @@ -116,11 +110,9 @@ static class EncoderFactory: public IEncoderFactory { if (isMp3(lowerType)) { return new LameEncoder(); } -#ifdef ENABLE_FFMPEG else if (supportedFormats.find(lowerType) != supportedFormats.end()) { return new FfmpegEncoder(lowerType); } -#endif return nullptr; } diff --git a/src/plugins/taglib_plugin/CMakeLists.txt b/src/plugins/taglib_plugin/CMakeLists.txt index 629c23808..62225d7de 100644 --- a/src/plugins/taglib_plugin/CMakeLists.txt +++ b/src/plugins/taglib_plugin/CMakeLists.txt @@ -3,15 +3,9 @@ set (taglibreader_SOURCES 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}) - +include_directories(${Boost_INCLUDE_DIRS}) + if (NOT ${ENABLE_BUNDLED_TAGLIB} MATCHES "false") 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") 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") else() message(STATUS "[taglibmetadatareader] using bundled taglib = false") ensure_library_exists(tag) - target_link_libraries(taglibreader ${BOOST_LINK_LIBS} tag z) + target_link_libraries(taglibreader ${Boost_LIBRARIES} tag z) endif() diff --git a/src/plugins/taglib_plugin/TaglibMetadataReader.cpp b/src/plugins/taglib_plugin/TaglibMetadataReader.cpp index a84ee1ea1..4bdb849ff 100644 --- a/src/plugins/taglib_plugin/TaglibMetadataReader.cpp +++ b/src/plugins/taglib_plugin/TaglibMetadataReader.cpp @@ -92,10 +92,6 @@ #include #include -#ifdef WIN32 -#define ENABLE_FFMPEG -#endif - using namespace musik::core::sdk; namespace str { @@ -243,7 +239,6 @@ bool TaglibMetadataReader::CanRead(const char *extension) { if (extension && strlen(extension)) { std::string ext(str::lower(extension[0] == '.' ? &extension[1] : extension)); return -#ifdef ENABLE_FFMPEG ext.compare("opus") == 0 || ext.compare("wv") == 0 || ext.compare("wma") == 0 || @@ -255,7 +250,6 @@ bool TaglibMetadataReader::CanRead(const char *extension) { ext.compare("wave") == 0 || ext.compare("aif") == 0 || ext.compare("aiff") == 0 || -#endif ext.compare("mp3") == 0 || ext.compare("ogg") == 0 || ext.compare("m4a") == 0 || diff --git a/src/plugins/taglib_plugin/taglib_plugin.cpp b/src/plugins/taglib_plugin/taglib_plugin.cpp index 86e211970..3d09f4b82 100644 --- a/src/plugins/taglib_plugin/taglib_plugin.cpp +++ b/src/plugins/taglib_plugin/taglib_plugin.cpp @@ -52,11 +52,7 @@ class TaglibPlugin : public musik::core::sdk::IPlugin { public: virtual void Release() { delete this; } -#if defined(ENABLE_FFMPEG) || defined(WIN32) 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* Author() { return "Daniel Önnerby, clangen"; } virtual const char* Guid() { return "c77ea7a4-5d57-4f17-8521-aba8eeadeda7"; }