replace sdl mixer/image version checking with something more robust
authorkoda
Wed, 06 Mar 2013 03:11:15 +0100
changeset 8661 ac8dba27a3f1
parent 8660 6370e545fd5f
child 8662 bfcc09f2accc
replace sdl mixer/image version checking with something more robust
cmake_modules/FindSDL_Extras.cmake
hedgewars/CMakeLists.txt
--- a/cmake_modules/FindSDL_Extras.cmake	Wed Mar 06 02:52:17 2013 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-#if the headers are not installed, the newer apis won't be activated
-
-#find which version of SDL_mixer we have (for Mix_Init)
-find_file(sdlmixer_h SDL_mixer.h ${SDLMIXER_INCLUDE_DIR})
-if(sdlmixer_h)
-    file(STRINGS ${sdlmixer_h} sdlmixer_majorversion_tmp REGEX "SDL_MIXER_MAJOR_VERSION[\t' ']+[0-9]+")
-    file(STRINGS ${sdlmixer_h} sdlmixer_minorversion_tmp REGEX "SDL_MIXER_MINOR_VERSION[\t' ']+[0-9]+")
-    file(STRINGS ${sdlmixer_h} sdlmixer_patchversion_tmp REGEX "SDL_MIXER_PATCHLEVEL[\t' ']+[0-9]+")
-    string(REGEX MATCH ".([0-9]+)" sdlmixer_majorversion "${sdlmixer_majorversion_tmp}")
-    string(REGEX MATCH ".([0-9]+)" sdlmixer_minorversion "${sdlmixer_minorversion_tmp}")
-    string(REGEX MATCH ".([0-9]+)" sdlmixer_patchversion "${sdlmixer_patchversion_tmp}")
-    math(EXPR sdlmixer_version "${sdlmixer_majorversion}*10000 + ${sdlmixer_minorversion}*100 + ${sdlmixer_patchversion}")
-
-    if(sdlmixer_version GREATER "10209")
-        message(STATUS "Mix_Init() is present")
-        list(APPEND pascal_flags "-dSDL_MIXER_NEWER")
-    endif()
-endif()
-
-#find which version of SDL_image we have (for IMG_Init)
-find_file(sdlimage_h SDL_image.h ${SDLIMAGE_INCLUDE_DIR})
-if(sdlimage_h)
-    file(STRINGS ${sdlimage_h} sdlimage_majorversion_tmp REGEX "SDL_IMAGE_MAJOR_VERSION[\t' ']+[0-9]+")
-    file(STRINGS ${sdlimage_h} sdlimage_minorversion_tmp REGEX "SDL_IMAGE_MINOR_VERSION[\t' ']+[0-9]+")
-    file(STRINGS ${sdlimage_h} sdlimage_patchversion_tmp REGEX "SDL_IMAGE_PATCHLEVEL[\t' ']+[0-9]+")
-    string(REGEX MATCH ".([0-9]+)" sdlimage_majorversion "${sdlimage_majorversion_tmp}")
-    string(REGEX MATCH ".([0-9]+)" sdlimage_minorversion "${sdlimage_minorversion_tmp}")
-    string(REGEX MATCH ".([0-9]+)" sdlimage_patchversion "${sdlimage_patchversion_tmp}")
-    math(EXPR sdlimage_version "${sdlimage_majorversion}*10000 + ${sdlimage_minorversion}*100 + ${sdlimage_patchversion}")
-
-    if(sdlimage_version GREATER "010207")
-        message(STATUS "IMG_Init() is present")
-        list(APPEND pascal_flags "-dSDL_IMAGE_NEWER")
-    endif()
-endif()
-
--- a/hedgewars/CMakeLists.txt	Wed Mar 06 02:52:17 2013 +0100
+++ b/hedgewars/CMakeLists.txt	Wed Mar 06 03:11:15 2013 +0100
@@ -4,7 +4,19 @@
 find_package(SDL_ttf)
 find_package(SDL_mixer)
 
-include(${CMAKE_SOURCE_DIR}/cmake_modules/FindSDL_Extras.cmake)
+
+include (CheckLibraryExists)
+#Mix_Init/Mix_Quit from SDL_mixer 1.2.9
+check_library_exists(${SDL_MIXER_LIBRARY} Mix_Init "" HAVE_MIXINIT) 
+if(HAVE_MIXINIT)
+    list(APPEND pascal_flags "-dSDL_MIXER_NEWER")
+endif()
+#IMG_Init/IMG_Quit from SDL_image 1.2.7
+check_library_exists(${SDL_IMAGE_LIBRARY} IMG_Init "" HAVE_IMGINIT)
+if(HAVE_IMGINIT)
+    list(APPEND pascal_flags "-dSDL_IMAGE_NEWER")
+endif()
+
 
 configure_file(${hedgewars_SOURCE_DIR}/hedgewars/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config.inc)