Skip to content

Commit

Permalink
Compile faudio statically
Browse files Browse the repository at this point in the history
  • Loading branch information
N00byKing committed Mar 11, 2022
1 parent dced612 commit b1d3c4b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
23 changes: 19 additions & 4 deletions desktop_version/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ if(BUNDLE_DEPENDENCIES)
../third_party/FAudio/include
../third_party/stb_vorbis
)
add_subdirectory(../third_party/FAudio faudioout)
else()
target_include_directories(
VVVVVV PRIVATE
Expand All @@ -174,6 +173,14 @@ endif()
set(XML2_SRC
../third_party/tinyxml2/tinyxml2.cpp
)
set(FAUDIO_SRC
../third_party/FAudio/src/FAPOBase.c
../third_party/FAudio/src/FAudio.c
../third_party/FAudio/src/FAudio_internal.c
../third_party/FAudio/src/FAudio_internal_simd.c
../third_party/FAudio/src/FAudio_operationset.c
../third_party/FAudio/src/FAudio_platform_sdl2.c
)
set(PFS_SRC
../third_party/physfs/physfs.c
../third_party/physfs/physfs_archiver_dir.c
Expand Down Expand Up @@ -290,6 +297,7 @@ target_compile_definitions(lodepng-static PRIVATE
-DLODEPNG_NO_COMPILE_ENCODER
)

add_library(faudio-static STATIC ${FAUDIO_SRC})
if(BUNDLE_DEPENDENCIES)
add_library(tinyxml2-static STATIC ${XML2_SRC})
add_library(physfs-static STATIC ${PFS_SRC})
Expand All @@ -303,7 +311,7 @@ if(BUNDLE_DEPENDENCIES)
set_property(TARGET physfs-static PROPERTY C_EXTENSIONS ON)
endif()

target_link_libraries(VVVVVV physfs-static tinyxml2-static lodepng-static FAudio)
target_link_libraries(VVVVVV physfs-static tinyxml2-static lodepng-static faudio-static)
else()
find_package(utf8cpp CONFIG)

Expand All @@ -315,23 +323,30 @@ if(DEFINED SDL2_INCLUDE_DIRS AND DEFINED SDL2_LIBRARIES)
message(STATUS "Using pre-defined SDL2 variables SDL2_INCLUDE_DIRS and SDL2_LIBRARIES")
target_include_directories(VVVVVV SYSTEM PRIVATE "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
target_link_libraries(VVVVVV ${SDL2_LIBRARIES})
target_link_libraries(faudio-static ${SDL2_LIBRARIES})
elseif (EMSCRIPTEN)
message(STATUS "Using Emscripten SDL2")
target_compile_options(VVVVVV PUBLIC -sUSE_SDL=2 -sUSE_SDL_MIXER=2)
target_link_libraries(VVVVVV -sUSE_SDL=2 -sUSE_SDL_MIXER=2)
target_compile_options(VVVVVV PUBLIC -sUSE_SDL=2)
target_link_libraries(VVVVVV -sUSE_SDL=2)
target_compile_options(faudio-static PUBLIC -sUSE_SDL=2)
target_link_libraries(faudio-static -sUSE_SDL=2)
else()
# Only try to autodetect if both SDL2 variables aren't explicitly set
find_package(SDL2 CONFIG)
if(TARGET SDL2::SDL2)
message(STATUS "Using TARGET SDL2::SDL2")
target_link_libraries(VVVVVV SDL2::SDL2)
target_link_libraries(faudio-static SDL2::SDL2)
elseif(TARGET SDL2)
message(STATUS "Using TARGET SDL2")
target_link_libraries(VVVVVV SDL2)
target_link_libraries(faudio-static SDL2)
else()
message(STATUS "No TARGET SDL2::SDL2, or SDL2, using variables")
target_include_directories(VVVVVV SYSTEM PRIVATE "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
target_link_libraries(VVVVVV ${SDL2_LIBRARIES})
target_include_directories(faudio-static SYSTEM PRIVATE "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
target_link_libraries(faudio-static ${SDL2_LIBRARIES})
endif()
endif()

Expand Down
5 changes: 0 additions & 5 deletions desktop_version/src/Music.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#include "UtilityClass.h"
#include "Vlogging.h"

/* Begin SDL_mixer wrapper */

#include <vector>

#define VVV_MAX_VOLUME 128
Expand Down Expand Up @@ -138,7 +136,6 @@ class SoundTrack

static FAudioMasteringVoice* masteringvoice;
};

FAudioMasteringVoice* SoundTrack::masteringvoice;

class MusicTrack
Expand Down Expand Up @@ -284,8 +281,6 @@ class MusicTrack
};
FAudioSourceVoice* MusicTrack::musicVoice = NULL;

/* End SDL_mixer wrapper */

musicclass::musicclass(void)
{
SoundTrack::Init(44100, 2);
Expand Down

0 comments on commit b1d3c4b

Please sign in to comment.