Skip to content

Commit

Permalink
cmake: allow to set a Lua library outside
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ligurio committed Dec 16, 2024
1 parent 92085b3 commit 13d8962
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ elseif (USE_LUAJIT)
include(BuildLuaJIT)
build_luajit(${LUA_VERSION})
set(IS_LUAJIT TRUE)
elseif (LUA_INCLUDE_DIR AND LUA_LIBRARIES AND LUA_EXECUTABLE)
message(STATUS "Lua library passed outside:")
message(STATUS "LUA_INCLUDE_DIR: ${LUA_INCLUDE_DIR}")
message(STATUS "LUA_LIBRARIES: ${LUA_LIBRARIES}")
message(STATUS "LUA_EXECUTABLE: ${LUA_EXECUTABLE}")

# When a path to a Lua library is passed outside, we should
# mimic a real CMake library to don't break code that depends on
# LUA_LIBRARIES.
add_library(bundled-liblua STATIC IMPORTED GLOBAL)
set_target_properties(bundled-liblua PROPERTIES
IMPORTED_LOCATION ${LUA_LIBRARIES})
set(LUA_LIBRARIES bundled-liblua)
else ()
message(FATAL_ERROR "No Lua is specified.")
endif ()
Expand Down

0 comments on commit 13d8962

Please sign in to comment.