cmake_modules/FindSDL1or2.cmake
branchsdl2transition
changeset 11361 31570b766315
parent 11360 7a7611adf715
child 11362 ed5a6478e710
equal deleted inserted replaced
11360:7a7611adf715 11361:31570b766315
     1 find_package(SDL QUIET)
       
     2 
       
     3 if(NOT SDL_FOUND)
       
     4     find_package(SDL2 REQUIRED)
       
     5     set(SDL_INCLUDE_DIR ${SDL2_INCLUDE_DIR})
       
     6     set(SDL_LIBRARY ${SDL2_LIBRARY})
       
     7 endif()
       
     8 
       
     9 if(NOT SDL_VERSION)
       
    10     #find which version of SDL we have
       
    11     find_file(sdlversion_h SDL_version.h ${SDL_INCLUDE_DIR})
       
    12     if(sdlversion_h)
       
    13         file(STRINGS ${sdlversion_h} sdl_majorversion_tmp REGEX "SDL_MAJOR_VERSION[\t' ']+[0-9]+")
       
    14         file(STRINGS ${sdlversion_h} sdl_minorversion_tmp REGEX "SDL_MINOR_VERSION[\t' ']+[0-9]+")
       
    15         file(STRINGS ${sdlversion_h} sdl_patchversion_tmp REGEX "SDL_PATCHLEVEL[\t' ']+[0-9]+")
       
    16         string(REGEX MATCH "([0-9]+)" sdl_majorversion "${sdl_majorversion_tmp}")
       
    17         string(REGEX MATCH "([0-9]+)" sdl_minorversion "${sdl_minorversion_tmp}")
       
    18         string(REGEX MATCH "([0-9]+)" sdl_patchversion "${sdl_patchversion_tmp}")
       
    19         set(SDL_VERSION "${sdl_majorversion}.${sdl_minorversion}.${sdl_patchversion}")
       
    20     endif()
       
    21 endif()
       
    22 
       
    23 mark_as_advanced(sdlversion_h sdl_majorversion sdl_minorversion sdl_patchversion)
       
    24