FindLua51: add version support

This commit is contained in:
Rolf Eike Beer 2012-01-25 23:39:21 +01:00
parent 208569f1da
commit 49b69add60
1 changed files with 12 additions and 2 deletions

View File

@ -2,7 +2,8 @@
# This module defines # This module defines
# LUA51_FOUND, if false, do not try to link to Lua # LUA51_FOUND, if false, do not try to link to Lua
# LUA_LIBRARIES # LUA_LIBRARIES
# LUA_INCLUDE_DIR, where to find lua.h # LUA_INCLUDE_DIR, where to find lua.h
# LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
# #
# Note that the expected include convention is # Note that the expected include convention is
# #include "lua.h" # #include "lua.h"
@ -66,10 +67,19 @@ IF(LUA_LIBRARY)
ENDIF(UNIX AND NOT APPLE) ENDIF(UNIX AND NOT APPLE)
ENDIF(LUA_LIBRARY) ENDIF(LUA_LIBRARY)
IF(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
FILE(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua .+\"")
STRING(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}")
UNSET(lua_version_str)
ENDIF()
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if # handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
# all listed variables are TRUE # all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua51 DEFAULT_MSG LUA_LIBRARIES LUA_INCLUDE_DIR) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua51
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
VERSION_VAR LUA_VERSION_STRING)
MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY) MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY)