From c503b1859c40595b593ef01987fbfd254423b9e9 Mon Sep 17 00:00:00 2001 From: kervala Date: Thu, 24 Feb 2011 18:01:31 +0100 Subject: [PATCH] Changed: #1251 NeL can't find selected drivers in CMake --- code/CMakeLists.txt | 4 +- code/CMakeModules/ConfigureChecks.cmake | 26 ++++++++++ code/config.h.cmake | 8 +++ code/nel/src/sound/driver/openal/ext_al.cpp | 5 +- code/nel/src/sound/driver/sound_driver.cpp | 57 +++++++++------------ 5 files changed, 61 insertions(+), 39 deletions(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index c7cac3e19..97dc2b7f7 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -86,9 +86,7 @@ NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS() NL_SETUP_PREFIX_PATHS() RYZOM_SETUP_PREFIX_PATHS() -IF(NOT WIN32) - NL_CONFIGURE_CHECKS() -ENDIF(NOT WIN32) +NL_CONFIGURE_CHECKS() #----------------------------------------------------------------------------- #Platform specifics diff --git a/code/CMakeModules/ConfigureChecks.cmake b/code/CMakeModules/ConfigureChecks.cmake index 4a0c76e1d..707b85c86 100644 --- a/code/CMakeModules/ConfigureChecks.cmake +++ b/code/CMakeModules/ConfigureChecks.cmake @@ -42,7 +42,33 @@ MACRO(NL_CONFIGURE_CHECKS) CHECK_FUNCTION_EXISTS("strtoull" HAVE_STRTOULL) CHECK_FUNCTION_EXISTS("statvfs" HAVE_STATVFS) CHECK_FUNCTION_EXISTS("stat64" HAVE_STAT64) + + # 3D drivers + IF(WITH_DRIVER_OPENGL) + SET(NL_OPENGL_AVAILABLE 1) + ENDIF(WITH_DRIVER_OPENGL) + IF(WITH_DRIVER_DIRECT3D) + SET(NL_DIRECT3D_AVAILABLE 1) + ENDIF(WITH_DRIVER_DIRECT3D) + + # sound drivers + IF(WITH_DRIVER_FMOD) + SET(NL_FMOD_AVAILABLE 1) + ENDIF(WITH_DRIVER_FMOD) + + IF(WITH_DRIVER_OPENAL) + SET(NL_OPENAL_AVAILABLE 1) + ENDIF(WITH_DRIVER_OPENAL) + + IF(WITH_DRIVER_DSOUND) + SET(NL_DSOUND_AVAILABLE 1) + ENDIF(WITH_DRIVER_DSOUND) + + IF(WITH_DRIVER_XAUDIO2) + SET(NL_XAUDIO2_AVAILABLE 1) + ENDIF(WITH_DRIVER_XAUDIO2) + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) ADD_DEFINITIONS(-DHAVE_CONFIG_H) diff --git a/code/config.h.cmake b/code/config.h.cmake index 0bdb9ad73..a2f65aa41 100644 --- a/code/config.h.cmake +++ b/code/config.h.cmake @@ -34,6 +34,14 @@ #cmakedefine HAVE_STATVFS 1 #cmakedefine HAVE_STAT64 1 +#cmakedefine NL_OPENGL_AVAILABLE ${NL_OPENGL_AVAILABLE} +#cmakedefine NL_DIRECT3D_AVAILABLE ${NL_DIRECT3D_AVAILABLE} + +#cmakedefine NL_FMOD_AVAILABLE ${NL_FMOD_AVAILABLE} +#cmakedefine NL_OPENAL_AVAILABLE ${NL_OPENAL_AVAILABLE} +#cmakedefine NL_DSOUND_AVAILABLE ${NL_DSOUND_AVAILABLE} +#cmakedefine NL_XAUDIO2_AVAILABLE ${NL_XAUDIO2_AVAILABLE} + #cmakedefine NL_BIN_PREFIX "${NL_BIN_PREFIX}" #cmakedefine NL_ETC_PREFIX "${NL_ETC_PREFIX}" #cmakedefine NL_SHARE_PREFIX "${NL_SHARE_PREFIX}" diff --git a/code/nel/src/sound/driver/openal/ext_al.cpp b/code/nel/src/sound/driver/openal/ext_al.cpp index 0c6690eb1..34763df8e 100644 --- a/code/nel/src/sound/driver/openal/ext_al.cpp +++ b/code/nel/src/sound/driver/openal/ext_al.cpp @@ -66,7 +66,8 @@ void alExtInitDevice(ALCdevice *device) } } -#if !defined(NL_STATIC) || defined(NL_OS_MAC) +// Windows and Mac OS always link to shared OpenAL library +#if defined(NL_OS_WINDOWS) || defined(NL_OS_MAC) || !defined(NL_STATIC) // EFX if ((AlExtEfx = (alcIsExtensionPresent(device, "ALC_EXT_EFX") == ALC_TRUE)) == true) { @@ -136,7 +137,7 @@ EAXGetBufferMode eaxGetBufferMode = NULL; // ALC_EXT_EFX bool AlExtEfx = false; // effect objects -#if !defined(NL_STATIC) || defined(NL_OS_MAC) +#if defined(NL_OS_WINDOWS) || defined(NL_OS_MAC) || !defined(NL_STATIC) LPALGENEFXOBJECTS alGenEffects = NULL; LPALDELETEEFXOBJECTS alDeleteEffects = NULL; LPALISEFXOBJECT alIsEffect = NULL; diff --git a/code/nel/src/sound/driver/sound_driver.cpp b/code/nel/src/sound/driver/sound_driver.cpp index f18488779..e8aecdf53 100644 --- a/code/nel/src/sound/driver/sound_driver.cpp +++ b/code/nel/src/sound/driver/sound_driver.cpp @@ -20,6 +20,17 @@ #ifdef HAVE_CONFIG_H # include "config.h" +#elif defined(NL_STATIC) +// Driver availability for NL_STATIC compilation. +# undef NL_FMOD_AVAILABLE +# undef NL_OPENAL_AVAILABLE +# undef NL_DSOUND_AVAILABLE +# undef NL_XAUDIO2_AVAILABLE +# if defined( NL_OS_WINDOWS ) +# define NL_FMOD_AVAILABLE +# else +# define NL_OPENAL_AVAILABLE +# endif #endif // HAVE_CONFIG_H #ifdef NL_OS_WINDOWS @@ -34,28 +45,6 @@ using namespace NLMISC; -// Driver availability for NL_STATIC compilation. -#if defined( NL_OS_WINDOWS ) -# define NL_FMOD_AVAILABLE 1 -# define NL_OPENAL_AVAILABLE 0 -# define NL_DSOUND_AVAILABLE 0 -# define NL_XAUDIO2_AVAILABLE 0 -#elif defined( NL_OS_UNIX ) -#ifdef NL_STATIC -# define NL_FMOD_AVAILABLE 0 -#else -# define NL_FMOD_AVAILABLE 1 -#endif -# define NL_OPENAL_AVAILABLE 1 -# define NL_DSOUND_AVAILABLE 0 -# define NL_XAUDIO2_AVAILABLE 0 -#else -# define NL_FMOD_AVAILABLE 0 -# define NL_OPENAL_AVAILABLE 0 -# define NL_DSOUND_AVAILABLE 0 -# define NL_XAUDIO2_AVAILABLE 0 -#endif - namespace NLSOUND { @@ -72,16 +61,16 @@ const uint32 ISoundDriver::InterfaceVersion = 0x16; // Kaetemi extern void outputProfile##__soundDriver(std::string &out); \ extern ISoundDriver::TDriver getDriverType##__soundDriver(); -#if NL_FMOD_AVAILABLE +#ifdef NL_FMOD_AVAILABLE NLSOUND_DECLARE_DRIVER(FMod) #endif -#if NL_OPENAL_AVAILABLE +#ifdef NL_OPENAL_AVAILABLE NLSOUND_DECLARE_DRIVER(OpenAl) #endif -#if NL_DSOUND_AVAILABLE +#ifdef NL_DSOUND_AVAILABLE NLSOUND_DECLARE_DRIVER(DSound) #endif -#if NL_XAUDIO2_AVAILABLE +#ifdef NL_XAUDIO2_AVAILABLE NLSOUND_DECLARE_DRIVER(XAudio2) #endif @@ -122,26 +111,26 @@ ISoundDriver *ISoundDriver::createDriver(IStringMapperProvider *stringMapper, TD switch (driverType) { // switch between available drivers -# if NL_FMOD_AVAILABLE +# ifdef NL_FMOD_AVAILABLE case DriverFMod: result = createISoundDriverInstanceFMod(stringMapper); break; # endif -# if NL_OPENAL_AVAILABLE +# ifdef NL_OPENAL_AVAILABLE case DriverOpenAl: result = createISoundDriverInstanceOpenAl(stringMapper); break; # endif -# if NL_DSOUND_AVAILABLE +# ifdef NL_DSOUND_AVAILABLE case DriverDSound: result = createISoundDriverInstanceDSound(stringMapper); break; # endif -# if NL_XAUDIO2_AVAILABLE +# ifdef NL_XAUDIO2_AVAILABLE case DriverXAudio2: result = createISoundDriverInstanceXAudio2(stringMapper); break; # endif // auto driver = first available in this order: FMod, OpenAl, XAudio2, DSound -# if NL_FMOD_AVAILABLE +# if defined(NL_FMOD_AVAILABLE) case DriverAuto: result = createISoundDriverInstanceFMod(stringMapper); break; -# elif NL_OPENAL_AVAILABLE +# elif defined(NL_OPENAL_AVAILABLE) case DriverAuto: result = createISoundDriverInstanceOpenAl(stringMapper); break; -# elif NL_XAUDIO2_AVAILABLE +# elif defined(NL_XAUDIO2_AVAILABLE) case DriverAuto: result = createISoundDriverInstanceXAudio2(stringMapper); break; -# elif NL_DSOUND_AVAILABLE +# elif defined(NL_DSOUND_AVAILABLE) case DriverAuto: result = createISoundDriverInstanceDSound(stringMapper); break; # endif // unavailable driver = FAIL