# HG changeset patch
# User unc0rr
# Date 1383685173 -14400
# Node ID 71626318f80e5a490a50f6d1e83630684b3e0887
# Parent ce7396d4eaf70792fef82930b66296309a606872
- Use USESDL12 for old SDL
- Engine builds, frontend doesn't due to changes in API
diff -r ce7396d4eaf7 -r 71626318f80e CMakeLists.txt
--- a/CMakeLists.txt Tue Nov 05 11:04:26 2013 +0400
+++ b/CMakeLists.txt Wed Nov 06 00:59:33 2013 +0400
@@ -15,6 +15,7 @@
option(NOSERVER "Disable gameServer build (off)]" OFF)
option(NOPNG "Disable screenshoot compression (off)" OFF)
option(NOVIDEOREC "Disable video recording (off)" OFF)
+option(USESDL12 "Use SDL 1.2 (off)" OFF)
#libraries are built shared unless explicitly added as a static
option(BUILD_SHARED_LIBS "Build libraries as shared modules (on)" ON)
diff -r ce7396d4eaf7 -r 71626318f80e QTfrontend/CMakeLists.txt
--- a/QTfrontend/CMakeLists.txt Tue Nov 05 11:04:26 2013 +0400
+++ b/QTfrontend/CMakeLists.txt Wed Nov 06 00:59:33 2013 +0400
@@ -19,8 +19,15 @@
message(FATAL_ERROR "This version of QT is known *not* to work, please update or use a lower version")
endif()
-find_package(SDL1or2) #video in SDLInteraction
-find_package(SDL_mixer REQUIRED) #audio in SDLInteraction
+if(${USESDL12})
+ find_package(SDL REQUIRED) #video in SDLInteraction
+ find_package(SDL_mixer REQUIRED) #audio in SDLInteraction
+ include_directories(${SDL_INCLUDE_DIR})
+ include_directories(${SDLMIXER_INCLUDE_DIR})
+else(${USESDL12})
+ find_package(SDL2 REQUIRED)
+ include_directories(${SDL2_INCLUDE_DIR})
+endif(${USESDL12})
if(${FFMPEG_FOUND})
add_definitions(-DVIDEOREC -D__STDC_CONSTANT_MACROS)
@@ -59,8 +66,6 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ui/widget)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/util)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/util/platform)
-include_directories(${SDL_INCLUDE_DIR})
-include_directories(${SDLMIXER_INCLUDE_DIR})
include_directories(${PHYSFS_INCLUDE_DIR})
include_directories(${PHYSLAYER_INCLUDE_DIR})
diff -r ce7396d4eaf7 -r 71626318f80e QTfrontend/ui/widget/about.cpp
--- a/QTfrontend/ui/widget/about.cpp Tue Nov 05 11:04:26 2013 +0400
+++ b/QTfrontend/ui/widget/about.cpp Wed Nov 06 00:59:33 2013 +0400
@@ -99,7 +99,14 @@
libinfo.append(QString(tr("Unknown Compiler")).arg(__VERSION__) + QString("
"));
#endif
- const SDL_version *sdl_ver = SDL_Linked_Version();
+ const SDL_version *sdl_ver;
+ SDL_version sdl_version;
+#if SDL_MAJOR_VERSION == 2
+ SDL_GetVersion(&sdl_version);
+ sdl_ver = &sdl_version;
+#else
+ sdl_ver = SDL_Linked_Version();
+#endif
libinfo.append(QString("SDL version: %1.%2.%3
")
.arg(sdl_ver->major)
.arg(sdl_ver->minor)
diff -r ce7396d4eaf7 -r 71626318f80e cmake_modules/FindSDL2_image.cmake
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cmake_modules/FindSDL2_image.cmake Wed Nov 06 00:59:33 2013 +0400
@@ -0,0 +1,88 @@
+# - Locate SDL2_image library
+# This module defines:
+# SDL2_IMAGE_LIBRARIES, the name of the library to link against
+# SDL2_IMAGE_INCLUDE_DIRS, where to find the headers
+# SDL2_IMAGE_FOUND, if false, do not try to link against
+# SDL2_IMAGE_VERSION_STRING - human-readable string containing the version of SDL2_image
+#
+# For backward compatiblity the following variables are also set:
+# SDL2IMAGE_LIBRARY (same value as SDL2_IMAGE_LIBRARIES)
+# SDL2IMAGE_INCLUDE_DIR (same value as SDL2_IMAGE_INCLUDE_DIRS)
+# SDL2IMAGE_FOUND (same value as SDL2_IMAGE_FOUND)
+#
+# $SDL2DIR is an environment variable that would
+# correspond to the ./configure --prefix=$SDL2DIR
+# used in building SDL2.
+#
+# Created by Eric Wing. This was influenced by the FindSDL2.cmake
+# module, but with modifications to recognize OS X frameworks and
+# additional Unix paths (FreeBSD, etc).
+
+#=============================================================================
+# Copyright 2005-2009 Kitware, Inc.
+# Copyright 2012 Benjamin Eikel
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+if(NOT SDL2_IMAGE_INCLUDE_DIR AND SDL2IMAGE_INCLUDE_DIR)
+ set(SDL2_IMAGE_INCLUDE_DIR ${SDL2IMAGE_INCLUDE_DIR} CACHE PATH "directory cache
+entry initialized from old variable name")
+endif()
+find_path(SDL2_IMAGE_INCLUDE_DIR SDL_image.h
+ HINTS
+ ENV SDL2IMAGEDIR
+ ENV SDL2DIR
+ PATH_SUFFIXES include/SDL2 include
+)
+
+if(NOT SDL2_IMAGE_LIBRARY AND SDL2IMAGE_LIBRARY)
+ set(SDL2_IMAGE_LIBRARY ${SDL2IMAGE_LIBRARY} CACHE FILEPATH "file cache entry
+initialized from old variable name")
+endif()
+find_library(SDL2_IMAGE_LIBRARY
+ NAMES SDL2_image
+ HINTS
+ ENV SDL2IMAGEDIR
+ ENV SDL2DIR
+ PATH_SUFFIXES lib
+)
+
+if(SDL2_IMAGE_INCLUDE_DIR AND EXISTS "${SDL2_IMAGE_INCLUDE_DIR}/SDL2_image.h")
+ file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL2_image.h" SDL2_IMAGE_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL2_IMAGE_MAJOR_VERSION[ \t]+[0-9]+$")
+ file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL2_image.h" SDL2_IMAGE_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL2_IMAGE_MINOR_VERSION[ \t]+[0-9]+$")
+ file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL2_image.h" SDL2_IMAGE_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL2_IMAGE_PATCHLEVEL[ \t]+[0-9]+$")
+ string(REGEX REPLACE "^#define[ \t]+SDL2_IMAGE_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_IMAGE_VERSION_MAJOR "${SDL2_IMAGE_VERSION_MAJOR_LINE}")
+ string(REGEX REPLACE "^#define[ \t]+SDL2_IMAGE_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_IMAGE_VERSION_MINOR "${SDL2_IMAGE_VERSION_MINOR_LINE}")
+ string(REGEX REPLACE "^#define[ \t]+SDL2_IMAGE_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_IMAGE_VERSION_PATCH "${SDL2_IMAGE_VERSION_PATCH_LINE}")
+ set(SDL2_IMAGE_VERSION_STRING ${SDL2_IMAGE_VERSION_MAJOR}.${SDL2_IMAGE_VERSION_MINOR}.${SDL2_IMAGE_VERSION_PATCH})
+ unset(SDL2_IMAGE_VERSION_MAJOR_LINE)
+ unset(SDL2_IMAGE_VERSION_MINOR_LINE)
+ unset(SDL2_IMAGE_VERSION_PATCH_LINE)
+ unset(SDL2_IMAGE_VERSION_MAJOR)
+ unset(SDL2_IMAGE_VERSION_MINOR)
+ unset(SDL2_IMAGE_VERSION_PATCH)
+endif()
+
+set(SDL2_IMAGE_LIBRARIES ${SDL2_IMAGE_LIBRARY})
+set(SDL2_IMAGE_INCLUDE_DIRS ${SDL2_IMAGE_INCLUDE_DIR})
+
+include(FindPackageHandleStandardArgs)
+
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_image
+ REQUIRED_VARS SDL2_IMAGE_LIBRARIES SDL2_IMAGE_INCLUDE_DIRS
+ VERSION_VAR SDL2_IMAGE_VERSION_STRING)
+
+# for backward compatiblity
+set(SDL2IMAGE_LIBRARY ${SDL2_IMAGE_LIBRARIES})
+set(SDL2IMAGE_INCLUDE_DIR ${SDL2_IMAGE_INCLUDE_DIRS})
+set(SDL2IMAGE_FOUND ${SDL2_IMAGE_FOUND})
+
+mark_as_advanced(SDL2_IMAGE_LIBRARY SDL2_IMAGE_INCLUDE_DIR)
diff -r ce7396d4eaf7 -r 71626318f80e cmake_modules/FindSDL2_mixer.cmake
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cmake_modules/FindSDL2_mixer.cmake Wed Nov 06 00:59:33 2013 +0400
@@ -0,0 +1,88 @@
+# - Locate SDL2_mixer library
+# This module defines:
+# SDL2_MIXER_LIBRARIES, the name of the library to link against
+# SDL2_MIXER_INCLUDE_DIRS, where to find the headers
+# SDL2_MIXER_FOUND, if false, do not try to link against
+# SDL2_MIXER_VERSION_STRING - human-readable string containing the version of SDL2_mixer
+#
+# For backward compatiblity the following variables are also set:
+# SDL2MIXER_LIBRARY (same value as SDL2_MIXER_LIBRARIES)
+# SDL2MIXER_INCLUDE_DIR (same value as SDL2_MIXER_INCLUDE_DIRS)
+# SDL2MIXER_FOUND (same value as SDL2_MIXER_FOUND)
+#
+# $SDL2DIR is an environment variable that would
+# correspond to the ./configure --prefix=$SDL2DIR
+# used in building SDL2.
+#
+# Created by Eric Wing. This was influenced by the FindSDL2.cmake
+# module, but with modifications to recognize OS X frameworks and
+# additional Unix paths (FreeBSD, etc).
+
+#=============================================================================
+# Copyright 2005-2009 Kitware, Inc.
+# Copyright 2012 Benjamin Eikel
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+if(NOT SDL2_MIXER_INCLUDE_DIR AND SDL2MIXER_INCLUDE_DIR)
+ set(SDL2_MIXER_INCLUDE_DIR ${SDL2MIXER_INCLUDE_DIR} CACHE PATH "directory cache
+entry initialized from old variable name")
+endif()
+find_path(SDL2_MIXER_INCLUDE_DIR SDL_mixer.h
+ HINTS
+ ENV SDL2MIXERDIR
+ ENV SDL2DIR
+ PATH_SUFFIXES include/SDL2 include
+)
+
+if(NOT SDL2_MIXER_LIBRARY AND SDL2MIXER_LIBRARY)
+ set(SDL2_MIXER_LIBRARY ${SDL2MIXER_LIBRARY} CACHE FILEPATH "file cache entry
+initialized from old variable name")
+endif()
+find_library(SDL2_MIXER_LIBRARY
+ NAMES SDL2_mixer
+ HINTS
+ ENV SDL2MIXERDIR
+ ENV SDL2DIR
+ PATH_SUFFIXES lib
+)
+
+if(SDL2_MIXER_INCLUDE_DIR AND EXISTS "${SDL2_MIXER_INCLUDE_DIR}/SDL2_mixer.h")
+ file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL2_mixer.h" SDL2_MIXER_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL2_MIXER_MAJOR_VERSION[ \t]+[0-9]+$")
+ file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL2_mixer.h" SDL2_MIXER_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL2_MIXER_MINOR_VERSION[ \t]+[0-9]+$")
+ file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL2_mixer.h" SDL2_MIXER_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL2_MIXER_PATCHLEVEL[ \t]+[0-9]+$")
+ string(REGEX REPLACE "^#define[ \t]+SDL2_MIXER_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_MIXER_VERSION_MAJOR "${SDL2_MIXER_VERSION_MAJOR_LINE}")
+ string(REGEX REPLACE "^#define[ \t]+SDL2_MIXER_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_MIXER_VERSION_MINOR "${SDL2_MIXER_VERSION_MINOR_LINE}")
+ string(REGEX REPLACE "^#define[ \t]+SDL2_MIXER_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_MIXER_VERSION_PATCH "${SDL2_MIXER_VERSION_PATCH_LINE}")
+ set(SDL2_MIXER_VERSION_STRING ${SDL2_MIXER_VERSION_MAJOR}.${SDL2_MIXER_VERSION_MINOR}.${SDL2_MIXER_VERSION_PATCH})
+ unset(SDL2_MIXER_VERSION_MAJOR_LINE)
+ unset(SDL2_MIXER_VERSION_MINOR_LINE)
+ unset(SDL2_MIXER_VERSION_PATCH_LINE)
+ unset(SDL2_MIXER_VERSION_MAJOR)
+ unset(SDL2_MIXER_VERSION_MINOR)
+ unset(SDL2_MIXER_VERSION_PATCH)
+endif()
+
+set(SDL2_MIXER_LIBRARIES ${SDL2_MIXER_LIBRARY})
+set(SDL2_MIXER_INCLUDE_DIRS ${SDL2_MIXER_INCLUDE_DIR})
+
+include(FindPackageHandleStandardArgs)
+
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_mixer
+ REQUIRED_VARS SDL2_MIXER_LIBRARIES SDL2_MIXER_INCLUDE_DIRS
+ VERSION_VAR SDL2_MIXER_VERSION_STRING)
+
+# for backward compatiblity
+set(SDL2MIXER_LIBRARY ${SDL2_MIXER_LIBRARIES})
+set(SDL2MIXER_INCLUDE_DIR ${SDL2_MIXER_INCLUDE_DIRS})
+set(SDL2MIXER_FOUND ${SDL2_MIXER_FOUND})
+
+mark_as_advanced(SDL2_MIXER_LIBRARY SDL2_MIXER_INCLUDE_DIR)
diff -r ce7396d4eaf7 -r 71626318f80e cmake_modules/FindSDL2_net.cmake
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cmake_modules/FindSDL2_net.cmake Wed Nov 06 00:59:33 2013 +0400
@@ -0,0 +1,88 @@
+# - Locate SDL2_net library
+# This module defines:
+# SDL2_NET_LIBRARIES, the name of the library to link against
+# SDL2_NET_INCLUDE_DIRS, where to find the headers
+# SDL2_NET_FOUND, if false, do not try to link against
+# SDL2_NET_VERSION_STRING - human-readable string containing the version of SDL2_net
+#
+# For backward compatiblity the following variables are also set:
+# SDL2NET_LIBRARY (same value as SDL2_NET_LIBRARIES)
+# SDL2NET_INCLUDE_DIR (same value as SDL2_NET_INCLUDE_DIRS)
+# SDL2NET_FOUND (same value as SDL2_NET_FOUND)
+#
+# $SDL2DIR is an environment variable that would
+# correspond to the ./configure --prefix=$SDL2DIR
+# used in building SDL2.
+#
+# Created by Eric Wing. This was influenced by the FindSDL2.cmake
+# module, but with modifications to recognize OS X frameworks and
+# additional Unix paths (FreeBSD, etc).
+
+#=============================================================================
+# Copyright 2005-2009 Kitware, Inc.
+# Copyright 2012 Benjamin Eikel
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+if(NOT SDL2_NET_INCLUDE_DIR AND SDL2NET_INCLUDE_DIR)
+ set(SDL2_NET_INCLUDE_DIR ${SDL2NET_INCLUDE_DIR} CACHE PATH "directory cache
+entry initialized from old variable name")
+endif()
+find_path(SDL2_NET_INCLUDE_DIR SDL_net.h
+ HINTS
+ ENV SDL2NETDIR
+ ENV SDL2DIR
+ PATH_SUFFIXES include/SDL2 include
+)
+
+if(NOT SDL2_NET_LIBRARY AND SDL2NET_LIBRARY)
+ set(SDL2_NET_LIBRARY ${SDL2NET_LIBRARY} CACHE FILEPATH "file cache entry
+initialized from old variable name")
+endif()
+find_library(SDL2_NET_LIBRARY
+ NAMES SDL2_net
+ HINTS
+ ENV SDL2NETDIR
+ ENV SDL2DIR
+ PATH_SUFFIXES lib
+)
+
+if(SDL2_NET_INCLUDE_DIR AND EXISTS "${SDL2_NET_INCLUDE_DIR}/SDL2_net.h")
+ file(STRINGS "${SDL2_NET_INCLUDE_DIR}/SDL2_net.h" SDL2_NET_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL2_NET_MAJOR_VERSION[ \t]+[0-9]+$")
+ file(STRINGS "${SDL2_NET_INCLUDE_DIR}/SDL2_net.h" SDL2_NET_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL2_NET_MINOR_VERSION[ \t]+[0-9]+$")
+ file(STRINGS "${SDL2_NET_INCLUDE_DIR}/SDL2_net.h" SDL2_NET_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL2_NET_PATCHLEVEL[ \t]+[0-9]+$")
+ string(REGEX REPLACE "^#define[ \t]+SDL2_NET_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_NET_VERSION_MAJOR "${SDL2_NET_VERSION_MAJOR_LINE}")
+ string(REGEX REPLACE "^#define[ \t]+SDL2_NET_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_NET_VERSION_MINOR "${SDL2_NET_VERSION_MINOR_LINE}")
+ string(REGEX REPLACE "^#define[ \t]+SDL2_NET_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_NET_VERSION_PATCH "${SDL2_NET_VERSION_PATCH_LINE}")
+ set(SDL2_NET_VERSION_STRING ${SDL2_NET_VERSION_MAJOR}.${SDL2_NET_VERSION_MINOR}.${SDL2_NET_VERSION_PATCH})
+ unset(SDL2_NET_VERSION_MAJOR_LINE)
+ unset(SDL2_NET_VERSION_MINOR_LINE)
+ unset(SDL2_NET_VERSION_PATCH_LINE)
+ unset(SDL2_NET_VERSION_MAJOR)
+ unset(SDL2_NET_VERSION_MINOR)
+ unset(SDL2_NET_VERSION_PATCH)
+endif()
+
+set(SDL2_NET_LIBRARIES ${SDL2_NET_LIBRARY})
+set(SDL2_NET_INCLUDE_DIRS ${SDL2_NET_INCLUDE_DIR})
+
+include(FindPackageHandleStandardArgs)
+
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_net
+ REQUIRED_VARS SDL2_NET_LIBRARIES SDL2_NET_INCLUDE_DIRS
+ VERSION_VAR SDL2_NET_VERSION_STRING)
+
+# for backward compatiblity
+set(SDL2NET_LIBRARY ${SDL2_NET_LIBRARIES})
+set(SDL2NET_INCLUDE_DIR ${SDL2_NET_INCLUDE_DIRS})
+set(SDL2NET_FOUND ${SDL2_NET_FOUND})
+
+mark_as_advanced(SDL2_NET_LIBRARY SDL2_NET_INCLUDE_DIR)
diff -r ce7396d4eaf7 -r 71626318f80e cmake_modules/FindSDL2_ttf.cmake
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cmake_modules/FindSDL2_ttf.cmake Wed Nov 06 00:59:33 2013 +0400
@@ -0,0 +1,88 @@
+# - Locate SDL2_ttf library
+# This module defines:
+# SDL2_TTF_LIBRARIES, the name of the library to link against
+# SDL2_TTF_INCLUDE_DIRS, where to find the headers
+# SDL2_TTF_FOUND, if false, do not try to link against
+# SDL2_TTF_VERSION_STRING - human-readable string containing the version of SDL2_ttf
+#
+# For backward compatiblity the following variables are also set:
+# SDL2TTF_LIBRARY (same value as SDL2_TTF_LIBRARIES)
+# SDL2TTF_INCLUDE_DIR (same value as SDL2_TTF_INCLUDE_DIRS)
+# SDL2TTF_FOUND (same value as SDL2_TTF_FOUND)
+#
+# $SDL2DIR is an environment variable that would
+# correspond to the ./configure --prefix=$SDL2DIR
+# used in building SDL2.
+#
+# Created by Eric Wing. This was influenced by the FindSDL2.cmake
+# module, but with modifications to recognize OS X frameworks and
+# additional Unix paths (FreeBSD, etc).
+
+#=============================================================================
+# Copyright 2005-2009 Kitware, Inc.
+# Copyright 2012 Benjamin Eikel
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+if(NOT SDL2_TTF_INCLUDE_DIR AND SDL2TTF_INCLUDE_DIR)
+ set(SDL2_TTF_INCLUDE_DIR ${SDL2TTF_INCLUDE_DIR} CACHE PATH "directory cache
+entry initialized from old variable name")
+endif()
+find_path(SDL2_TTF_INCLUDE_DIR SDL_ttf.h
+ HINTS
+ ENV SDL2TTFDIR
+ ENV SDL2DIR
+ PATH_SUFFIXES include/SDL2 include
+)
+
+if(NOT SDL2_TTF_LIBRARY AND SDL2TTF_LIBRARY)
+ set(SDL2_TTF_LIBRARY ${SDL2TTF_LIBRARY} CACHE FILEPATH "file cache entry
+initialized from old variable name")
+endif()
+find_library(SDL2_TTF_LIBRARY
+ NAMES SDL2_ttf
+ HINTS
+ ENV SDL2TTFDIR
+ ENV SDL2DIR
+ PATH_SUFFIXES lib
+)
+
+if(SDL2_TTF_INCLUDE_DIR AND EXISTS "${SDL2_TTF_INCLUDE_DIR}/SDL2_ttf.h")
+ file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL2_ttf.h" SDL2_TTF_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL2_TTF_MAJOR_VERSION[ \t]+[0-9]+$")
+ file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL2_ttf.h" SDL2_TTF_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL2_TTF_MINOR_VERSION[ \t]+[0-9]+$")
+ file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL2_ttf.h" SDL2_TTF_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL2_TTF_PATCHLEVEL[ \t]+[0-9]+$")
+ string(REGEX REPLACE "^#define[ \t]+SDL2_TTF_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_TTF_VERSION_MAJOR "${SDL2_TTF_VERSION_MAJOR_LINE}")
+ string(REGEX REPLACE "^#define[ \t]+SDL2_TTF_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_TTF_VERSION_MINOR "${SDL2_TTF_VERSION_MINOR_LINE}")
+ string(REGEX REPLACE "^#define[ \t]+SDL2_TTF_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_TTF_VERSION_PATCH "${SDL2_TTF_VERSION_PATCH_LINE}")
+ set(SDL2_TTF_VERSION_STRING ${SDL2_TTF_VERSION_MAJOR}.${SDL2_TTF_VERSION_MINOR}.${SDL2_TTF_VERSION_PATCH})
+ unset(SDL2_TTF_VERSION_MAJOR_LINE)
+ unset(SDL2_TTF_VERSION_MINOR_LINE)
+ unset(SDL2_TTF_VERSION_PATCH_LINE)
+ unset(SDL2_TTF_VERSION_MAJOR)
+ unset(SDL2_TTF_VERSION_MINOR)
+ unset(SDL2_TTF_VERSION_PATCH)
+endif()
+
+set(SDL2_TTF_LIBRARIES ${SDL2_TTF_LIBRARY})
+set(SDL2_TTF_INCLUDE_DIRS ${SDL2_TTF_INCLUDE_DIR})
+
+include(FindPackageHandleStandardArgs)
+
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_ttf
+ REQUIRED_VARS SDL2_TTF_LIBRARIES SDL2_TTF_INCLUDE_DIRS
+ VERSION_VAR SDL2_TTF_VERSION_STRING)
+
+# for backward compatiblity
+set(SDL2TTF_LIBRARY ${SDL2_TTF_LIBRARIES})
+set(SDL2TTF_INCLUDE_DIR ${SDL2_TTF_INCLUDE_DIRS})
+set(SDL2TTF_FOUND ${SDL2_TTF_FOUND})
+
+mark_as_advanced(SDL2_TTF_LIBRARY SDL2_TTF_INCLUDE_DIR)
diff -r ce7396d4eaf7 -r 71626318f80e hedgewars/CMakeLists.txt
--- a/hedgewars/CMakeLists.txt Tue Nov 05 11:04:26 2013 +0400
+++ b/hedgewars/CMakeLists.txt Wed Nov 06 00:59:33 2013 +0400
@@ -1,13 +1,22 @@
-find_package(SDL1or2)
-find_package(SDL_image)
-find_package(SDL_net)
-find_package(SDL_ttf)
-find_package(SDL_mixer)
+enable_language(Pascal)
+
+if(${USESDL12})
+ find_package(SDL REQUIRED)
+ find_package(SDL_image REQUIRED)
+ find_package(SDL_net REQUIRED)
+ find_package(SDL_ttf REQUIRED)
+ find_package(SDL_mixer REQUIRED)
+else(${USESDL12})
+ find_package(SDL2 REQUIRED)
+ find_package(SDL2_image REQUIRED)
+ find_package(SDL2_net REQUIRED)
+ find_package(SDL2_ttf REQUIRED)
+ find_package(SDL2_mixer REQUIRED)
+ add_definitions(-dSDL2)
+endif(${USESDL12})
include (CheckLibraryExists)
-
-enable_language(Pascal)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config.inc)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
@@ -111,8 +120,11 @@
list(APPEND HW_LINK_LIBS avwrapper)
add_definitions(-dUSE_VIDEO_RECORDING)
add_flag_append(CMAKE_Pascal_FLAGS -Fl${LIBRARY_OUTPUT_PATH})
- #only for SDL < 2, linking carried out by fpc
- find_package_or_disable_msg(GLUT NOVIDEOREC "Video recording will not be built")
+
+ if(${USESDL12})
+ #only for SDL < 2, linking carried out by fpc
+ find_package_or_disable_msg(GLUT NOVIDEOREC "Video recording will not be built")
+ endif(${USESDL12})
endif()
find_package_or_disable_msg(PNG NOPNG "Screenshots will be saved in BMP")
@@ -148,20 +160,18 @@
list(APPEND HW_LINK_LIBS physlayer)
#Mix_Init/Mix_Quit from SDL_mixer 1.2.10
-check_library_exists(${SDLMIXER_LIBRARY} Mix_Init "" HAVE_MIXINIT)
-if(HAVE_MIXINIT)
- add_definitions(-dSDL_MIXER_NEWER)
-endif(HAVE_MIXINIT)
+if(${USESDL12})
+ check_library_exists(${SDLMIXER_LIBRARY} Mix_Init "" HAVE_MIXINIT)
+ if(HAVE_MIXINIT)
+ add_definitions(-dSDL_MIXER_NEWER)
+ endif(HAVE_MIXINIT)
-#IMG_Init/IMG_Quit from SDL_image 1.2.8
-check_library_exists(${SDLIMAGE_LIBRARY} IMG_Init "" HAVE_IMGINIT)
-if(HAVE_IMGINIT)
- add_definitions(-dSDL_IMAGE_NEWER)
-endif(HAVE_IMGINIT)
-
-if(NOT (SDL_VERSION VERSION_LESS 2.0))
- add_definitions(-dSDL2)
-endif()
+ #IMG_Init/IMG_Quit from SDL_image 1.2.8
+ check_library_exists(${SDLIMAGE_LIBRARY} IMG_Init "" HAVE_IMGINIT)
+ if(HAVE_IMGINIT)
+ add_definitions(-dSDL_IMAGE_NEWER)
+ endif(HAVE_IMGINIT)
+endif(${USESDL12})
#needs to be last
add_definitions(-dDEBUGFILE)
diff -r ce7396d4eaf7 -r 71626318f80e hedgewars/SDLh.pas
--- a/hedgewars/SDLh.pas Tue Nov 05 11:04:26 2013 +0400
+++ b/hedgewars/SDLh.pas Wed Nov 06 00:59:33 2013 +0400
@@ -70,18 +70,34 @@
(* SDL *)
const
-{$IFDEF WIN32}
- SDLLibName = 'SDL.dll';
- SDL_TTFLibName = 'SDL_ttf.dll';
- SDL_MixerLibName = 'SDL_mixer.dll';
- SDL_ImageLibName = 'SDL_image.dll';
- SDL_NetLibName = 'SDL_net.dll';
+{$IFDEF SDL2}
+ {$IFDEF WIN32}
+ SDLLibName = 'SDL2.dll';
+ SDL_TTFLibName = 'SDL2_ttf.dll';
+ SDL_MixerLibName = 'SDL2_mixer.dll';
+ SDL_ImageLibName = 'SDL2_image.dll';
+ SDL_NetLibName = 'SDL2_net.dll';
+ {$ELSE}
+ SDLLibName = 'libSDL2';
+ SDL_TTFLibName = 'libSDL2_ttf';
+ SDL_MixerLibName = 'libSDL2_mixer';
+ SDL_ImageLibName = 'libSDL2_image';
+ SDL_NetLibName = 'libSDL2_net';
+ {$ENDIF}
{$ELSE}
- SDLLibName = 'libSDL';
- SDL_TTFLibName = 'libSDL_ttf';
- SDL_MixerLibName = 'libSDL_mixer';
- SDL_ImageLibName = 'libSDL_image';
- SDL_NetLibName = 'libSDL_net';
+ {$IFDEF WIN32}
+ SDLLibName = 'SDL.dll';
+ SDL_TTFLibName = 'SDL_ttf.dll';
+ SDL_MixerLibName = 'SDL_mixer.dll';
+ SDL_ImageLibName = 'SDL_image.dll';
+ SDL_NetLibName = 'SDL_net.dll';
+ {$ELSE}
+ SDLLibName = 'libSDL';
+ SDL_TTFLibName = 'libSDL_ttf';
+ SDL_MixerLibName = 'libSDL_mixer';
+ SDL_ImageLibName = 'libSDL_image';
+ SDL_NetLibName = 'libSDL_net';
+ {$ENDIF}
{$ENDIF}
/////////////////////////////////////////////////////////////////
diff -r ce7396d4eaf7 -r 71626318f80e hedgewars/uStore.pas
--- a/hedgewars/uStore.pas Tue Nov 05 11:04:26 2013 +0400
+++ b/hedgewars/uStore.pas Wed Nov 06 00:59:33 2013 +0400
@@ -1138,6 +1138,7 @@
WriteLnToConsole(msgOK);
// load engine icon
{$IFNDEF DARWIN}
+ {$IFNDEF SDL2}
ico:= LoadDataImage(ptGraphics, 'hwengine', ifIgnoreCaps);
if ico <> nil then
begin
@@ -1145,6 +1146,7 @@
SDL_FreeSurface(ico)
end;
{$ENDIF}
+ {$ENDIF}
end
else
begin
diff -r ce7396d4eaf7 -r 71626318f80e misc/libphyslayer/CMakeLists.txt
--- a/misc/libphyslayer/CMakeLists.txt Tue Nov 05 11:04:26 2013 +0400
+++ b/misc/libphyslayer/CMakeLists.txt Wed Nov 06 00:59:33 2013 +0400
@@ -1,7 +1,13 @@
-find_package(SDL1or2)
+if(${USESDL12})
+ find_package(SDL REQUIRED)
+ include_directories(${SDL_INCLUDE_DIR})
+else(${USESDL12})
+ find_package(SDL2 REQUIRED)
+ include_directories(${SDL2_INCLUDE_DIR})
+endif(${USESDL12})
+
include_directories(${PHYSFS_INCLUDE_DIR})
-include_directories(${SDL_INCLUDE_DIR})
include_directories(${LUA_INCLUDE_DIR})
## extra functions needed by Hedgewars