Skip to content

Commit 1e49b2b

Browse files
committed
[CMAKE] Add OpenAL build option
1 parent bc54f1b commit 1e49b2b

File tree

4 files changed

+32
-9
lines changed

4 files changed

+32
-9
lines changed

GeneralsMD/Code/GameEngineDevice/CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,4 +247,22 @@ if(RTS_BUILD_OPTION_FFMPEG)
247247
target_link_libraries(z_gameenginedevice PRIVATE ${FFMPEG_LIBRARIES})
248248
target_compile_definitions(z_gameenginedevice PUBLIC RTS_HAS_FFMPEG)
249249
endif()
250+
endif()
251+
252+
if(RTS_BUILD_OPTION_OPENAL)
253+
find_package(OpenAL CONFIG REQUIRED)
254+
255+
if(OpenAL_FOUND)
256+
#target_sources(z_gameenginedevice PRIVATE
257+
# Include/OpenALDevice/OpenALAudioManager.h
258+
# Include/OpenALDevice/OpenALAudioStream.h
259+
# Source/OpenALDevice/OpenALAudioCache.h
260+
# Source/OpenALDevice/OpenALAudioCache.cpp
261+
# Source/OpenALDevice/OpenALAudioManager.cpp
262+
# Source/OpenALDevice/OpenALAudioStream.cpp
263+
#)
264+
265+
target_link_libraries(z_gameenginedevice PRIVATE OpenAL::OpenAL)
266+
target_compile_definitions(z_gameenginedevice PUBLIC RTS_HAS_OPENAL)
267+
endif()
250268
endif()

GeneralsMD/Code/GameEngineDevice/Source/MilesAudioDevice/MilesAudioFileCache.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
// FILE: MilesAudioFileCache.h //////////////////////////////////////////////////////////////////////////
2020
// MilesAudioManager implementation
2121
// Author: John K. McDonald, July 2002
22+
#pragma once
23+
2224
#include "MilesAudioDevice/MilesAudioManager.h"
2325

2426
struct PlayingAudio
@@ -37,11 +39,11 @@ struct PlayingAudio
3739
Bool m_requestStop;
3840
Bool m_cleanupAudioEventRTS;
3941
Int m_framesFaded;
40-
41-
PlayingAudio() :
42-
m_type(PAT_INVALID),
43-
m_audioEventRTS(NULL),
44-
m_requestStop(false),
42+
43+
PlayingAudio() :
44+
m_type(PAT_INVALID),
45+
m_audioEventRTS(NULL),
46+
m_requestStop(false),
4547
m_cleanupAudioEventRTS(true),
4648
m_sample(NULL),
4749
m_framesFaded(0)
@@ -56,7 +58,7 @@ struct OpenAudioFile
5658
UnsignedInt m_fileSize;
5759

5860
Bool m_compressed; // if the file was compressed, then we need to free it with a miles function.
59-
61+
6062
// Note: OpenAudioFile does not own this m_eventInfo, and should not delete it.
6163
const AudioEventInfo *m_eventInfo; // Not mutable, unlike the one on AudioEventRTS.
6264
};
@@ -68,7 +70,7 @@ class MilesAudioFileCache
6870
{
6971
public:
7072
MilesAudioFileCache();
71-
73+
7274
// Protected by mutex
7375
virtual ~MilesAudioFileCache();
7476
void *openFile( AudioEventRTS *eventToOpenFrom );
@@ -87,7 +89,7 @@ class MilesAudioFileCache
8789

8890
// This function will return TRUE if it was able to free enough space, and FALSE otherwise.
8991
Bool freeEnoughSpaceForSample(const OpenAudioFile& sampleThatNeedsSpace);
90-
92+
9193
OpenFilesHash m_openFiles;
9294
UnsignedInt m_currentlyUsedSize;
9395
UnsignedInt m_maxSize;

cmake/config-build.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ option(RTS_BUILD_OPTION_PROFILE "Build code with the \"Profile\" configuration."
88
option(RTS_BUILD_OPTION_DEBUG "Build code with the \"Debug\" configuration." OFF)
99
option(RTS_BUILD_OPTION_ASAN "Build code with Address Sanitizer." OFF)
1010
option(RTS_BUILD_OPTION_FFMPEG "Enable FFmpeg support" OFF)
11+
option(RTS_BUILD_OPTION_OPENAL "Enable OpenAL support" OFF)
1112

1213
if(NOT RTS_BUILD_ZEROHOUR AND NOT RTS_BUILD_GENERALS)
1314
set(RTS_BUILD_ZEROHOUR TRUE)
@@ -23,6 +24,7 @@ add_feature_info(ProfileBuild RTS_BUILD_OPTION_PROFILE "Building as a \"Profile\
2324
add_feature_info(DebugBuild RTS_BUILD_OPTION_DEBUG "Building as a \"Debug\" build")
2425
add_feature_info(AddressSanitizer RTS_BUILD_OPTION_ASAN "Building with address sanitizer")
2526
add_feature_info(FFmpegSupport RTS_BUILD_OPTION_FFMPEG "Building with FFmpeg support")
27+
add_feature_info(OpenALSupport RTS_BUILD_OPTION_OPENAL "Building with OpenAL support")
2628

2729
if(RTS_BUILD_ZEROHOUR)
2830
option(RTS_BUILD_ZEROHOUR_TOOLS "Build tools for Zero Hour" ON)

vcpkg.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"builtin-baseline": "b02e341c927f16d991edbd915d8ea43eac52096c",
44
"dependencies": [
55
"zlib",
6-
"ffmpeg"
6+
"ffmpeg",
7+
"openal-soft"
78
]
89
}

0 commit comments

Comments
 (0)