Added option to control dynamic loading of OpenAL

Dynamic loading is enabled by default, set DYN_OPENAL to OFF to link with static or dynamic library

# Conflicts:
#	src/sound/oalsound.cpp
#	src/sound/oalsound.h
This commit is contained in:
alexey.lysiuk 2016-02-11 14:07:01 +02:00 committed by Christoph Oelckers
parent 243030046a
commit 5348a15b75
4 changed files with 36 additions and 21 deletions

View file

@ -28,6 +28,7 @@ if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
endif() endif()
option( DYN_FLUIDSYNTH "Dynamically load fluidsynth" ON ) option( DYN_FLUIDSYNTH "Dynamically load fluidsynth" ON )
option( DYN_OPENAL "Dynamically load OpenAL" ON )
if( APPLE ) if( APPLE )
option( OSX_COCOA_BACKEND "Use native Cocoa backend instead of SDL" ON ) option( OSX_COCOA_BACKEND "Use native Cocoa backend instead of SDL" ON )
@ -230,6 +231,16 @@ if( NOT NO_OPENAL )
mark_as_advanced(CLEAR OPENAL_INCLUDE_DIR) mark_as_advanced(CLEAR OPENAL_INCLUDE_DIR)
if( OPENAL_INCLUDE_DIR ) if( OPENAL_INCLUDE_DIR )
include_directories( ${OPENAL_INCLUDE_DIR} ) include_directories( ${OPENAL_INCLUDE_DIR} )
if( DYN_OPENAL )
add_definitions( -DDYN_OPENAL )
else()
mark_as_advanced(CLEAR OPENAL_LIBRARY)
if( OPENAL_LIBRARY )
set( ZDOOM_LIBS ${OPENAL_LIBRARY} ${ZDOOM_LIBS} )
else()
set( NO_OPENAL ON )
endif()
endif()
else() else()
set( NO_OPENAL ON ) set( NO_OPENAL ON )
endif() endif()

View file

@ -1,7 +1,7 @@
#ifndef OALDEF_H #ifndef OALDEF_H
#define OALDEF_H #define OALDEF_H
#ifndef NO_OPENAL #if !defined NO_OPENAL && defined DYN_OPENAL
#ifndef _WIN32 #ifndef _WIN32
typedef void* FARPROC; typedef void* FARPROC;

View file

@ -83,6 +83,8 @@ bool IsOpenALPresent()
{ {
#ifdef NO_OPENAL #ifdef NO_OPENAL
return false; return false;
#elif !defined DYN_OPENAL
return true;
#else #else
static bool cached_result = false; static bool cached_result = false;
static bool done = false; static bool done = false;

View file

@ -12,7 +12,9 @@
#ifndef NO_OPENAL #ifndef NO_OPENAL
#ifdef DYN_OPENAL
#define AL_NO_PROTOTYPES #define AL_NO_PROTOTYPES
#endif // DYN_OPENAL
#include "al.h" #include "al.h"
#include "alc.h" #include "alc.h"