Skip to content

Commit e44ea88

Browse files
committed
Add CMake option to build without AudioMan
1 parent 2f6f4c3 commit e44ea88

6 files changed

Lines changed: 74 additions & 21 deletions

File tree

CMakeLists.txt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,13 @@ endif()
5454
set(3DMM_BRENDER_LIBRARY "${3DMM_BRENDER_LIBRARY_DEFAULT}" CACHE STRING "Argonaut BRender library to use for rendering 3D images")
5555
set_property(CACHE 3DMM_BRENDER_LIBRARY PROPERTY STRINGS "Original" "Source")
5656

57-
set(3DMM_AUDIOMAN_LIBRARY "Decompilation" CACHE STRING "AudioMan library to use for mixing wave sounds")
58-
set_property(CACHE 3DMM_AUDIOMAN_LIBRARY PROPERTY STRINGS "Original" "Decompilation")
57+
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
58+
# AudioMan is only supported on Windows
59+
set(3DMM_AUDIOMAN_LIBRARY "Decompilation" CACHE STRING "AudioMan library to use for mixing wave sounds")
60+
set_property(CACHE 3DMM_AUDIOMAN_LIBRARY PROPERTY STRINGS "Original" "Decompilation" "None")
61+
else()
62+
set(3DMM_AUDIOMAN_LIBRARY "None")
63+
endif()
5964

6065
# Default to Win32 on Windows, and SDL on other platforms.
6166
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
@@ -168,7 +173,7 @@ endif()
168173
if ("${3DMM_AUDIOMAN_LIBRARY}" STREQUAL "Original")
169174

170175
# Use original static library
171-
find_package(AudioMan)
176+
find_package(AudioMan REQUIRED)
172177

173178
elseif("${3DMM_AUDIOMAN_LIBRARY}" STREQUAL "Decompilation")
174179

@@ -184,10 +189,16 @@ elseif("${3DMM_AUDIOMAN_LIBRARY}" STREQUAL "Decompilation")
184189
FetchContent_MakeAvailable(AudioManDecomp)
185190
add_library(3DMMForever::AudioMan ALIAS AudioMan)
186191

192+
elseif("${3DMM_AUDIOMAN_LIBRARY}" STREQUAL "None")
193+
# No AudioMan
187194
else()
188195
message(FATAL_ERROR "Invalid AudioMan library selected: ${3DMM_AUDIOMAN_LIBRARY}")
189196
endif()
190197

198+
if (NOT "${3DMM_AUDIOMAN_LIBRARY}" STREQUAL "None")
199+
add_compile_definitions(HAS_AUDIOMAN)
200+
endif()
201+
191202
add_custom_target(tests)
192203

193204
add_subdirectory(kauai)

inc/srec.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
#ifndef SREC_H
1515
#define SREC_H
1616

17+
#ifdef HAS_AUDIOMAN
1718
#include "audioman.h"
19+
#endif // HAS_AUDIOMAN
1820

1921
/****************************************
2022
RIFF Header helper class
@@ -33,6 +35,8 @@
3335
#define FACT_TAG 'tcaf' // fact
3436
#endif
3537

38+
#ifdef KAUAI_WIN32
39+
3640
#pragma pack(push, _SOCPACK_)
3741
#pragma pack(1)
3842

@@ -79,6 +83,8 @@ class RIFF
7983
};
8084
#pragma pack(pop, _SOCPACK_)
8185

86+
#endif // KAUAI_WIN32
87+
8288
/****************************************
8389
The sound recording class
8490
****************************************/
@@ -105,9 +111,11 @@ class SREC : public SREC_PAR
105111
HWAVEIN _hwavein; // handle to wavein device
106112
WAVEHDR _wavehdr; // wave hdr for buffer
107113

114+
#if defined(HAS_AUDIOMAN)
108115
LPMIXER _pmixer; // pointer to Audioman Mixer
109116
LPCHANNEL _pchannel; // pointer to Audioman Channel
110117
LPSOUND _psnd; // psnd for current sound
118+
#endif // HAS_AUDIOMAN
111119
RIFF *_priff; // pointer to riff in memory
112120

113121
bool _FOpenRecord();

kauai/CMakeLists.txt

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -247,33 +247,47 @@ target_link_libraries(
247247
)
248248

249249
if (3DMM_GUI STREQUAL "Win32")
250-
# Win32: Use AudioMan for wave sounds and winmm MIDI player for music
250+
# Win32: Use AudioMan for wave sounds
251+
252+
if (NOT "${3DMM_AUDIOMAN_LIBRARY}" STREQUAL "None")
253+
target_sources(
254+
KauaiSound
255+
PRIVATE
256+
"${PROJECT_SOURCE_DIR}/kauai/src/sndam.cpp"
257+
)
258+
target_link_libraries(
259+
KauaiSound
260+
PUBLIC
261+
3DMMForever::AudioMan
262+
msacm32
263+
)
264+
if ("${3DMM_AUDIOMAN_LIBRARY}" STREQUAL "Original")
265+
# The static library requires a stub for some old MSVC floating-point division helper functions
266+
add_library(
267+
FDivStub
268+
"${PROJECT_SOURCE_DIR}/kauai/src/stub.cpp"
269+
)
270+
target_link_libraries(
271+
KauaiSound
272+
PRIVATE
273+
FDivStub
274+
)
275+
endif()
276+
endif()
277+
278+
# Use Win32 MIDI player
251279
target_sources(
252280
KauaiSound
253281
PRIVATE
254-
"${PROJECT_SOURCE_DIR}/kauai/src/sndam.cpp"
255282
"${PROJECT_SOURCE_DIR}/kauai/src/mididev.cpp"
256283
"${PROJECT_SOURCE_DIR}/kauai/src/mididev2.cpp"
257284
)
258285
target_link_libraries(
259286
KauaiSound
260287
PUBLIC
261-
3DMMForever::AudioMan
262-
msacm32
263288
winmm
264289
)
265-
if ("${3DMM_AUDIOMAN_LIBRARY}" STREQUAL "Original")
266-
# The static library requires a stub for some old MSVC floating-point division helper functions
267-
add_library(
268-
FDivStub
269-
"${PROJECT_SOURCE_DIR}/kauai/src/stub.cpp"
270-
)
271-
target_link_libraries(
272-
KauaiSound
273-
PRIVATE
274-
FDivStub
275-
)
276-
endif()
290+
277291
else()
278292
message(WARNING "Sound playback disabled")
279293
endif()

kauai/src/appb.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,11 +626,14 @@ bool APPB::_FInitSound(int32_t wav)
626626
return fTrue;
627627

628628
#if defined(KAUAI_WIN32)
629+
630+
#if defined(HAS_AUDIOMAN)
629631
if (pvNil != (psndv = SDAM::PsdamNew(wav)))
630632
{
631633
vpsndm->FAddDevice(kctgWave, psndv);
632634
ReleasePpo(&psndv);
633635
}
636+
#endif // HAS_AUDIOMAN
634637

635638
// create the midi playback device - use the stream one
636639
if (pvNil != (psndv = MDPS::PmdpsNew()))

src/CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ target_sources(engine
3939
"${PROJECT_SOURCE_DIR}/src/engine/tdt.cpp"
4040
"${PROJECT_SOURCE_DIR}/src/engine/tmpl.cpp"
4141
)
42-
if (3DMM_GUI STREQUAL "Win32")
42+
if (3DMM_GUI STREQUAL "Win32" AND NOT 3DMM_AUDIOMAN_LIBRARY STREQUAL "None")
4343
target_sources(engine
4444
PRIVATE
4545
"${PROJECT_SOURCE_DIR}/src/engine/srecwin.cpp"
@@ -60,8 +60,13 @@ target_link_libraries(engine
6060
KauaiDoc
6161
KauaiRichText
6262
bren
63-
3DMMForever::AudioMan # required for sound recorder
6463
)
64+
if (NOT "${3DMM_AUDIOMAN_LIBRARY}" STREQUAL "None")
65+
target_link_libraries(engine
66+
PUBLIC
67+
3DMMForever::AudioMan
68+
)
69+
endif()
6570

6671
# On non-windows WIN32 is a no-op
6772
add_executable(studio WIN32)
@@ -123,6 +128,7 @@ target_link_libraries(studio
123128

124129
$<$<PLATFORM_ID:Windows>:mpr> # Required for WNetGetUser()
125130
$<$<PLATFORM_ID:Windows>:vfw32> # Required for ICInfo in _wHaveICMCodec
131+
$<$<PLATFORM_ID:Windows>:msacm32> # Required for acmFormatTagDetailsA in _wHaveACMCodec
126132
)
127133

128134
set_property(TARGET studio PROPERTY OUTPUT_NAME 3dmovie)

src/engine/msnd.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
2424
***************************************************************************/
2525
#include "soc.h"
26+
27+
#ifdef HAS_AUDIOMAN
2628
#include "audioman.h"
29+
#endif // HAS_AUDIOMAN
2730

2831
ASSERTNAME
2932

@@ -303,6 +306,8 @@ bool MSND::FCopyWave(PFIL pfilSrc, PCFL pcflDest, int32_t sty, CNO *pcno, PSTN p
303306
Assert(sty != styMidi, "Illegal sty argument");
304307
AssertNilOrPo(pstn, 0);
305308

309+
#if defined(KAUAI_WIN32) && defined(HAS_AUDIOMAN)
310+
306311
FNI fniSrc;
307312
STN stnName; // sound name
308313
STN stn; // src file path name
@@ -566,6 +571,12 @@ bool MSND::FCopyWave(PFIL pfilSrc, PCFL pcflDest, int32_t sty, CNO *pcno, PSTN p
566571
if (tYes == fniNew.TExists())
567572
fniNew.FDelete();
568573
return fFalse;
574+
575+
#else
576+
// TODO: implement sound import without AudioMan
577+
RawRtn();
578+
return fFalse;
579+
#endif // KAUAI_WIN32 && HAS_AUDIOMAN
569580
}
570581

571582
/***************************************************************************

0 commit comments

Comments
 (0)