diff options
author | Peter Wu <peter@lekensteyn.nl> | 2015-11-15 00:27:53 +0100 |
---|---|---|
committer | Bill Meier <wmeier@newsguy.com> | 2015-11-15 20:15:41 +0000 |
commit | 67ad1de0d06128c9eda70adb3f172c8b7ff4d6b6 (patch) | |
tree | 70b6396ddae195d2ff68343988fc6793eb067e15 /cmake/modules | |
parent | a8e774034b188662f29a41e3ff86ec96068bd025 (diff) |
FindLUA.cmake: reject version 5.3
Lua 5.3 could still be used when located at /usr/include/lua.h. Detect
and reject it in that case.
Rename LUA_VERSION to LUA_VERSION_NUM to avoid a conflict with
pkg-config (which uses a different version format). Ensure that the
regex matches a number only.
Bug: 11706
Change-Id: Idb7e3e1a8d9c6e4ab9ab1816c4dedea7de9dde8e
Reviewed-on: https://code.wireshark.org/review/11836
Reviewed-by: Bill Meier <wmeier@newsguy.com>
Diffstat (limited to 'cmake/modules')
-rw-r--r-- | cmake/modules/FindLUA.cmake | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/cmake/modules/FindLUA.cmake b/cmake/modules/FindLUA.cmake index 195b2f86da..3c399cd386 100644 --- a/cmake/modules/FindLUA.cmake +++ b/cmake/modules/FindLUA.cmake @@ -41,11 +41,12 @@ FIND_PATH(LUA_INCLUDE_DIR lua.h ) if(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h") - file(STRINGS "${LUA_INCLUDE_DIR}/lua.h" LUA_VERSION REGEX "LUA_VERSION_NUM") - if (LUA_VERSION) - string(REGEX REPLACE "^#define[ \t]+LUA_VERSION_NUM[ \t]+(.+)" "\\1" LUA_VERSION "${LUA_VERSION}") + file(STRINGS "${LUA_INCLUDE_DIR}/lua.h" LUA_VERSION_NUM REGEX "LUA_VERSION_NUM") + if (LUA_VERSION_NUM) + string(REGEX REPLACE "^#define[ \t]+LUA_VERSION_NUM[ \t]+([0-9]+)" "\\1" + LUA_VERSION_NUM "${LUA_VERSION_NUM}") else() - set( LUA_VERSION "500") + set( LUA_VERSION_NUM "500") endif() endif() string( REGEX REPLACE ".*[/\\]lua(.+)$" "\\1" LUA_INC_SUFFIX "${LUA_INCLUDE_DIR}" ) @@ -58,23 +59,30 @@ FIND_LIBRARY(LUA_LIBRARY HINTS "${LUA_LIBDIR}" "$ENV{LUA_DIR}" - ${LUA_HINTS} + ${LUA_HINTS} PATH_SUFFIXES lib64 lib PATHS - ~/Library/Frameworks - /Library/Frameworks - /usr/local - /usr - /sw - /opt/local - /opt/csw - /opt + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw + /opt/local + /opt/csw + /opt ) +# Lua 5.3 is not supported, only 5.0/5.1/5.2 are (due to bitops problem) +if(LUA_VERSION_NUM GREATER 502) + set(LUA_VERSION_NUM) +endif() + INCLUDE(FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if # all listed variables are TRUE -FIND_PACKAGE_HANDLE_STANDARD_ARGS(LUA DEFAULT_MSG LUA_LIBRARY LUA_INCLUDE_DIR) +find_package_handle_standard_args(LUA + REQUIRED_VARS LUA_LIBRARY LUA_INCLUDE_DIR LUA_VERSION_NUM + VERSION_VAR LUA_VERSION_NUM) IF(LUA_LIBRARY) SET( LUA_LIBRARIES "${LUA_LIBRARY}") |