Add support for using system LuaJIT (#808)
* Add support for using system LuaJIT * Test CI: Update package list * Update toml11
This commit is contained in:
1
.github/workflows/Test_Build.yml
vendored
1
.github/workflows/Test_Build.yml
vendored
@@ -16,6 +16,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Install and update packages
|
- name: Install and update packages
|
||||||
run: |
|
run: |
|
||||||
|
apt-get update
|
||||||
apt-get -y install python3 python3-pip python3-venv p7zip-full libarchive13
|
apt-get -y install python3 python3-pip python3-venv p7zip-full libarchive13
|
||||||
python3 --version
|
python3 --version
|
||||||
python3 -m venv venv
|
python3 -m venv venv
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ option(ENABLE_DISCORD_RPC "Compile with Discord RPC support (disabled by default
|
|||||||
option(ENABLE_LUAJIT "Enable scripting with the Lua programming language" ON)
|
option(ENABLE_LUAJIT "Enable scripting with the Lua programming language" ON)
|
||||||
option(ENABLE_QT_GUI "Enable the Qt GUI. If not selected then the emulator uses a minimal SDL-based UI instead" OFF)
|
option(ENABLE_QT_GUI "Enable the Qt GUI. If not selected then the emulator uses a minimal SDL-based UI instead" OFF)
|
||||||
option(USE_SYSTEM_SDL2 "Use the system's SDL2 package" OFF)
|
option(USE_SYSTEM_SDL2 "Use the system's SDL2 package" OFF)
|
||||||
|
option(USE_SYSTEM_LUAJIT "Use the system's LuaJIT package" OFF)
|
||||||
option(ENABLE_GIT_VERSIONING "Enables querying git for the emulator version" ON)
|
option(ENABLE_GIT_VERSIONING "Enables querying git for the emulator version" ON)
|
||||||
option(BUILD_HYDRA_CORE "Build a Hydra core" OFF)
|
option(BUILD_HYDRA_CORE "Build a Hydra core" OFF)
|
||||||
option(BUILD_LIBRETRO_CORE "Build a Libretro core" OFF)
|
option(BUILD_LIBRETRO_CORE "Build a Libretro core" OFF)
|
||||||
@@ -228,8 +229,20 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_LUAJIT)
|
if(ENABLE_LUAJIT)
|
||||||
|
if (USE_SYSTEM_LUAJIT)
|
||||||
|
find_package(LuaJIT MODULE REQUIRED)
|
||||||
|
|
||||||
|
if (LUAJIT_FOUND)
|
||||||
|
target_include_directories(AlberCore PUBLIC ${LUA_INCLUDE_DIR})
|
||||||
|
message(STATUS "Lua include dir: ${LUA_INCLUDE_DIR}")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Failed to find system LuaJIT. Either disable LuaJIT, or use the bundled LuaJIT by setting USE_SYSTEM_LUAJIT to false")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_link_libraries(AlberCore PRIVATE ${LUA_LIBRARIES})
|
||||||
|
else()
|
||||||
add_subdirectory(third_party/LuaJIT luajit)
|
add_subdirectory(third_party/LuaJIT luajit)
|
||||||
include_directories(third_party/LuaJIT/src ${CMAKE_BINARY_DIR}/luajit)
|
target_include_directories(AlberCore PUBLIC third_party/LuaJIT/src ${CMAKE_BINARY_DIR}/luajit)
|
||||||
set_target_properties(luajit PROPERTIES EXCLUDE_FROM_ALL 1)
|
set_target_properties(luajit PROPERTIES EXCLUDE_FROM_ALL 1)
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
@@ -238,10 +251,12 @@ if(ENABLE_LUAJIT)
|
|||||||
target_compile_definitions(buildvm PRIVATE _CRT_SECURE_NO_WARNINGS)
|
target_compile_definitions(buildvm PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_compile_definitions(AlberCore PUBLIC "PANDA3DS_ENABLE_LUA=1")
|
|
||||||
target_link_libraries(AlberCore PRIVATE libluajit)
|
target_link_libraries(AlberCore PRIVATE libluajit)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
target_compile_definitions(AlberCore PUBLIC "PANDA3DS_ENABLE_LUA=1")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Detect target architecture
|
# Detect target architecture
|
||||||
if (NOT APPLE OR "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
|
if (NOT APPLE OR "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
|
||||||
# Normal target detection
|
# Normal target detection
|
||||||
|
|||||||
62
cmake/FindLuaJIT.cmake
Normal file
62
cmake/FindLuaJIT.cmake
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
# Locate LuaJIT library
|
||||||
|
# This module defines
|
||||||
|
# LUAJIT_FOUND, if false, do not try to link to Lua
|
||||||
|
# LUA_LIBRARIES
|
||||||
|
# LUA_INCLUDE_DIR, where to find lua.h
|
||||||
|
# LUAJIT_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
|
||||||
|
|
||||||
|
## Copied from default CMake FindLua51.cmake
|
||||||
|
|
||||||
|
find_path(LUA_INCLUDE_DIR luajit.h
|
||||||
|
HINTS
|
||||||
|
ENV LUA_DIR
|
||||||
|
PATH_SUFFIXES include/luajit-2.0 include/luajit-2.1 include
|
||||||
|
PATHS
|
||||||
|
~/Library/Frameworks
|
||||||
|
/Library/Frameworks
|
||||||
|
/sw # Fink
|
||||||
|
/opt/local # DarwinPorts
|
||||||
|
/opt/csw # Blastwave
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(LUA_LIBRARY
|
||||||
|
NAMES luajit-5.1
|
||||||
|
HINTS
|
||||||
|
ENV LUA_DIR
|
||||||
|
PATH_SUFFIXES lib
|
||||||
|
PATHS
|
||||||
|
~/Library/Frameworks
|
||||||
|
/Library/Frameworks
|
||||||
|
/sw
|
||||||
|
/opt/local
|
||||||
|
/opt/csw
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
|
||||||
|
if(LUA_LIBRARY)
|
||||||
|
# include the math library for Unix
|
||||||
|
if(UNIX AND NOT APPLE)
|
||||||
|
find_library(LUA_MATH_LIBRARY m)
|
||||||
|
set( LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
|
||||||
|
# For Windows and Mac, don't need to explicitly include the math library
|
||||||
|
else()
|
||||||
|
set( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/luajit.h")
|
||||||
|
file(STRINGS "${LUA_INCLUDE_DIR}/luajit.h" luajit_version_str REGEX "^#define[ \t]+LUAJIT_VERSION[ \t]+\"LuaJIT .+\"")
|
||||||
|
|
||||||
|
string(REGEX REPLACE "^#define[ \t]+LUAJIT_VERSION[ \t]+\"LuaJIT ([^\"]+)\".*" "\\1" LUAJIT_VERSION_STRING "${luajit_version_str}")
|
||||||
|
unset(luajit_version_str)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
|
||||||
|
# all listed variables are TRUE
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LuaJIT
|
||||||
|
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
|
||||||
|
VERSION_VAR LUAJIT_VERSION_STRING)
|
||||||
|
|
||||||
|
mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY)
|
||||||
2
third_party/toml11
vendored
2
third_party/toml11
vendored
Submodule third_party/toml11 updated: 1340692442...c44459dc47
Reference in New Issue
Block a user