Skip to content

Commit 9d68fcd

Browse files
committed
rockspec: propagate CMake options
Sometimes one needs to build a luzer module using rockspec with a non-system Lua library and headers, for which the CMake options LUA_LIBRARIES and LUA_INCLUDE_DIR are used. The patch adds variables for the rockspec to set these options via environment variables: CMAKE_LUA_LIBRARIES, CMAKE_LUA_INCLUDE_DIR, ENABLE_LUAJIT and LUAJIT_FRIENDLY_MODE. luarocks install --lua-version 5.1 --verbose --tree=lua_modules \ luzer-scm-1.rockspec ENABLE_LUAJIT=ON LUAJIT_FRIENDLY_MODE=ON Needed for google/oss-fuzz#14610
1 parent 545028b commit 9d68fcd

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ endif()
1616
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
1717
include(SetClangRTLib)
1818

19+
# It is not possible to pass LUA_LIBRARIES and LUA_INCLUDE_DIR
20+
# directly because it breaks `find_package(Lua)`, so it is done
21+
# using intermediate variables.
22+
if(NOT "${CMAKE_LUA_LIBRARIES}" STREQUAL "")
23+
set(LUA_LIBRARIES "${CMAKE_LUA_LIBRARIES}")
24+
endif()
25+
if(NOT "${CMAKE_LUA_INCLUDE_DIR}" STREQUAL "")
26+
set(LUA_INCLUDE_DIR "${CMAKE_LUA_INCLUDE_DIR}")
27+
endif()
28+
1929
if(LUA_INCLUDE_DIR AND LUA_LIBRARIES)
2030
# When a path to a Lua library is passed outside, we should
2131
# mimic a real CMake library to don't break code that depends on

luzer-scm-1.rockspec

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ build = {
2626
-- https://github.com/luarocks/luarocks/blob/7ed653f010671b3a7245be9adcc70068c049ef68/docs/config_file_format.md#config-file-format
2727
-- luacheck: pop
2828
variables = {
29+
ENABLE_LUAJIT = "$(ENABLE_LUAJIT)",
30+
LUAJIT_FRIENDLY_MODE = "$(LUAJIT_FRIENDLY_MODE)",
31+
CMAKE_LUA_INCLUDE_DIR = "$(LUA_INCLUDE_DIR)",
32+
CMAKE_LUA_LIBRARIES = "$(LUA_LIBRARIES)",
2933
CMAKE_LUADIR = "$(LUADIR)",
3034
CMAKE_LIBDIR = "$(LIBDIR)",
3135
CMAKE_BUILD_TYPE = "RelWithDebInfo",

0 commit comments

Comments
 (0)