Compiles on Linux with OpenAL support, SDL1/2 support.

Added build options for Zip/Ogg/OpenAL (On if available)
This commit is contained in:
Bradley Clemetson 2015-08-10 22:55:01 -07:00
parent 8211f5d497
commit 2d20c5c801
5 changed files with 54 additions and 35 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/build/
/release/
*.mk
*.user

View File

@ -12,6 +12,13 @@ set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake/modules
#Add Homebrew for OSX
list(APPEND CMAKE_PREFIX_PATH /usr/local)
#yquake2 compilation options
option(ZIP_SUPPORT "ZIP support" ON)
option(OGG_SUPPORT "OGG Vorbis playback support (Music)" ON)
option(OPENAL_SUPPORT "3D Sound support" ON)
#TODO Remove the X11 Gamma from the code
#TODO Remove SDL 1.X all together.
#These variables will act as our list of include folders and linker flags
set(yquake2LinkerFlags)
set(yquake2IncludeDirectories)
@ -28,41 +35,64 @@ set(CLIENT_SRC_DIR ${SOURCE_DIR}/client)
#Required libraries to build the different
#components of the tutorials. Find them and add the include/linker
#directories and flags(In case the package manager find it in a weird place)
find_package(SDL2 REQUIRED)
add_definitions(-DSDL2)
list(APPEND yquake2IncludeDirectories "${SDL2_INCLUDE_DIR}/..")
list(APPEND yquake2LinkerFlags ${SDL2_LIBRARY})
find_package(SDL2)
if(${SDL2_FOUND})
add_definitions(-DSDL2)
list(APPEND yquake2IncludeDirectories "${SDL2_INCLUDE_DIR}/..")
list(APPEND yquake2LinkerFlags ${SDL2_LIBRARY})
else()
#If we can't get SDL2 at least get SDL 1.X
find_package(SDL REQUIRED)
add_definitions(-DWITH_CDA)
list(APPEND yquake2IncludeDirectories "${SDL_INCLUDE_DIR}/..")
list(APPEND yquake2LinkerFlags ${SDL_LIBRARY})
endif()
find_package(OpenGL REQUIRED)
list(APPEND yquake2IncludeDirectories ${OPENGL_INCLUDE_DIR})
list(APPEND yquake2LinkerFlags ${OPENGL_LIBRARIES})
find_package(ZLIB REQUIRED)
list(APPEND yquake2IncludeDirectories ${ZLIB_INCLUDE_DIRS})
list(APPEND yquake2LinkerFlags ${ZLIB_LIBRARIES})
if(${ZIP_SUPPORT})
find_package(ZLIB REQUIRED)
list(APPEND yquake2IncludeDirectories ${ZLIB_INCLUDE_DIRS})
list(APPEND yquake2LinkerFlags ${ZLIB_LIBRARIES})
add_definitions(-DZIP -DNOUNCRYPT)
endif()
#OggVorbis
find_package(OggVorbis)
if(${OGGVORBIS_FOUND})
if(${OGG_SUPPORT})
find_package(OggVorbis)
if(${OGGVORBIS_FOUND})
add_definitions(-DOGG=1)
list(APPEND yquake2IncludeDirectories ${OGGVORBIS_INCLUDE_DIR})
list(APPEND yquake2LinkerFlags ${OGG_LIBRARY} ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY})
endif()
endif()
#OpenAL
find_package(OpenAL)
#TODO Enable OSX OpenAL support
if(${OPENAL_FOUND} AND NOT(${CMAKE_SYSTEM_NAME} MATCHES "Darwin"))
add_definitions(-DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER)
if(${OPENAL_SUPPORT})
find_package(OpenAL)
#TODO Enable OSX OpenAL support
if(${OPENAL_FOUND} AND NOT(${CMAKE_SYSTEM_NAME} MATCHES "Darwin"))
list(APPEND yquake2IncludeDirectories "${OPENAL_INCLUDE_DIR}")
list(APPEND yquake2LinkerFlags ${OPENAL_LIBRARY})
list(APPEND yquake2LinkerFlags ${OPENAL_LIBRARY})
#TODO This should be done in the source with a #ifdef PLATFORM_X
#We found the library but we must also give it the right dynamic library
#to open.
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
add_definitions(-DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER="openal32.dll")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_definitions(-DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER="libopenal.dylib")
elseif((${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") OR (${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD"))
add_definitions(-DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER="libopenal.so")
else()
add_definitions(-DUSE_OPENAL -DDEFAULT_OPENAL_DRIVER="libopenal.so.1")
endif()
endif()
endif()
list(APPEND yquake2LinkerFlags "-lm -rdynamic")
list(APPEND yquake2LinkerFlags ${CMAKE_DL_LIBS})
add_definitions(-DZIP -DNOUNCRYPT)
#With all of those libraries and user defined paths added,
#lets give them to the compiler and linker.
include_directories(${yquake2IncludeDirectories})

View File

@ -31,15 +31,11 @@
#include "../../client/header/client.h"
/* There's no sdl-config on OS X and Windows */
#if defined(_WIN32) || defined(__APPLE__)
#ifdef SDL2
#include <SDL2/SDL.h>
#else /* SDL1.2 */
#include <SDL/SDL.h>
#endif /*SDL2 */
#else /* not _WIN32 || APPLE */
#include <SDL.h>
#endif /* _WIN32 || APPLE */
/* SDL 1.2 <-> 2.0 compatiblity cruft */
#if SDL_VERSION_ATLEAST(2, 0, 0)

View File

@ -41,15 +41,11 @@
#include <GL/gl.h>
#endif
#if defined(_WIN32) || defined(__APPLE__)
#ifdef SDL2
#include <SDL2/SDL.h>
#else // SDL1.2
#include <SDL/SDL.h>
#endif //SDL2
#else // not _WIN32 || APPLE
#include <SDL.h>
#endif // _WIN32 || APPLE
/* The window icon */
#include "icon/q2icon.xbm"

View File

@ -34,15 +34,11 @@
*/
/* SDL includes */
#if defined(_WIN32) || defined(__APPLE__)
#ifdef SDL2
#include <SDL2/SDL.h>
#else // SDL1.2
#include <SDL/SDL.h>
#endif //SDL2
#else // not _WIN32 || APPLE
#include <SDL.h>
#endif // _WIN32 || APPLE
/* Local includes */
#include "../../client/header/client.h"