FindLua: Fix error when LUA_INCLUDE_PREFIX is set as a variable
Avoid errors like:
CMake Error at /usr/local/share/cmake-3.11/Modules/FindLua.cmake:88 (file):
file STRINGS file "/usr/include/lua/lua.h" cannot be read.
Call Stack (most recent call first):
/usr/local/share/cmake-3.11/Modules/FindLua.cmake:137 (_lua_check_header_version)
CMakeLists.txt:8 (find_package)
CMake Error at /usr/local/share/cmake-3.11/Modules/FindLua.cmake:88 (file):
file STRINGS file "/usr/include/lua.h" cannot be read.
Call Stack (most recent call first):
/usr/local/share/cmake-3.11/Modules/FindLua.cmake:137 (_lua_check_header_version)
CMakeLists.txt:8 (find_package)
CMake Error at /usr/local/share/cmake-3.11/Modules/FindLua.cmake:88 (file):
file STRINGS file "/usr/include/lua53/lua.h" cannot be read.
Call Stack (most recent call first):
/usr/local/share/cmake-3.11/Modules/FindLua.cmake:137 (_lua_check_header_version)
CMakeLists.txt:8 (find_package)
In our build process at some point variables are saved and later restored. This creates a new variable for every cache entry. In FindLua.cmake LUA_INCLUDE_PREFIX will be unset from the cache but if a variable of the same name also exists the code will assume that find_path succeeded even if it didn't. This can be reproduced with the following simple project:
cmake_minimum_required(VERSION 3.10)
project(find-lua-test)
if (LUA_INCLUDE_PREFIX)
set(LUA_INCLUDE_PREFIX "${LUA_INCLUDE_PREFIX}")
endif()
find_package(Lua)
Topic-rename: FindLua-tolerate-var
Edited by Brad King