Skip to content

Commit b2e0e24

Browse files
committed
[CMAKE] Add OpenAL build option
1 parent 8a26398 commit b2e0e24

File tree

4 files changed

+33
-10
lines changed

4 files changed

+33
-10
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: 11 additions & 9 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,13 +39,13 @@ 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),
46-
m_sample(0),
48+
m_sample(0),
4749
m_3DSample(0),
4850
m_stream(0),
4951
m_framesFaded(0)
@@ -58,7 +60,7 @@ struct OpenAudioFile
5860
UnsignedInt m_fileSize;
5961

6062
Bool m_compressed; // if the file was compressed, then we need to free it with a miles function.
61-
63+
6264
// Note: OpenAudioFile does not own this m_eventInfo, and should not delete it.
6365
const AudioEventInfo *m_eventInfo; // Not mutable, unlike the one on AudioEventRTS.
6466
};
@@ -70,7 +72,7 @@ class MilesAudioFileCache
7072
{
7173
public:
7274
MilesAudioFileCache();
73-
75+
7476
// Protected by mutex
7577
virtual ~MilesAudioFileCache();
7678
void *openFile( AudioEventRTS *eventToOpenFrom );
@@ -89,7 +91,7 @@ class MilesAudioFileCache
8991

9092
// This function will return TRUE if it was able to free enough space, and FALSE otherwise.
9193
Bool freeEnoughSpaceForSample(const OpenAudioFile& sampleThatNeedsSpace);
92-
94+
9395
OpenFilesHash m_openFiles;
9496
UnsignedInt m_currentlyUsedSize;
9597
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)