diff --git a/CMakeLists.txt b/CMakeLists.txt index 7bdade0c..327fc8c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ set(CMAKE_CXX_STANDARD 20) find_package(Lua QUIET) -if (NOT Lua_FOUND) +if (NOT LUA_FOUND) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../lib/lua) find_package(Lua REQUIRED) endif() diff --git a/lib/lua/Findlua.cmake b/lib/lua/Findlua.cmake index 2afa3892..d087ccee 100644 --- a/lib/lua/Findlua.cmake +++ b/lib/lua/Findlua.cmake @@ -40,6 +40,18 @@ This is because, the lua location is not standardized and may exist in locations other than lua/ #]=======================================================================] +if (NOT LUA_FOUND) + INCLUDE(FetchContent) + + FetchContent_Declare(lua URL https://www.lua.org/ftp/lua-5.4.3.tar.gz) + FetchContent_GetProperties(lua) + if (NOT lua_POPULATED) + SET(FETCHCONTENT_QUIET NO) + FetchContent_Populate(lua) + ADD_SUBDIRECTORY(${lua_SOURCE_DIR}) + endif() +endif() + cmake_policy(PUSH) # Policies apply to functions at definition-time cmake_policy(SET CMP0012 NEW) # For while(TRUE)