Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to use a lua library compiled as C++ #604

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ option(BUILD_LUA_BINDINGS "Build Lua bindings" OFF)

if (BUILD_LUA_BINDINGS)
option(BUILD_LUA_BINDINGS_FOR_LUAJIT "Build Lua bindings using luajit" OFF)
option(RMLUI_LUA_AS_CXX "Lua library was compiled with a C++ compiler" OFF)
endif()

if(APPLE)
Expand Down Expand Up @@ -417,6 +418,9 @@ if(BUILD_LUA_BINDINGS)
list(APPEND LUA_BINDINGS_INCLUDE_DIRS ${LUA_INCLUDE_DIR})
list(APPEND LUA_BINDINGS_LINK_LIBS ${LUA_LIBRARIES})
endif()
if(RMLUI_LUA_AS_CXX)
list(APPEND LUA_BINDINGS_PUBLIC_DEFS -DRMLUI_LUA_COMPILED_AS_CXX)
endif()
endif()

# rlottie
Expand Down Expand Up @@ -664,9 +668,11 @@ if(BUILD_LUA_BINDINGS)
if(NOT BUILD_FRAMEWORK)
target_link_libraries(RmlLua RmlCore ${LUA_BINDINGS_LINK_LIBS})
target_include_directories(RmlLua PUBLIC ${LUA_BINDINGS_INCLUDE_DIRS})
target_compile_definitions(RmlLua PUBLIC ${LUA_BINDINGS_PUBLIC_DEFS})
else()
target_link_libraries(RmlUi ${LUA_BINDINGS_LINK_LIBS})
target_include_directories(RmlUi PUBLIC ${LUA_BINDINGS_INCLUDE_DIRS})
target_compile_definitions(RmlUi PUBLIC ${LUA_BINDINGS_PUBLIC_DEFS})
endif()
endif()

Expand Down
8 changes: 7 additions & 1 deletion Include/RmlUi/Lua/IncludeLua.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,17 @@
#ifndef RMLUI_LUA_INCLUDELUA_H
#define RMLUI_LUA_INCLUDELUA_H

// The standard Lua headers
#ifndef RMLUI_LUA_COMPILED_AS_CXX
extern "C" {
#endif

// The standard Lua headers
#include <lauxlib.h>
#include <lua.h>
#include <lualib.h>

#ifndef RMLUI_LUA_COMPILED_AS_CXX
}
#endif

#endif
Loading