From a5f5270f8e184ef1bd1bd04c128608d7cfc36318 Mon Sep 17 00:00:00 2001 From: dhewg Date: Thu, 19 Jul 2012 20:05:38 +0200 Subject: [PATCH] Add SDL2 support for the build system Defaults to off, tree doesn't yet compile with SDL2. --- CMakeLists.txt | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f31a1c..e159bcb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,7 @@ option(BASE "Build the base game code" ON) option(D3XP "Build the d3xp game code" ON) option(DEDICATED "Build the dedicated server" OFF) option(ONATIVE "Optimize for the host CPU" OFF) +option(SDL2 "Use SDL2 instead of SDL1.2" OFF) if(NOT CMAKE_SYSTEM_PROCESSOR) message(FATAL_ERROR "No target CPU architecture set") @@ -73,6 +74,7 @@ if(DHEWM3LIBS) # these are too stupid, give them a hint set(ENV{OPENALDIR} ${DHEWM3LIBS}) set(ENV{SDLDIR} ${DHEWM3LIBS}) + set(ENV{SDL2DIR} ${DHEWM3LIBS}) endif() # libs @@ -98,12 +100,23 @@ include_directories(${VORBISFILE_INCLUDE_DIR}) find_package(OpenAL REQUIRED) include_directories(${OPENAL_INCLUDE_DIR}) -if(APPLE OR WIN32) +if (SDL2) + # skip SDL2main + if(APPLE OR WIN32) + set(SDL2_BUILDING_LIBRARY TRUE) + endif() + find_package(SDL2 REQUIRED) + include_directories(${SDL2_INCLUDE_DIR}) + set(SDLx_LIBRARY ${SDL2_LIBRARY}) +else() # skip SDLmain - set(SDL_BUILDING_LIBRARY TRUE) + if(APPLE OR WIN32) + set(SDL_BUILDING_LIBRARY TRUE) + endif() + find_package(SDL REQUIRED) + include_directories(${SDL_INCLUDE_DIR}) + set(SDLx_LIBRARY ${SDL_LIBRARY}) endif() -find_package(SDL REQUIRED) -include_directories(${SDL_INCLUDE_DIR}) find_package(CURL QUIET) if(CURL_FOUND) @@ -737,7 +750,7 @@ if(CORE) ${CURL_LIBRARY} ${JPEG_LIBRARY} ${ZLIB_LIBRARY} - ${SDL_LIBRARY} + ${SDLx_LIBRARY} ${sys_libs} ) @@ -767,7 +780,7 @@ if(DEDICATED) ${CURL_LIBRARY} ${JPEG_LIBRARY} ${ZLIB_LIBRARY} - ${SDL_LIBRARY} + ${SDLx_LIBRARY} ${sys_libs} )