Make CMake Lua executable customizable

Some platforms, such as Arch Linux, already moved to Lua 5.4, while
offering Lua 5.3 as a separate executable, such as `/usr/bin/lua5.3`.
To be able to build awesomeWM on these platforms without extensive
shims, this change introduces a new CMake variable `LUA_EXECUTABLE`.

Its default is set by `find_program` to the usual `/usr/bin/lua`,
but allows running CMake like this:

```sh
cmake ../ \
    -DLUA_INCLUDE_DIR=/usr/include/lua5.3 \
    -DLUA_LIBRARY=/usr/lib/liblua.so.5.3 \
    -DLUA_EXECUTABLE=/usr/bin/lua5.3
```
This commit is contained in:
Lucas Schwiderski 2021-03-06 12:03:24 +01:00
parent aeb2d85dad
commit 353ccfb0dd
No known key found for this signature in database
GPG key ID: AA12679AAA6DF4D8
2 changed files with 8 additions and 7 deletions

View file

@ -33,6 +33,7 @@ macro(a_find_program var prg req)
endif()
endmacro()
a_find_program(LUA_EXECUTABLE lua TRUE)
a_find_program(GIT_EXECUTABLE git FALSE)
# programs needed for man pages
a_find_program(ASCIIDOCTOR_EXECUTABLE asciidoctor FALSE)
@ -374,7 +375,7 @@ add_custom_command(TARGET setup_directories
add_custom_command(
OUTPUT ${BUILD_DIR}/docs/06-appearance.md
COMMAND lua ${SOURCE_DIR}/docs/06-appearance.md.lua
COMMAND ${LUA_EXECUTABLE} ${SOURCE_DIR}/docs/06-appearance.md.lua
${BUILD_DIR}/docs/06-appearance.md
DEPENDS
lgi-check-run
@ -385,7 +386,7 @@ add_custom_command(
foreach(RULE_TYPE client tag screen notification)
add_custom_command(
OUTPUT ${BUILD_DIR}/docs/common/${RULE_TYPE}_rules_index.ldoc
COMMAND lua ${SOURCE_DIR}/docs/build_rules_index.lua
COMMAND ${LUA_EXECUTABLE} ${SOURCE_DIR}/docs/build_rules_index.lua
${BUILD_DIR}/docs/common/${RULE_TYPE}_rules_index.ldoc
${RULE_TYPE}
@ -405,7 +406,7 @@ endforeach()
add_custom_command(
OUTPUT ${BUILD_DIR}/awesomerc.lua ${BUILD_DIR}/docs/05-awesomerc.md
${BUILD_DIR}/script_files/rc.lua
COMMAND lua ${SOURCE_DIR}/docs/05-awesomerc.md.lua
COMMAND ${LUA_EXECUTABLE} ${SOURCE_DIR}/docs/05-awesomerc.md.lua
${BUILD_DIR}/docs/05-awesomerc.md ${SOURCE_DIR}/awesomerc.lua
${BUILD_DIR}/awesomerc.lua
${BUILD_DIR}/script_files/rc.lua
@ -414,7 +415,7 @@ add_custom_command(
add_custom_command(
OUTPUT ${BUILD_DIR}/script_files/theme.lua
COMMAND lua ${SOURCE_DIR}/docs/sample_theme.lua ${BUILD_DIR}/script_files/
COMMAND ${LUA_EXECUTABLE} ${SOURCE_DIR}/docs/sample_theme.lua ${BUILD_DIR}/script_files/
)
# Create a target for the auto-generated awesomerc.lua and other files

View file

@ -17,7 +17,7 @@ endif()
cmake_minimum_required(VERSION 3.0.0)
# Get and update the LUA_PATH so the scripts can be executed without awesome.
execute_process(COMMAND lua -e "p = package.path:gsub(';', '\\\\;'); io.stdout:write(p)"
execute_process(COMMAND ${LUA_EXECUTABLE} -e "p = package.path:gsub(';', '\\\\;'); io.stdout:write(p)"
OUTPUT_VARIABLE "LUA_PATH_")
# Allow to use the example tests by themselves.
@ -40,9 +40,9 @@ if (DO_COVERAGE)
message(${TEST_ERROR})
message(FATAL_ERROR "Failed to run luacov.runner.")
endif()
set(LUA_COV_RUNNER lua "-erequire('luacov.runner')('${TOP_SOURCE_DIR}/.luacov')")
set(LUA_COV_RUNNER ${LUA_EXECUTABLE} "-erequire('luacov.runner')('${TOP_SOURCE_DIR}/.luacov')")
else()
set(LUA_COV_RUNNER lua)
set(LUA_COV_RUNNER ${LUA_EXECUTABLE})
endif()
if (STRICT_TESTS)