[Orxonox-commit 6443] r11100 - code/trunk/cmake/tools

muemart at orxonox.net muemart at orxonox.net
Thu Jan 28 15:56:24 CET 2016


Author: muemart
Date: 2016-01-28 15:56:24 +0100 (Thu, 28 Jan 2016)
New Revision: 11100

Modified:
   code/trunk/cmake/tools/FindLua5.1.cmake
Log:
Update FindLua5.1.cmake to work with newer versions. Also added another path suffix for include directories.

Modified: code/trunk/cmake/tools/FindLua5.1.cmake
===================================================================
--- code/trunk/cmake/tools/FindLua5.1.cmake	2016-01-27 17:50:51 UTC (rev 11099)
+++ code/trunk/cmake/tools/FindLua5.1.cmake	2016-01-28 14:56:24 UTC (rev 11100)
@@ -30,7 +30,7 @@
 INCLUDE(FindPackageHandleAdvancedArgs)
 INCLUDE(HandleLibraryTypes)
 
-# Macro that determines Lua version. Should work for versions 2.2 and above (current release: 5.1.4)
+# Macro that determines Lua version. Should work for versions 2.2 and above (current release: 5.3.2)
 FUNCTION(DETERMINE_LUA_VERSION _file _varname)
   IF(EXISTS ${_file})
     FILE(STRINGS ${_file} _file_content REGEX "LUA_VERSION|LUA_RELEASE")
@@ -43,7 +43,13 @@
     # At most version 5.1.0
     STRING(REGEX REPLACE "^.*LUA_VERSION[ \t]+\"Lua[ \t]+([.0-9]+)\".*$" "\\1" ${_varname} "${_file_content}")
     IF(${_varname} STREQUAL "${_file_content}")
-      MESSAGE(FATAL_ERROR "Could not determine Lua version which means this script has a bug")
+      # Last chance, search for LUA_VERSION_MAJOR and LUA_VERSION_MINOR
+      STRING(REGEX REPLACE "^.*LUA_VERSION_MAJOR[ \t]+\"([0-9]+)\".*$" "\\1" _major "${_file_content}")
+      STRING(REGEX REPLACE "^.*LUA_VERSION_MINOR[ \t]+\"([0-9]+)\".*$" "\\1" _minor "${_file_content}")
+      IF(_major STREQUAL "${_file_content}" OR _minor STREQUAL "${_file_content}")
+        MESSAGE(FATAL_ERROR "Could not determine Lua version which means this script has a bug")
+      ENDIF()
+      SET(${_varname} "${_major}.${_minor}")
     ENDIF()
     IF(${_varname} MATCHES "^[0-9]+\\.[0-9]+$")
       SET(${_varname} "${${_varname}}.0") # E.g. "3.2" is "3.2.0" actually
@@ -56,7 +62,7 @@
 # Find include path
 FIND_PATH(LUA5.1_INCLUDE_DIR lua.h
   PATHS $ENV{LUA5.1_DIR} $ENV{LUA_DIR}
-  PATH_SUFFIXES include/lua51 include/lua5.1 include/lua include
+  PATH_SUFFIXES lua5.1 include/lua51 include/lua5.1 include/lua include
 )
 
 # Check whether we really found Lua version 5.1




More information about the Orxonox-commit mailing list