]> source.dussan.org Git - rspamd.git/commitdiff
[Rework] Remove old FindLua module, disable lua fallback when LuaJIT is enabled
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 17 May 2020 19:22:23 +0000 (20:22 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 17 May 2020 19:22:54 +0000 (20:22 +0100)
CMakeLists.txt
cmake/FindLua.cmake [deleted file]

index 478aee46bdd7e30f6c069b6f1d1f2918fc7cb516..2d7e21ff84914c1263b22c8bb71313b1c69fdb4f 100644 (file)
@@ -68,7 +68,6 @@ INCLUDE(CMakeParseArguments)
 INCLUDE(FindArch)
 INCLUDE(AsmOp)
 INCLUDE(FindRagel)
-INCLUDE(FindLua)
 INCLUDE(ProcessPackage)
 
 IF(NOT RAGEL_FOUND)
@@ -122,29 +121,53 @@ INCLUDE(OSDep)
 # Now find libraries and headers
 LIST(APPEND RSPAMD_REQUIRED_LIBRARIES "m")
 IF(ENABLE_LUAJIT MATCHES "ON")
-       #ProcessPackage(LUAJIT luajit)
-       SET(WITH_LUA 1)
-       FindLua(VERSION_MAJOR "5" VERSION_MINOR "1" ROOT "${LUA_ROOT}")
-       IF(NOT LUA_FOUND)
-               MESSAGE(FATAL_ERROR "Lua not found, lua support is required")
-       ELSE(NOT LUA_FOUND)
-               SET(WITH_LUA 1)
-               INCLUDE_DIRECTORIES("${LUA_INCLUDE_DIR}")
-       ENDIF(NOT LUA_FOUND)
+       ProcessPackage(LIBLUAJIT LIBRARY        "luajit"
+                                                                               "luajit-2.0"
+                                                                               "luajit2.0"
+                       INCLUDE luajit.h INCLUDE_SUFFIXES
+                                                                               "include/luajit-2.0"
+                                                                               "include/luajit-2.1"
+                                                                               "include/luajit"
+                       ROOT ${LUA_ROOT}
+                       MODULES luajit)
+       SET(WITH_LUAJIT 1)
 ELSE(ENABLE_LUAJIT MATCHES "ON")
-       FindLua(VERSION_MAJOR "5" VERSION_MINOR "3" ROOT "${LUA_ROOT}")
-       IF(NOT LUA_FOUND)
-               FindLua(VERSION_MAJOR "5" VERSION_MINOR "2" ROOT "${LUA_ROOT}")
-               IF(NOT LUA_FOUND)
-                               FindLua(VERSION_MAJOR "5" VERSION_MINOR "1" ROOT "${LUA_ROOT}")
-               ENDIF(NOT LUA_FOUND)
-       ENDIF(NOT LUA_FOUND)
-       IF(NOT LUA_FOUND)
-                       MESSAGE(FATAL_ERROR "Lua not found, lua support is required")
-       ELSE(NOT LUA_FOUND)
-                       SET(WITH_LUA 1)
-                       INCLUDE_DIRECTORIES("${LUA_INCLUDE_DIR}")
-       ENDIF(NOT LUA_FOUND)
+
+       ProcessPackage(LIBLUA LIBRARY   "lua"
+                       "lua-5.3"
+                       INCLUDE lua.h INCLUDE_SUFFIXES
+                       "include/lua-5.3"
+                       "include/lua5.3"
+                       "include/lua53"
+                       "include/lua"
+                       ROOT ${LUA_ROOT}
+                       MODULES lua53
+                       OPTIONAL)
+
+       IF (NOT LIBLUA_FOUND)
+               ProcessPackage(LIBLUA LIBRARY   "lua"
+                               "lua-5.2"
+                               INCLUDE lua.h INCLUDE_SUFFIXES
+                               "include/lua-5.2"
+                               "include/lua5.2"
+                               "include/lua52"
+                               "include/lua"
+                               ROOT ${LUA_ROOT}
+                               MODULES lua52
+                               OPTIONAL)
+
+               IF (NOT LIBLUA_FOUND)
+                       ProcessPackage(LIBLUA LIBRARY   "lua"
+                                       "lua-5.1"
+                                       INCLUDE lua.h INCLUDE_SUFFIXES
+                                       "include/lua-5.1"
+                                       "include/lua5.1"
+                                       "include/lua51"
+                                       "include/lua"
+                                       ROOT ${LUA_ROOT}
+                                       MODULES lua51)
+               ENDIF()
+       ENDIF()
 ENDIF(ENABLE_LUAJIT MATCHES "ON")
 
 IF(ENABLE_JEMALLOC MATCHES "ON" AND NOT SANITIZE)
diff --git a/cmake/FindLua.cmake b/cmake/FindLua.cmake
deleted file mode 100644 (file)
index 7aa3e8b..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-# Find lua installation
-MACRO(FindLua)
-    # Find lua libraries
-    UNSET(LUA_INCLUDE_DIR CACHE)
-    UNSET(LUA_LIBRARY CACHE)
-    CMAKE_PARSE_ARGUMENTS(LUA "" "VERSION_MAJOR;VERSION_MINOR;ROOT" "" ${ARGN})
-
-    IF(NOT LUA_VERSION_MAJOR OR NOT LUA_VERSION_MINOR)
-        MESSAGE(FATAL_ERROR "Invalid FindLua invocation: ${ARGN}")
-    ENDIF()
-
-    IF(ENABLE_LUAJIT MATCHES "ON")
-        MESSAGE(STATUS "Check for luajit ${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}")
-        FIND_PATH(LUA_INCLUDE_DIR luajit.h
-                HINTS
-                "${RSPAMD_SEARCH_PATH}" "${LUA_ROOT}"
-                $ENV{LUA_DIR}
-                PATH_SUFFIXES "include/luajit-2.0"
-                "include/luajit-2.1"
-                "include/luajit${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}"
-                "include/luajit${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
-                "include/luajit-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
-                "include/luajit-${LUA_VERSION_MAJOR}_${LUA_VERSION_MINOR}-2.0"
-                "include/luajit-${LUA_VERSION_MAJOR}_${LUA_VERSION_MINOR}-2.1"
-                "include/luajit"
-                "include/lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}"
-                "include/lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
-                "include/lua-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
-                include/lua include
-                PATHS ${RSPAMD_DEFAULT_INCLUDE_PATHS}
-                )
-        FIND_LIBRARY(LUA_LIBRARY
-                NAMES luajit
-                "luajit-2.0"
-                "luajit2.0"
-                "luajit${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}"
-                "luajit${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
-                "luajit-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
-                HINTS
-                "${RSPAMD_SEARCH_PATH}" "${LUA_ROOT}"
-                $ENV{LUA_DIR}
-                PATH_SUFFIXES lib64 lib
-                PATHS ${RSPAMD_DEFAULT_LIBRARY_PATHS}
-                DOC "Lua library"
-                )
-
-        IF(NOT LUA_LIBRARY OR NOT LUA_INCLUDE_DIR)
-            MESSAGE(STATUS "Fallback from luajit to plain lua")
-            SET(ENABLE_LUAJIT "OFF")
-            MESSAGE(STATUS "Check for lua ${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}")
-            FIND_PATH(LUA_INCLUDE_DIR lua.h
-                    HINTS
-                    "${RSPAMD_SEARCH_PATH}" "${LUA_ROOT}"
-                    $ENV{LUA_DIR}
-                    PATH_SUFFIXES "include/lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}"
-                    "include/lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
-                    "include/lua-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
-                    include/lua include
-                    PATHS ${RSPAMD_DEFAULT_INCLUDE_PATHS}
-                    )
-            FIND_LIBRARY(LUA_LIBRARY
-                    NAMES lua
-                    "lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}"
-                    "lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
-                    "lua-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
-                    HINTS
-                    "${RSPAMD_SEARCH_PATH}" "${LUA_ROOT}"
-                    $ENV{LUA_DIR}
-                    PATH_SUFFIXES lib64 lib
-                    PATHS ${RSPAMD_DEFAULT_LIBRARY_PATHS}
-                    DOC "Lua library"
-                    )
-        ELSE()
-            SET(WITH_LUAJIT 1)
-        ENDIF()
-    ELSE(ENABLE_LUAJIT MATCHES "ON")
-        MESSAGE(STATUS "Check for lua ${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}")
-        FIND_PATH(LUA_INCLUDE_DIR lua.h
-                HINTS
-                "${RSPAMD_SEARCH_PATH}" "${LUA_ROOT}"
-                $ENV{LUA_DIR}
-                PATH_SUFFIXES "include/lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}"
-                "include/lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
-                "include/lua-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
-                include/lua include
-                PATHS ${RSPAMD_DEFAULT_INCLUDE_PATHS}
-                )
-        FIND_LIBRARY(LUA_LIBRARY
-                NAMES lua
-                "lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}"
-                "lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
-                "lua-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}"
-                HINTS
-                "${RSPAMD_SEARCH_PATH}" "${LUA_ROOT}"
-                $ENV{LUA_DIR}
-                PATH_SUFFIXES lib64 lib
-                PATHS ${RSPAMD_DEFAULT_LIBRARY_PATHS}
-                DOC "Lua library"
-                )
-    ENDIF(ENABLE_LUAJIT MATCHES "ON")
-
-    IF(LUA_LIBRARY AND LUA_INCLUDE_DIR)
-        SET(LUA_FOUND 1)
-        IF(NOT LUA_VERSION_MAJOR OR NOT LUA_VERSION_MINOR)
-            SET(LUA_VERSION_MAJOR ${LUA_VERSION_MAJOR})
-            SET(LUA_VERSION_MINOR ${LUA_VERSION_MINOR})
-        ENDIF(NOT LUA_VERSION_MAJOR OR NOT LUA_VERSION_MINOR)
-        IF(ENABLE_LUAJIT MATCHES "ON")
-            MESSAGE(STATUS "Found luajit ${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR} in lib:${LUA_LIBRARY}, headers:${LUA_INCLUDE_DIR}")
-        ELSE(ENABLE_LUAJIT MATCHES "ON")
-            MESSAGE(STATUS "Found lua ${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR} in lib:${LUA_LIBRARY}, headers:${LUA_INCLUDE_DIR}")
-        ENDIF(ENABLE_LUAJIT MATCHES "ON")
-    ENDIF(LUA_LIBRARY AND LUA_INCLUDE_DIR)
-ENDMACRO()
\ No newline at end of file