diff --git a/CMakeLists.txt b/CMakeLists.txt index df92046e..36d8dc14 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,8 @@ if(WIN32) set(WTL_INCLUDE_PATH CACHE PATH "Path to WTL include directory") option(BUILD_WINAMP "Build Winamp plugin" ON) option(BUILD_XMPLAY "Build XMPlay plugin" ON) +else() + option(BUILD_AUDACIOUS "Build Audacious plugin" ON) endif() if(WIN32) @@ -95,6 +97,13 @@ else() set(USE_FFMPEG FALSE) endif() endif() + + # If building Audacious, we need to make sure we can find its pkg-config module as well as GTK's + if(BUILD_AUDACIOUS) + include(FindPkgConfig) + pkg_search_module(AUDACIOUS REQUIRED audacious>=3.6) + pkg_search_module(GTK REQUIRED gtk+-3.0 gtk+-2.0) + endif() endif() # Set compiler flags @@ -178,6 +187,10 @@ if(WIN32) if(BUILD_XMPLAY) add_subdirectory(xmplay) endif() +else() + if(BUILD_AUDACIOUS) + add_subdirectory(audacious) + endif() endif() if(BUILD_CLI) if(WIN32) @@ -210,5 +223,7 @@ if(WIN32) message(STATUS "foobar2000 component: ${BUILD_FB2K}") message(STATUS " Winamp plugin: ${BUILD_WINAMP}") message(STATUS " XMPlay plugin: ${BUILD_XMPLAY}") +else() + message(STATUS " Audacious plugin: ${BUILD_AUDACIOUS}") endif() message(STATUS "") diff --git a/audacious/CMakeLists.txt b/audacious/CMakeLists.txt new file mode 100644 index 00000000..041ab877 --- /dev/null +++ b/audacious/CMakeLists.txt @@ -0,0 +1,67 @@ +add_library(audacious_vgmstream SHARED + plugin.h + vfs.h + plugin.cc + vfs.cc) + +setup_target(audacious_vgmstream TRUE) + +# Remove the prefix and set output name +set_target_properties(audacious_vgmstream PROPERTIES + PREFIX "" + OUTPUT_NAME "vgmstream") + +macro(extract_defines CFLAGS CFLAGS_COPY) + set(${CFLAGS_COPY} ${${CFLAGS}}) + if(${CFLAGS_COPY}) + list(FILTER ${CFLAGS_COPY} INCLUDE REGEX "^-D.*") + endif() +endmacro() + +macro(extract_non_defines CFLAGS CFLAGS_COPY) + set(${CFLAGS_COPY} ${${CFLAGS}}) + if(${CFLAGS_COPY}) + list(FILTER ${CFLAGS_COPY} EXCLUDE REGEX "^-D.*") + endif() +endmacro() + +extract_defines(AUDACIOUS_CFLAGS_OTHER AUDACIOUS_DEFINES) +extract_defines(GTK_CFLAGS_OTHER GTK_DEFINES) +extract_non_defines(AUDACIOUS_CFLAGS_OTHER AUDACIOUS_CFLAGS_OTHER) +extract_non_defines(GTK_CFLAGS_OTHER GTK_CFLAGS_OTHER) + +# Include compile definitions for Audacious and GTK, as well as the version string +target_compile_definitions(audacious_vgmstream PRIVATE + ${AUDACIOUS_DEFINES} + ${GTK_DEFINES} + VERSION="${VGMSTREAM_VERSION}") + +# Include compile flags for Audacious and GTK +set_target_properties(audacious_vgmstream PROPERTIES + COMPILE_FLAGS "${AUDACIOUS_CFLAGS_OTHER} ${GTK_CFLAGS_OTHER}") + +# Make sure that the binary directory is included (for version.h) as well as the Audacious and GTK include directories +target_include_directories(audacious_vgmstream PRIVATE + ${CMAKE_BINARY_DIR} + ${AUDACIOUS_INCLUDE_DIRS} + ${GTK_INCLUDE_DIRS}) + +# Link to the vgmstream library and audacious library +target_link_libraries(audacious_vgmstream + libvgmstream + ${AUDACIOUS_LINK_LIBRARIES} + ${GTK_LINK_LIBRARIES}) + +# Make sure that whatever compiler we use can handle these features +target_compile_features(audacious_vgmstream PRIVATE + cxx_auto_type + cxx_constexpr + cxx_decltype + cxx_defaulted_move_initializers + cxx_deleted_functions + cxx_nullptr + cxx_rvalue_references + cxx_static_assert + cxx_strong_enums + cxx_variadic_macros + cxx_variadic_templates) diff --git a/audacious/plugin.cc b/audacious/plugin.cc index aedd7b73..c40d69af 100644 --- a/audacious/plugin.cc +++ b/audacious/plugin.cc @@ -22,7 +22,7 @@ extern "C" { #ifndef VERSION -#include "../version.h" +#include "version.h" #endif #ifndef VERSION #define VERSION "(unknown version)" diff --git a/audacious/plugin.h b/audacious/plugin.h index acc6a3fb..14e2a76a 100644 --- a/audacious/plugin.h +++ b/audacious/plugin.h @@ -24,7 +24,7 @@ public: //constexpr VgmstreamPlugin() : InputPlugin(info, iinfo) {} //constexpr VgmstreamPlugin() : InputPlugin (info, InputInfo().with_exts(exts)) {} - constexpr VgmstreamPlugin() : InputPlugin (info, NULL) {} + constexpr VgmstreamPlugin() : InputPlugin (info, InputInfo()) {} bool init(); void cleanup(); diff --git a/audacious/vfs.cc b/audacious/vfs.cc index ec2206fa..c5ebc59b 100644 --- a/audacious/vfs.cc +++ b/audacious/vfs.cc @@ -70,12 +70,12 @@ STREAMFILE *open_vfs_by_VFSFILE(VFSFile *file, const char *path) { // success, set our pointers memset(streamfile, 0, sizeof(VFSSTREAMFILE)); - streamfile->sf.read = read_vfs; - streamfile->sf.get_size = get_size_vfs; - streamfile->sf.get_offset = get_offset_vfs; - streamfile->sf.get_name = get_name_vfs; - streamfile->sf.open = open_vfs_impl; - streamfile->sf.close = close_vfs; + streamfile->sf.read = (size_t (*)(STREAMFILE *, uint8_t *, off_t, size_t))read_vfs; + streamfile->sf.get_size = (size_t (*)(STREAMFILE *))get_size_vfs; + streamfile->sf.get_offset = (off_t (*)(STREAMFILE *))get_offset_vfs; + streamfile->sf.get_name = (void (*)(STREAMFILE *, char *, size_t))get_name_vfs; + streamfile->sf.open = (STREAMFILE *(*)(STREAMFILE *, const char *, size_t))open_vfs_impl; + streamfile->sf.close = (void (*)(STREAMFILE *))close_vfs; streamfile->vfsFile = file; streamfile->offset = 0; diff --git a/cmake/fdk-aac.cmake b/cmake/fdk-aac.cmake index ea91ede1..2c75f1d7 100644 --- a/cmake/fdk-aac.cmake +++ b/cmake/fdk-aac.cmake @@ -77,3 +77,7 @@ target_include_directories(fdk-aac PRIVATE # Make sure that whatever compiler we use can handle these features target_compile_features(fdk-aac PRIVATE cxx_long_long_type) + +# Set up position-independent code +set_target_properties(fdk-aac PROPERTIES + POSITION_INDEPENDENT_CODE TRUE) diff --git a/cmake/mp4v2.cmake b/cmake/mp4v2.cmake index 8dde5228..4dd5dddd 100644 --- a/cmake/mp4v2.cmake +++ b/cmake/mp4v2.cmake @@ -109,3 +109,7 @@ target_include_directories(mp4v2 PRIVATE target_compile_features(mp4v2 PRIVATE cxx_long_long_type cxx_variadic_macros) + +# Set up position-independent code +set_target_properties(mp4v2 PROPERTIES + POSITION_INDEPENDENT_CODE TRUE) diff --git a/cmake/vgmstream.cmake b/cmake/vgmstream.cmake index a3419268..4f0d70c8 100644 --- a/cmake/vgmstream.cmake +++ b/cmake/vgmstream.cmake @@ -17,6 +17,9 @@ macro(setup_target TARGET) else() target_include_directories(${TARGET} PRIVATE AFTER ${CMAKE_SOURCE_DIR}/ext_includes) endif() + # Set up position-independent code for all targets + set_target_properties(${TARGET} PROPERTIES + POSITION_INDEPENDENT_CODE TRUE) if(USE_FDKAAC) target_compile_definitions(${TARGET} PRIVATE diff --git a/ext_libs/Getopt/CMakeLists.txt b/ext_libs/Getopt/CMakeLists.txt index 820026b3..95f65f37 100644 --- a/ext_libs/Getopt/CMakeLists.txt +++ b/ext_libs/Getopt/CMakeLists.txt @@ -1,4 +1,3 @@ -set(SOURCES +add_library(getopt STATIC + getopt.h getopt.c) - -add_library(getopt STATIC ${SOURCES}) diff --git a/fb2k/CMakeLists.txt b/fb2k/CMakeLists.txt index d91207c6..619f6951 100644 --- a/fb2k/CMakeLists.txt +++ b/fb2k/CMakeLists.txt @@ -54,7 +54,9 @@ add_dependencies(foo_input_vgmstream target_compile_features(foo_input_vgmstream PRIVATE cxx_auto_type cxx_nullptr - cxx_static_assert) + cxx_rvalue_references + cxx_static_assert + cxx_variadic_templates) # Include the version string if(MSVC)