# defines
#  LUAJIT_FOUND
#  LUAJIT_INCLUDE_DIRS
#  LUAJIT_LIBRARIES

find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
	pkg_check_modules(PC_LUAJIT QUIET luajit)
endif()

set(LUAJIT_DEFINITIONS ${PC_LUAJIT_CFLAGS_OTHER})

find_path(LUAJIT_INCLUDE_DIR luajit.h
	PATHS ${PC_LUAJIT_INCLUDEDIR} ${PC_LUAJIT_INCLUDE_DIRS}
	PATH_SUFFIXES luajit-2.0 luajit-2.1)

list(APPEND LUAJIT_NAMES luajit-5.1)

find_library(LUAJIT_LIBRARY NAMES ${LUAJIT_NAMES}
	PATHS ${PC_LUAJIT_LIBDIR} ${PC_LUAJIT_LIBRARY_DIRS})

set(LUAJIT_LIBRARIES ${LUAJIT_LIBRARY})
set(LUAJIT_INCLUDE_DIRS ${LUAJIT_INCLUDE_DIR})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LuaJit DEFAULT_MSG
	LUAJIT_LIBRARY LUAJIT_INCLUDE_DIR)

mark_as_advanced(LUAJIT_INCLUDE_DIR LUAJIT_LIBRARY)
