Skip to content

Commit 6f9c893

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 or set other CMake options before building. The patch adds variables for the rockspec to set the following CMake options via environment variables: ENABLE_LUAJIT, LUAJIT_FRIENDLY_MODE and OSS_FUZZ: luarocks install --tree=lua_modules luzer-scm-1.rockspec \ ENABLE_LUAJIT=ON LUAJIT_FRIENDLY_MODE=ON The patch also renames CMake variables used for setting a custom Lua library and Lua include directory: LUA_LIBRARIES to CMAKE_LUA_LIBRARIES and LUA_INCLUDE_DIR to CMAKE_LUA_INCLUDE_DIR. This is needed because with empty environment variables LUA_LIBRARIES and LUA_INCLUDE_DIR passed to luarocks breaks CMake module for finding Lua package: CMake Error at /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message): Could NOT find Lua (missing: LUA_LIBRARIES LUA_INCLUDE_DIR) (Required is at least version "5.1") Call Stack (most recent call first): /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE) /usr/share/cmake-3.28/Modules/FindLua.cmake:236 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) CMakeLists.txt:49 (find_package) After renaming these options can be specified for luarocks. The patch also sorts variables in alphabetical order. Needed for google/oss-fuzz#14610
1 parent a0ecdf9 commit 6f9c893

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424
- Support OSS Fuzz environment (#73).
2525
- Support for building on Ubuntu 24.04 AArch64 (ARM64).
2626
- Support for building on macOS ARM64.
27+
- Add `ENABLE_LUAJIT`, `LUAJIT_FRIENDLY_MODE` and `OSS_FUZZ`
28+
variables to the rockspec.
2729

2830
### Changed
2931

@@ -34,6 +36,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3436
`consume_numbers()` instead `double`.
3537
- Method `oneof()` in FuzzedDataProvider returns an item's index
3638
as a second value.
39+
- Rename CMake option `LUA_LIBRARIES` to `CMAKE_LUA_LIBRARIES` and
40+
`LUA_INCLUDE_DIR` to `CMAKE_LUA_INCLUDE_DIR`.
3741

3842
### Fixed
3943

CMakeLists.txt

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

19-
if(LUA_INCLUDE_DIR AND LUA_LIBRARIES)
19+
if(CMAKE_LUA_INCLUDE_DIR AND CMAKE_LUA_LIBRARIES)
2020
# When a path to a Lua library is passed outside, we should
2121
# mimic a real CMake library to don't break code that depends on
2222
# LUA_LIBRARIES.
2323
add_library(liblua STATIC IMPORTED GLOBAL)
2424
set_target_properties(liblua PROPERTIES
25-
IMPORTED_LOCATION ${LUA_LIBRARIES})
25+
IMPORTED_LOCATION ${CMAKE_LUA_LIBRARIES})
2626
set(LUA_LIBRARIES liblua)
2727
set(LUA_FOUND TRUE)
2828
elseif(ENABLE_LUAJIT)

luzer-scm-1.rockspec

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ build = {
2626
-- https://github.com/luarocks/luarocks/blob/7ed653f010671b3a7245be9adcc70068c049ef68/docs/config_file_format.md#config-file-format
2727
-- luacheck: pop
2828
variables = {
29-
CMAKE_LUADIR = "$(LUADIR)",
30-
CMAKE_LIBDIR = "$(LIBDIR)",
3129
CMAKE_BUILD_TYPE = "RelWithDebInfo",
3230
CMAKE_C_COMPILER = "clang",
3331
CMAKE_CXX_COMPILER = "clang++",
32+
CMAKE_LIBDIR = "$(LIBDIR)",
33+
CMAKE_LUADIR = "$(LUADIR)",
34+
ENABLE_LUAJIT = "$(ENABLE_LUAJIT)",
35+
LUAJIT_FRIENDLY_MODE = "$(LUAJIT_FRIENDLY_MODE)",
36+
OSS_FUZZ = "$(OSS_FUZZ)",
3437
},
3538
}

0 commit comments

Comments
 (0)