INCLUDE(FindPackageHandleStandardArgs)

FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(PC_LUA52 QUIET lua52)

IF (NOT LUA_INCLUDE_DIR)
    FIND_PATH(LUA_INCLUDE_DIR lua.h
        HINTS $ENV{LUA_DIR} ${PC_LUA52_INCLUDEDIR} ${PC_LUA52_INCLUDE_DIRS}
        PATH_SUFFIXES lua5.2
    )
ENDIF()

IF (NOT LUA_LIBRARIES)
    FIND_LIBRARY(LUA_LIBRARIES lua5.2
        HINTS $ENV{LUA_DIR} ${PC_LUA52_LIBDIR} ${PC_LUA52_LIB_DIRS}
    )
ENDIF()

MARK_AS_ADVANCED(LUA_INCLUDE_DIR)
MARK_AS_ADVANCED(LUA_LIBRARIES)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(
    Lua
    DEFAULT_MSG
    LUA_LIBRARIES
    LUA_INCLUDE_DIR
)

