Blob Blame Raw
From 1b5a6fdbe6a1c9696ec85a9c774a1aea8ccf1672 Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Date: Tue, 27 Dec 2016 15:23:09 +0100
Subject: [PATCH] use pkg-config to find luajit

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
---
 cmake/Modules/FindLuaJIT.cmake | 38 +++++---------------------------------
 1 file changed, 5 insertions(+), 33 deletions(-)

diff --git a/cmake/Modules/FindLuaJIT.cmake b/cmake/Modules/FindLuaJIT.cmake
index e4335d83..f62fe8ac 100644
--- a/cmake/Modules/FindLuaJIT.cmake
+++ b/cmake/Modules/FindLuaJIT.cmake
@@ -6,39 +6,11 @@
 #
 # This module is similar to FindLua51.cmake except that it finds LuaJit instead.
 
-FIND_PATH(LUA_INCLUDE_DIR luajit.h
-	HINTS
-	$ENV{LUA_DIR}
-	PATH_SUFFIXES include/luajit-2.0 include/luajit-5_1-2.0 include
-	PATHS
-	~/Library/Frameworks
-	/Library/Frameworks
-	/sw # Fink
-	/opt/local # DarwinPorts
-	/opt/csw # Blastwave
-	/opt
-)
-
-FIND_LIBRARY(LUA_LIBRARY
-	NAMES luajit-5.1
-	HINTS
-	$ENV{LUA_DIR}
-	PATH_SUFFIXES lib64 lib
-	PATHS
-	~/Library/Frameworks
-	/Library/Frameworks
-	/sw
-	/opt/local
-	/opt/csw
-	/opt
-)
-
-IF(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/luajit.h")
-	FILE(STRINGS "${LUA_INCLUDE_DIR}/luajit.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"LuaJIT .+\"")
-
-	STRING(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"LuaJIT ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}")
-	UNSET(lua_version_str)
-ENDIF()
+find_package (PkgConfig REQUIRED)
+pkg_check_modules (LuaJIT QUIET REQUIRED luajit)
+set (LUA_LIBRARY ${LuaJIT_LIBRARIES})
+set (LUA_INCLUDE_DIR ${LuaJIT_INCLUDE_DIRS})
+set (LUA_VERSION_STRING ${LuaJIT_VERSION})
 
 INCLUDE(FindPackageHandleStandardArgs)
 # handle the QUIETLY and REQUIRED arguments and set LUAJIT_FOUND to TRUE if
-- 
2.11.0