cmake: only set LUA_PRG with successful check (#11172)

This is relevant for when using `USE_BUNDLED_LUAJIT=ON` with
`USE_BUNDLED_LUAROCKS=OFF`, and then building without the necessary modules
being installed/activated there yet: it would check the other (system) "lua"
interpreters also, and in case all failed keep the `LUA_PRG` in the cache for
the last failed entry - making it not re-check the previous ones on the next
build (after you might have activated your custom LuaRocks installation).

Only setting LUA_PRG if the check was successful handles the case better where
it is configured already - we should not try to re-configure it then.
Este commit está contenido en:
Daniel Hahler 2019-10-07 17:42:40 +02:00 cometido por GitHub
padre dfed0e60d7
commit 7faa6c41c8
No se encontró ninguna clave conocida en la base de datos para esta firma
ID de clave GPG: 4AEE18F83AFDEB23
Se han modificado 1 ficheros con 6 adiciones y 5 borrados

Ver fichero

@ -487,18 +487,19 @@ include(LuaHelpers)
set(LUA_DEPENDENCIES lpeg mpack bit)
if(NOT LUA_PRG)
foreach(CURRENT_LUA_PRG luajit lua5.1 lua5.2 lua)
# If LUA_PRG is set find_program() will not search
unset(LUA_PRG CACHE)
unset(_CHECK_LUA_PRG CACHE)
unset(LUA_PRG_WORKS)
find_program(LUA_PRG ${CURRENT_LUA_PRG})
find_program(_CHECK_LUA_PRG ${CURRENT_LUA_PRG})
if(LUA_PRG)
check_lua_deps(${LUA_PRG} "${LUA_DEPENDENCIES}" LUA_PRG_WORKS)
if(_CHECK_LUA_PRG)
check_lua_deps(${_CHECK_LUA_PRG} "${LUA_DEPENDENCIES}" LUA_PRG_WORKS)
if(LUA_PRG_WORKS)
set(LUA_PRG "${_CHECK_LUA_PRG}" CACHE FILEPATH "Path to a program.")
break()
endif()
endif()
endforeach()
unset(_CHECK_LUA_PRG CACHE)
else()
check_lua_deps(${LUA_PRG} "${LUA_DEPENDENCIES}" LUA_PRG_WORKS)
endif()