Add `cmake_lua` for supporting running Lua script
Since #19863's scope is quite big, and looks to be dormant, I would like to have a stab at this. As suggested by @brad.king, a cmake_lua
command should be the first step for making Lua an alternative scripting language for CMake. Therefore, I would like to propose the following design.
Lua version
We should stick to Lua 5.1, specifically LuaJIT. This reduces the effort to keep up with the new changes made to Lua, since Lua does not guarantee backward compatibility, and Lua 5.1 itself is a good enough language for build system scripting.
Signatures
cmake_lua(FILE file_path)
cmake_lua(CODE lua_code)
Minimum feature
First, we disable the standard library so for now, we don't have to deal with all the nuance details. After that, as a step to introduce Lua code inside CMake code, I think from the Lua side, it needs to be able to read values of CMake's variables, and have access to CMake's set
function. This means that Lua has access to variables of the current scope of the cmake_lua
call side.