From 1ceb8a750bfa4e632c5742ff18bcde843ddcd932 Mon Sep 17 00:00:00 2001 From: Paul Dino Jones Date: Mon, 25 May 2026 23:03:57 -0400 Subject: [PATCH] add macro for lua 5.4 backwards compatibility so we can compile against lua 5.4 or 5.5 --- CMakeLists.txt | 29 ++++++++++++-------- src/monocoque/devices/serial/arduinoledlua.h | 9 ++++-- src/monocoque/devices/simdevice.h | 2 +- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b02e839..61e2537 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,16 +17,23 @@ set(CMAKE_EXE_LINKER_FLAGS "-Wl,--no-as-needed -ldl") set(LIBUSB_INCLUDE_DIR /usr/include/libusb-1.0) set(LIBXML_INCLUDE_DIR /usr/include/libxml2) -FIND_PACKAGE(Lua REQUIRED 5.4) -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}" - ) - message("Lua ${Lua_VERSION} found") +FIND_PACKAGE(Lua) +#FIND_PACKAGE(Lua 5.4 REQUIRED EXACT) +#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() +message("Lua ${Lua_VERSION} found") +if (Lua_VERSION VERSION_GREATER_EQUAL "5.5.0") + add_compile_definitions(USE_LUA_55) +else() + remove_definitions(USE_LUA_55) endif() #FIND_PATH(LIBUSB_INCLUDE_DIR libusb.h @@ -66,7 +73,7 @@ endif() message("Using pulseaudio backend...") add_compile_definitions(USE_PULSEAUDIO=true) -target_link_libraries(monocoque m hidapi-hidraw pulse serialport xml2 argtable2 config gameloop helper devices slog simulatorapi uv xdg-basedir lua5.4 proc2) +target_link_libraries(monocoque m hidapi-hidraw pulse serialport xml2 argtable2 config gameloop helper devices slog simulatorapi uv xdg-basedir lua proc2) target_include_directories(monocoque PUBLIC config ${LIBXML_INCLUDE_DIR} ${LUA_INCLUDE_DIR}) diff --git a/src/monocoque/devices/serial/arduinoledlua.h b/src/monocoque/devices/serial/arduinoledlua.h index c538988..89ae748 100644 --- a/src/monocoque/devices/serial/arduinoledlua.h +++ b/src/monocoque/devices/serial/arduinoledlua.h @@ -2,8 +2,13 @@ #define _ARDUINOLEDLUA_H //#include -#include -#include +#include +#include + +#ifdef USE_LUA_55 +/* open all libraries */ +#define luaL_openlibs(L) luaL_openselectedlibs(L, ~0, 0) +#endif #include "../../simulatorapi/simapi/simapi/simdata.h" diff --git a/src/monocoque/devices/simdevice.h b/src/monocoque/devices/simdevice.h index 10f2824..e0594ab 100644 --- a/src/monocoque/devices/simdevice.h +++ b/src/monocoque/devices/simdevice.h @@ -4,7 +4,7 @@ #include #include -#include +#include #include "usbdevice.h" #include "sounddevice.h"