47 lines
1.2 KiB
CMake
Raw Permalink Normal View History

2021-10-14 13:47:35 +02:00
# ---------------------------------
# Finds LUA
# Adds library to target
# Adds include path
# ---------------------------------
GET_PROPERTY(OV_PRINTED GLOBAL PROPERTY OV_TRIED_ThirdPartyLua)
IF(WIN32)
FIND_PATH(LUA_INCLUDE_DIR lua.h PATHS ${LIST_DEPENDENCIES_PATH} PATH_SUFFIXES lua/include NO_DEFAULT_PATH)
ELSEIF(UNIX)
if(${CMAKE_SYSTEM} MATCHES fc21)
FIND_PACKAGE(Lua REQUIRED)
else ()
FIND_PACKAGE(Lua51 REQUIRED)
endif()
ENDIF()
IF(LUA_INCLUDE_DIR)
OV_PRINT(OV_PRINTED " Found Lua... in '${LUA_INCLUDE_DIR}'")
IF(WIN32)
FIND_LIBRARY(LUA_LIBRARIES lua5.1 PATHS ${LUA_INCLUDE_DIR}/../lib NO_DEFAULT_PATH)
FIND_LIBRARY(LUA_LIBRARIES lua5.1 PATHS ${LUA_INCLUDE_DIR}/../lib)
ENDIF()
IF(LUA_LIBRARIES)
OV_PRINT(OV_PRINTED " [ OK ] lib ${LUA_LIBRARIES}")
INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LUA_LIBRARIES})
ADD_DEFINITIONS(-DTARGET_HAS_ThirdPartyLua)
IF(WIN32)
INSTALL(FILES "${LUA_INCLUDE_DIR}/../bin/lua5.1.dll" DESTINATION "${DIST_BINDIR}")
ENDIF()
ELSE()
OV_PRINT(OV_PRINTED " [FAILED] lib lua5.1")
ENDIF()
ELSE()
OV_PRINT(OV_PRINTED " FAILED to find Lua")
ENDIF()
SET_PROPERTY(GLOBAL PROPERTY OV_TRIED_ThirdPartyLua "Yes")