From 8c74ee31e08f94740be9e5e6a99776b19f9b735d Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Thu, 4 Dec 2025 00:39:09 -0600 Subject: [PATCH] Add lua diff --- cmake/modules/Findlua.cmake | 59 ------------------------------------- src/CMakeLists.txt | 14 +++++++-- 2 files changed, 12 insertions(+), 61 deletions(-) delete mode 100644 cmake/modules/Findlua.cmake diff --git a/cmake/modules/Findlua.cmake b/cmake/modules/Findlua.cmake deleted file mode 100644 index a31ceb0..0000000 --- a/cmake/modules/Findlua.cmake +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -if(NOT TARGET lua) - message(STATUS "Looking for Lua...") - - set(LUA_FOUND FALSE CACHE INTERNAL "Lua found") - set(LUA_DOWNLOAD_DIR "${CMAKE_BINARY_DIR}/_lua") - set(LUA_SEARCH_ROOTS - "${LUA_ROOT}" - "$ENV{LUADEV}" - "$ENV{HOME}/luadev" - "/usr/local/luadev" - "/opt/luadev" - "/usr/luadev" - "${LUA_DOWNLOAD_DIR}/luadev" - ) - - foreach(root IN LISTS LUA_SEARCH_ROOTS) - list(APPEND LUA_BIN_HINTS "${root}/bin") - list(APPEND LUA_INCLUDE_HINTS "${root}/include") - list(APPEND LUA_LIB_HINTS "${root}/lib") - endforeach() - - # Find Lua interpreter - find_program(LUA_EXECUTABLE NAMES lua HINTS ${LUA_BIN_HINTS}) - - # Find Lua headers and library - find_path(LUA_INCLUDE_DIR lua.h HINTS ${LUA_INCLUDE_HINTS}) - find_library(LUA_LIBRARY NAMES lua HINTS ${LUA_LIB_HINTS}) - - # If not found, use FetchContent to download and build Lua - if(NOT LUA_EXECUTABLE OR NOT LUA_INCLUDE_DIR OR NOT LUA_LIBRARY) - message(STATUS "Lua not found in system paths. Using FetchContent to download and build Lua.") - include(FetchContent) - FetchContent_Declare( - lua - GIT_REPOSITORY https://github.com/lua/lua.git - GIT_TAG v5.4.6 # Change to desired version - ) - FetchContent_MakeAvailable(lua) - # Try to locate built Lua - set(LUA_INCLUDE_DIR "${lua_SOURCE_DIR}") - set(LUA_LIBRARY "${lua_BINARY_DIR}/liblua.a") - set(LUA_EXECUTABLE "${lua_BINARY_DIR}/lua") - endif() - - if(LUA_EXECUTABLE AND LUA_INCLUDE_DIR AND LUA_LIBRARY) - set(LUA_FOUND TRUE CACHE INTERNAL "Lua found") - add_library(lua INTERFACE IMPORTED) - set_target_properties(lua PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${LUA_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES "${LUA_LIBRARY}" - ) - message(STATUS "Lua found: ${LUA_EXECUTABLE}") - endif() -endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 98bf274..47de100 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,7 +5,17 @@ find_package(cglm REQUIRED) find_package(libzip REQUIRED) -find_package(lua REQUIRED) +find_package(Lua REQUIRED) + +if(Lua_FOUND AND NOT TARGET Lua::Lua) + add_library(Lua::Lua INTERFACE IMPORTED) + set_target_properties( + Lua::Lua + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${LUA_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${LUA_LIBRARIES}" + ) +endif() # Libs target_link_libraries(${DUSK_TARGET_NAME} @@ -13,8 +23,8 @@ target_link_libraries(${DUSK_TARGET_NAME} m cglm zip - lua pthread + Lua::Lua ) # Includes