FindSDL: Add version support for FindSDL_ttf
This commit is contained in:
parent
a28c24726b
commit
4541c07864
|
@ -58,13 +58,30 @@ find_library(SDL_TTF_LIBRARY
|
||||||
PATH_SUFFIXES lib
|
PATH_SUFFIXES lib
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(SDL_TTF_INCLUDE_DIR AND EXISTS "${SDL_TTF_INCLUDE_DIR}/SDL_ttf.h")
|
||||||
|
file(STRINGS "${SDL_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL_TTF_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+[0-9]+$")
|
||||||
|
file(STRINGS "${SDL_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL_TTF_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+[0-9]+$")
|
||||||
|
file(STRINGS "${SDL_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL_TTF_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+[0-9]+$")
|
||||||
|
string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_TTF_VERSION_MAJOR "${SDL_TTF_VERSION_MAJOR_LINE}")
|
||||||
|
string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_TTF_VERSION_MINOR "${SDL_TTF_VERSION_MINOR_LINE}")
|
||||||
|
string(REGEX REPLACE "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_TTF_VERSION_PATCH "${SDL_TTF_VERSION_PATCH_LINE}")
|
||||||
|
set(SDL_TTF_VERSION_STRING ${SDL_TTF_VERSION_MAJOR}.${SDL_TTF_VERSION_MINOR}.${SDL_TTF_VERSION_PATCH})
|
||||||
|
unset(SDL_TTF_VERSION_MAJOR_LINE)
|
||||||
|
unset(SDL_TTF_VERSION_MINOR_LINE)
|
||||||
|
unset(SDL_TTF_VERSION_PATCH_LINE)
|
||||||
|
unset(SDL_TTF_VERSION_MAJOR)
|
||||||
|
unset(SDL_TTF_VERSION_MINOR)
|
||||||
|
unset(SDL_TTF_VERSION_PATCH)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(SDL_TTF_LIBRARIES ${SDL_TTF_LIBRARY})
|
set(SDL_TTF_LIBRARIES ${SDL_TTF_LIBRARY})
|
||||||
set(SDL_TTF_INCLUDE_DIRS ${SDL_TTF_INCLUDE_DIR})
|
set(SDL_TTF_INCLUDE_DIRS ${SDL_TTF_INCLUDE_DIR})
|
||||||
|
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
||||||
|
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL_ttf
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL_ttf
|
||||||
REQUIRED_VARS SDL_TTF_LIBRARIES SDL_TTF_INCLUDE_DIRS)
|
REQUIRED_VARS SDL_TTF_LIBRARIES SDL_TTF_INCLUDE_DIRS
|
||||||
|
VERSION_VAR SDL_TTF_VERSION_STRING)
|
||||||
|
|
||||||
# for backward compatiblity
|
# for backward compatiblity
|
||||||
set(SDLTTF_LIBRARY ${SDL_TTF_LIBRARIES})
|
set(SDLTTF_LIBRARY ${SDL_TTF_LIBRARIES})
|
||||||
|
|
Loading…
Reference in New Issue