diff options
author | Rolf Eike Beer <eike@sf-mail.de> | 2012-01-25 22:39:21 (GMT) |
---|---|---|
committer | Rolf Eike Beer <eike@sf-mail.de> | 2012-01-26 08:07:53 (GMT) |
commit | 49b69add60d6fcd56688e276c3a4010759dade05 (patch) | |
tree | b115340ac9db0c5925ed67d5b0caaca5634f7172 /Modules/FindLua51.cmake | |
parent | 208569f1da0cf2c481f4b377ad4fe542a3a74e2a (diff) | |
download | CMake-49b69add60d6fcd56688e276c3a4010759dade05.zip CMake-49b69add60d6fcd56688e276c3a4010759dade05.tar.gz CMake-49b69add60d6fcd56688e276c3a4010759dade05.tar.bz2 |
FindLua51: add version support
Diffstat (limited to 'Modules/FindLua51.cmake')
-rw-r--r-- | Modules/FindLua51.cmake | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Modules/FindLua51.cmake b/Modules/FindLua51.cmake index 123fd5d..b67dd4c 100644 --- a/Modules/FindLua51.cmake +++ b/Modules/FindLua51.cmake @@ -2,7 +2,8 @@ # This module defines # LUA51_FOUND, if false, do not try to link to Lua # 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 # #include "lua.h" @@ -66,10 +67,19 @@ IF(LUA_LIBRARY) ENDIF(UNIX AND NOT APPLE) 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) # handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if # 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) |