Skip to content

Commit 4a4a507

Browse files
committed
cmake: allow to set a Lua library outside
The project builds Lua libraries for two the most popular Lua implementations: PUC Rio Lua and LuaJIT. However, integration with other implementations are interesting as well (like Tarantool, LuaVela, OpenResty etc.). The patch enables integration with other Lua libraries by setting `LUA_INCLUDE_DIR`, `LUA_LIBRARIES` and `LUA_EXECUTABLE` (yes, it is required too). Needed for tarantool/tarantool#10911
1 parent ff20482 commit 4a4a507

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ elseif (USE_LUAJIT)
5151
include(BuildLuaJIT)
5252
build_luajit(${LUA_VERSION})
5353
set(IS_LUAJIT TRUE)
54+
elseif (LUA_INCLUDE_DIR AND LUA_LIBRARIES AND LUA_EXECUTABLE)
55+
message(STATUS "Lua library passed outside:")
56+
message(STATUS "LUA_INCLUDE_DIR: ${LUA_INCLUDE_DIR}")
57+
message(STATUS "LUA_LIBRARIES: ${LUA_LIBRARIES}")
58+
message(STATUS "LUA_EXECUTABLE: ${LUA_EXECUTABLE}")
59+
60+
# When a path to a Lua library is passed outside, we should
61+
# mimic a real CMake library to don't break code that depends on
62+
# LUA_LIBRARIES.
63+
add_library(bundled-liblua STATIC IMPORTED GLOBAL)
64+
set_target_properties(bundled-liblua PROPERTIES
65+
IMPORTED_LOCATION ${LUA_LIBRARIES})
66+
set(LUA_LIBRARIES bundled-liblua)
5467
else ()
5568
message(FATAL_ERROR "No Lua is specified.")
5669
endif ()

0 commit comments

Comments
 (0)