From 353ccfb0dde0dc5c264595f9d17e47a23c82bcdf Mon Sep 17 00:00:00 2001 From: Lucas Schwiderski Date: Sat, 6 Mar 2021 12:03:24 +0100 Subject: [PATCH] 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 ``` --- awesomeConfig.cmake | 9 +++++---- tests/examples/CMakeLists.txt | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/awesomeConfig.cmake b/awesomeConfig.cmake index 5e341abc..34353729 100644 --- a/awesomeConfig.cmake +++ b/awesomeConfig.cmake @@ -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 diff --git a/tests/examples/CMakeLists.txt b/tests/examples/CMakeLists.txt index 3d2a81ed..1494a74e 100644 --- a/tests/examples/CMakeLists.txt +++ b/tests/examples/CMakeLists.txt @@ -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)