Skip to content
Browse files

clean up of linux build system and add ability to disable ALUT linking

- Not enabling ALUT will disable the WAV file loading.
  • Loading branch information...
1 parent 875c5a1 commit 0fc3696d218e5a9995dffbaa7d28a797b7503735 @urkle urkle committed Nov 28, 2011
View
62 CMakeLists.txt
@@ -4,13 +4,67 @@ project (OALWrapper)
set(OALWrapper_VERSION_MAJOR 1)
set(OALWrapper_VERSION_MINOR 0)
+SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeScripts)
+
+OPTION(WITH_ALUT "Include alut WAVE loading" OFF)
+
+FIND_PACKAGE(OGG)
+FIND_PACKAGE(Vorbis)
+FIND_PACKAGE(VorbisFile)
+FIND_PACKAGE(OpenAL)
+
+IF(WITH_ALUT)
+ FIND_PACKAGE(ALUT)
+ ADD_DEFINITIONS(-DWITH_ALUT)
+ENDIF()
+
include_directories(
- ${CMAKE_CURRENT_SOURCE_DIR}/include
- ${CMAKE_CURRENT_SOURCE_DIR}/../dependencies/include
+ include
)
-file(GLOB_RECURSE all_sources
- ${CMAKE_CURRENT_SOURCE_DIR}/sources/*.cpp
+SET(all_sources
+ sources/OAL_AudioData.cpp
+ sources/OAL_Buffer.cpp
+ sources/OAL_Device.cpp
+ sources/OAL_Effect.cpp
+ sources/OAL_Effect_Reverb.cpp
+ sources/OAL_EffectSlot.cpp
+ sources/OAL_EFX.cpp
+ sources/OAL_EFXManager.cpp
+ sources/OAL_Filter.cpp
+ sources/OAL_Helper.cpp
+ sources/OAL_Init.cpp
+ sources/OAL_Loaders.cpp
+ sources/OAL_LoggerObject.cpp
+ sources/OAL_OggHelper.cpp
+ sources/OAL_OggSample.cpp
+ sources/OAL_OggStream.cpp
+ sources/OAL_Playback.cpp
+ sources/OAL_Sample.cpp
+ sources/OAL_Source.cpp
+ sources/OAL_SourceManager.cpp
+ sources/OAL_Stream.cpp
+ sources/OAL_Types.cpp
)
+IF(WITH_ALUT)
+ LIST(APPEND all_sources
+ sources/OAL_WAVSample.cpp
+ )
+ENDIF()
+
add_library(OALWrapper STATIC ${all_sources})
+TARGET_LINK_LIBRARIES(OALWrapper
+ ${OGG_LIBRARY}
+ ${VORBIS_LIBRARY}
+ ${VORBISFILE_LIBRARY}
+ ${ALUT_LIBRARY}
+ ${OPENAL_LIBRARY}
+ SDL
+)
+ADD_EXECUTABLE(SimpleTest
+ tests/Simple/main.cpp
+)
+TARGET_LINK_LIBRARIES(SimpleTest
+ OALWrapper
+)
View
78 CMakeScripts/FindALUT.cmake
@@ -0,0 +1,78 @@
+# Locate ALUT
+# This module defines XXX_FOUND, XXX_INCLUDE_DIRS and XXX_LIBRARIES standard variables
+#
+# $ALUTDIR is an environment variable that would
+# correspond to the ./configure --prefix=$ALUTDIR
+# used in building ALUT.
+#
+# Created by Sukender (Benoit Neil). Based on FindOpenAL.cmake module.
+
+IF(ALUT_USE_AL_SUBDIR)
+ SET(ALUT_HEADER_NAMES "AL/alut.h")
+ SET(ALUT_HEADER_SUFFIXES include)
+ELSE()
+ SET(ALUT_HEADER_NAMES "alut.h")
+ SET(ALUT_HEADER_SUFFIXES include/AL include/OpenAL include)
+ENDIF()
+
+SET(ALUT_SEARCH_PATHS
+ ~/Library/Frameworks
+ /Library/Frameworks
+ /usr/local
+ /usr
+ /sw # Fink
+ /opt/local # DarwinPorts
+ /opt/csw # Blastwave
+ /opt
+)
+
+FIND_PATH(ALUT_INCLUDE_DIR NAMES ${ALUT_HEADER_NAMES}
+ HINTS
+ $ENV{ALUTDIR}
+ $ENV{ALUT_PATH}
+ PATH_SUFFIXES ${ALUT_HEADER_SUFFIXES}
+ PATHS ${ALUT_SEARCH_PATHS}
+)
+
+FIND_LIBRARY(ALUT_LIBRARY
+ NAMES alut libalut
+ HINTS
+ $ENV{ALUTDIR}
+ $ENV{ALUT_PATH}
+ PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64 Release
+ PATHS ${ALUT_SEARCH_PATHS}
+)
+
+# First search for d-suffixed libs
+FIND_LIBRARY(ALUT_LIBRARY_DEBUG
+ NAMES alutd libalutd
+ HINTS
+ $ENV{ALUTDIR}
+ $ENV{ALUT_PATH}
+ PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64 Debug
+ PATHS ${ALUT_SEARCH_PATHS}
+)
+
+IF(NOT ALUT_LIBRARY_DEBUG)
+ # Then search for non suffixed libs if necessary, but only in debug dirs
+ FIND_LIBRARY(ALUT_LIBRARY_DEBUG
+ NAMES alut libalut
+ HINTS
+ $ENV{ALUTDIR}
+ $ENV{ALUT_PATH}
+ PATH_SUFFIXES Debug
+ PATHS ${ALUT_SEARCH_PATHS}
+ )
+ENDIF()
+
+IF(ALUT_LIBRARY)
+ IF(ALUT_LIBRARY_DEBUG)
+ SET(ALUT_LIBRARIES optimized "${ALUT_LIBRARY}" debug "${ALUT_LIBRARY_DEBUG}")
+ ELSE()
+ SET(ALUT_LIBRARIES "${ALUT_LIBRARY}") # Could add "general" keyword, but it is optional
+ ENDIF()
+ENDIF()
+
+# handle the QUIETLY and REQUIRED arguments and set XXX_FOUND to TRUE if all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(ALUT DEFAULT_MSG ALUT_LIBRARIES ALUT_INCLUDE_DIR)
View
75 CMakeScripts/FindOGG.cmake
@@ -0,0 +1,75 @@
+# Locate OGG
+# This module defines XXX_FOUND, XXX_INCLUDE_DIRS and XXX_LIBRARIES standard variables
+#
+# $OGGDIR is an environment variable that would
+# correspond to the ./configure --prefix=$OGGDIR
+# used in building OGG.
+
+SET(OGG_SEARCH_PATHS
+ ~/Library/Frameworks
+ /Library/Frameworks
+ /usr/local
+ /usr
+ /sw # Fink
+ /opt/local # DarwinPorts
+ /opt/csw # Blastwave
+ /opt
+)
+
+SET(MSVC_YEAR_NAME)
+IF (MSVC_VERSION GREATER 1599) # >= 1600
+ SET(MSVC_YEAR_NAME VS2010)
+ELSEIF(MSVC_VERSION GREATER 1499) # >= 1500
+ SET(MSVC_YEAR_NAME VS2008)
+ELSEIF(MSVC_VERSION GREATER 1399) # >= 1400
+ SET(MSVC_YEAR_NAME VS2005)
+ELSEIF(MSVC_VERSION GREATER 1299) # >= 1300
+ SET(MSVC_YEAR_NAME VS2003)
+ELSEIF(MSVC_VERSION GREATER 1199) # >= 1200
+ SET(MSVC_YEAR_NAME VS6)
+ENDIF()
+
+FIND_PATH(OGG_INCLUDE_DIR
+ NAMES ogg/ogg.h ogg/os_types.h
+ HINTS ENV OGGDIR
+ PATH_SUFFIXES include
+ PATHS ${OGG_SEARCH_PATHS}
+)
+
+FIND_LIBRARY(OGG_LIBRARY
+ NAMES ogg libogg
+ HINTS ENV OGGDIR
+ PATH_SUFFIXES lib lib64 win32/Dynamic_Release "Win32/${MSVC_YEAR_NAME}/x64/Release" "Win32/${MSVC_YEAR_NAME}/Win32/Release"
+ PATHS ${OGG_SEARCH_PATHS}
+)
+
+# First search for d-suffixed libs
+FIND_LIBRARY(OGG_LIBRARY_DEBUG
+ NAMES oggd ogg_d liboggd libogg_d
+ HINTS ENV OGGDIR
+ PATH_SUFFIXES lib lib64 win32/Dynamic_Debug "Win32/${MSVC_YEAR_NAME}/x64/Debug" "Win32/${MSVC_YEAR_NAME}/Win32/Debug"
+ PATHS ${OGG_SEARCH_PATHS}
+)
+
+IF(NOT OGG_LIBRARY_DEBUG)
+ # Then search for non suffixed libs if necessary, but only in debug dirs
+ FIND_LIBRARY(OGG_LIBRARY_DEBUG
+ NAMES ogg libogg
+ HINTS ENV OGGDIR
+ PATH_SUFFIXES win32/Dynamic_Debug "Win32/${MSVC_YEAR_NAME}/x64/Debug" "Win32/${MSVC_YEAR_NAME}/Win32/Debug"
+ PATHS ${OGG_SEARCH_PATHS}
+ )
+ENDIF()
+
+
+IF(OGG_LIBRARY)
+ IF(OGG_LIBRARY_DEBUG)
+ SET(OGG_LIBRARIES optimized "${OGG_LIBRARY}" debug "${OGG_LIBRARY_DEBUG}")
+ ELSE()
+ SET(OGG_LIBRARIES "${OGG_LIBRARY}") # Could add "general" keyword, but it is optional
+ ENDIF()
+ENDIF()
+
+# handle the QUIETLY and REQUIRED arguments and set XXX_FOUND to TRUE if all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(OGG DEFAULT_MSG OGG_LIBRARIES OGG_INCLUDE_DIR)
View
83 CMakeScripts/FindVorbis.cmake
@@ -0,0 +1,83 @@
+# Locate Vorbis
+# This module defines XXX_FOUND, XXX_INCLUDE_DIRS and XXX_LIBRARIES standard variables
+#
+# $VORBISDIR is an environment variable that would
+# correspond to the ./configure --prefix=$VORBISDIR
+# used in building Vorbis.
+
+SET(VORBIS_SEARCH_PATHS
+ ~/Library/Frameworks
+ /Library/Frameworks
+ /usr/local
+ /usr
+ /sw # Fink
+ /opt/local # DarwinPorts
+ /opt/csw # Blastwave
+ /opt
+)
+
+SET(MSVC_YEAR_NAME)
+IF (MSVC_VERSION GREATER 1599) # >= 1600
+ SET(MSVC_YEAR_NAME VS2010)
+ELSEIF(MSVC_VERSION GREATER 1499) # >= 1500
+ SET(MSVC_YEAR_NAME VS2008)
+ELSEIF(MSVC_VERSION GREATER 1399) # >= 1400
+ SET(MSVC_YEAR_NAME VS2005)
+ELSEIF(MSVC_VERSION GREATER 1299) # >= 1300
+ SET(MSVC_YEAR_NAME VS2003)
+ELSEIF(MSVC_VERSION GREATER 1199) # >= 1200
+ SET(MSVC_YEAR_NAME VS6)
+ENDIF()
+
+FIND_PATH(VORBIS_INCLUDE_DIR
+ NAMES vorbis/codec.h
+ HINTS
+ $ENV{VORBISDIR}
+ $ENV{VORBIS_PATH}
+ PATH_SUFFIXES include
+ PATHS ${VORBIS_SEARCH_PATHS}
+)
+
+FIND_LIBRARY(VORBIS_LIBRARY
+ NAMES vorbis libvorbis
+ HINTS
+ $ENV{VORBISDIR}
+ $ENV{VORBIS_PATH}
+ PATH_SUFFIXES lib lib64 win32/Vorbis_Dynamic_Release "Win32/${MSVC_YEAR_NAME}/x64/Release" "Win32/${MSVC_YEAR_NAME}/Win32/Release"
+ PATHS ${VORBIS_SEARCH_PATHS}
+)
+
+# First search for d-suffixed libs
+FIND_LIBRARY(VORBIS_LIBRARY_DEBUG
+ NAMES vorbisd vorbis_d libvorbisd libvorbis_d
+ HINTS
+ $ENV{VORBISDIR}
+ $ENV{VORBIS_PATH}
+ PATH_SUFFIXES lib lib64 win32/Vorbis_Dynamic_Debug "Win32/${MSVC_YEAR_NAME}/x64/Debug" "Win32/${MSVC_YEAR_NAME}/Win32/Debug"
+ PATHS ${VORBIS_SEARCH_PATHS}
+)
+
+IF(NOT VORBIS_LIBRARY_DEBUG)
+ # Then search for non suffixed libs if necessary, but only in debug dirs
+ FIND_LIBRARY(VORBIS_LIBRARY_DEBUG
+ NAMES vorbis libvorbis
+ HINTS
+ $ENV{VORBISDIR}
+ $ENV{VORBIS_PATH}
+ PATH_SUFFIXES win32/Vorbis_Dynamic_Debug "Win32/${MSVC_YEAR_NAME}/x64/Debug" "Win32/${MSVC_YEAR_NAME}/Win32/Debug"
+ PATHS ${VORBIS_SEARCH_PATHS}
+ )
+ENDIF()
+
+
+IF(VORBIS_LIBRARY)
+ IF(VORBIS_LIBRARY_DEBUG)
+ SET(VORBIS_LIBRARIES optimized "${VORBIS_LIBRARY}" debug "${VORBIS_LIBRARY_DEBUG}")
+ ELSE()
+ SET(VORBIS_LIBRARIES "${VORBIS_LIBRARY}") # Could add "general" keyword, but it is optional
+ ENDIF()
+ENDIF()
+
+# handle the QUIETLY and REQUIRED arguments and set XXX_FOUND to TRUE if all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(VORBIS DEFAULT_MSG VORBIS_LIBRARIES VORBIS_INCLUDE_DIR)
View
91 CMakeScripts/FindVorbisFile.cmake
@@ -0,0 +1,91 @@
+# Locate VorbisFile
+# This module defines XXX_FOUND, XXX_INCLUDE_DIRS and XXX_LIBRARIES standard variables
+#
+# $VORBISDIR is an environment variable that would
+# correspond to the ./configure --prefix=$VORBISDIR
+# used in building Vorbis.
+
+SET(VORBISFILE_SEARCH_PATHS
+ ~/Library/Frameworks
+ /Library/Frameworks
+ /usr/local
+ /usr
+ /sw # Fink
+ /opt/local # DarwinPorts
+ /opt/csw # Blastwave
+ /opt
+)
+
+SET(MSVC_YEAR_NAME)
+IF (MSVC_VERSION GREATER 1599) # >= 1600
+ SET(MSVC_YEAR_NAME VS2010)
+ELSEIF(MSVC_VERSION GREATER 1499) # >= 1500
+ SET(MSVC_YEAR_NAME VS2008)
+ELSEIF(MSVC_VERSION GREATER 1399) # >= 1400
+ SET(MSVC_YEAR_NAME VS2005)
+ELSEIF(MSVC_VERSION GREATER 1299) # >= 1300
+ SET(MSVC_YEAR_NAME VS2003)
+ELSEIF(MSVC_VERSION GREATER 1199) # >= 1200
+ SET(MSVC_YEAR_NAME VS6)
+ENDIF()
+
+FIND_PATH(VORBISFILE_INCLUDE_DIR
+ NAMES vorbis/vorbisfile.h
+ HINTS
+ $ENV{VORBISFILEDIR}
+ $ENV{VORBISFILE_PATH}
+ $ENV{VORBISDIR}
+ $ENV{VORBIS_PATH}
+ PATH_SUFFIXES include
+ PATHS ${VORBISFILE_SEARCH_PATHS}
+)
+
+FIND_LIBRARY(VORBISFILE_LIBRARY
+ NAMES vorbisfile libvorbisfile
+ HINTS
+ $ENV{VORBISFILEDIR}
+ $ENV{VORBISFILE_PATH}
+ $ENV{VORBISDIR}
+ $ENV{VORBIS_PATH}
+ PATH_SUFFIXES lib lib64 win32/VorbisFile_Dynamic_Release "Win32/${MSVC_YEAR_NAME}/x64/Release" "Win32/${MSVC_YEAR_NAME}/Win32/Release"
+ PATHS ${VORBISFILE_SEARCH_PATHS}
+)
+
+# First search for d-suffixed libs
+FIND_LIBRARY(VORBISFILE_LIBRARY_DEBUG
+ NAMES vorbisfiled vorbisfile_d libvorbisfiled libvorbisfile_d
+ HINTS
+ $ENV{VORBISFILEDIR}
+ $ENV{VORBISFILE_PATH}
+ $ENV{VORBISDIR}
+ $ENV{VORBIS_PATH}
+ PATH_SUFFIXES lib lib64 win32/VorbisFile_Dynamic_Debug "Win32/${MSVC_YEAR_NAME}/x64/Debug" "Win32/${MSVC_YEAR_NAME}/Win32/Debug"
+ PATHS ${VORBISFILE_SEARCH_PATHS}
+)
+
+IF(NOT VORBISFILE_LIBRARY_DEBUG)
+ # Then search for non suffixed libs if necessary, but only in debug dirs
+ FIND_LIBRARY(VORBISFILE_LIBRARY_DEBUG
+ NAMES vorbisfile libvorbisfile
+ HINTS
+ $ENV{VORBISFILEDIR}
+ $ENV{VORBISFILE_PATH}
+ $ENV{VORBISDIR}
+ $ENV{VORBIS_PATH}
+ PATH_SUFFIXES win32/VorbisFile_Dynamic_Debug "Win32/${MSVC_YEAR_NAME}/x64/Debug" "Win32/${MSVC_YEAR_NAME}/Win32/Debug"
+ PATHS ${VORBISFILE_SEARCH_PATHS}
+ )
+ENDIF()
+
+
+IF(VORBISFILE_LIBRARY)
+ IF(VORBISFILE_LIBRARY_DEBUG)
+ SET(VORBISFILE_LIBRARIES optimized "${VORBISFILE_LIBRARY}" debug "${VORBISFILE_LIBRARY_DEBUG}")
+ ELSE()
+ SET(VORBISFILE_LIBRARIES "${VORBISFILE_LIBRARY}") # Could add "general" keyword, but it is optional
+ ENDIF()
+ENDIF()
+
+# handle the QUIETLY and REQUIRED arguments and set XXX_FOUND to TRUE if all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(VORBISFILE DEFAULT_MSG VORBISFILE_LIBRARIES VORBISFILE_INCLUDE_DIR)
View
9 include/OALWrapper/OAL_Funcs.h
@@ -19,18 +19,15 @@
#ifdef WIN32
#pragma comment(lib, "libvorbis.lib")
#pragma comment(lib, "libvorbisfile.lib")
-#pragma comment(lib, "alut.lib")
+#ifdef WITH_ALUT
+ #pragma comment(lib, "alut.lib")
+#endif
#pragma comment(lib, "openal32.lib")
#pragma comment(lib, "SDL.lib")
#endif
#include "OAL_Types.h"
-//#include "OAL_WAVSample.h"
-//#include "OAL_OggSample.h"
-//#include "OAL_OggStream.h"
-
-
////////////////////////////////////////////
// Init / Shutdown funcs
////////////////////////////////////////////
View
8 include/OALWrapper/OAL_Types.h
@@ -60,11 +60,15 @@
// system headers
#include <OpenAL/al.h>
#include <OpenAL/alc.h>
- #include <ALUT/alut.h>
+ #ifdef WITH_ALUT
+ #include <ALUT/alut.h>
+ #endif
#else
#include <AL/al.h>
#include <AL/alc.h>
- #include <AL/alut.h>
+ #ifdef WITH_ALUT
+ #include <AL/alut.h>
+ #endif
#endif
// Included headers not available on all systems
#include <AL/alext.h>
View
8 sources/OAL_Device.cpp
@@ -16,7 +16,9 @@
#include "OALWrapper/OAL_Device.h"
#include "OALWrapper/OAL_Source.h"
#include "OALWrapper/OAL_OggSample.h"
+#ifdef WITH_ALUT
#include "OALWrapper/OAL_WAVSample.h"
+#endif
#include "OALWrapper/OAL_OggStream.h"
#include "OALWrapper/OAL_SourceManager.h"
@@ -310,10 +312,14 @@ cOAL_Sample* cOAL_Device::LoadSample(const wstring& asFilename)
wstring strExt = GetExtensionW(asFilename);
if(strExt.compare(L"ogg") == 0 ) // Load an Ogg Vorbis sample
pSample = new cOAL_OggSample;
+#ifdef WITH_ALUT
else if(strExt.compare(L"wav")==0) // Load a .WAV sample
pSample = new cOAL_WAVSample;
+#endif
+ else
+ return NULL;
- if(pSample && pSample->CreateFromFile(asFilename) )
+ if(pSample->CreateFromFile(asFilename) )
mlstSamples.push_back(pSample);
else
{

0 comments on commit 0fc3696

Please sign in to comment.
Something went wrong with that request. Please try again.