sol2 icon indicating copy to clipboard operation
sol2 copied to clipboard

Include lua headers from custom directory

Open pfirsich opened this issue 2 years ago • 2 comments

Unfortunately vcpkg has moved LuaJIT headers to a luajit/ subdirectory (https://github.com/microsoft/vcpkg/pull/5863). It is my understanding that this means that sol2 can not be used with LuaJIT if both are installed via vcpkg, because soll will always look for lua.h, is that correct?

I would propose to provide a way to customize the include directory with something like SOL_LUA_INCLUDE_PATH_BASE or something that will be prepended to the header names before inclusion. Like this:

#define SOL_INCLUDE_PATH_BASE luajit/
#include <sol/sol.hpp>

This would require some ugly macro magic to build the correct include paths and probably make the includes a bit less readable.

Alternatively one could provide SOL_INCLUDE_PATH_LUA, SOL_INCLUDE_PATH_LAUXLIB and SOL_INCLUDE_PATH_LUALIB respectively to specify the paths directly.

Then I would just be able to do this:

#define SOL_INCLUDE_PATH_LUA <luajit/lua.h>
#define SOL_INCLUDE_PATH_LUALIB <luajit/lualib.h>
#define SOL_INCLUDE_PATH_LAUXLIB <luajit/lauxlib.h>
#include <sol/sol.hpp>

This way sol2 will be robust against any future changes in vcpkg package layouts as well.

pfirsich avatar May 29 '23 15:05 pfirsich

This will not solve the issue in a way which is relevant for vcpkg.

dg0yt avatar May 29 '23 20:05 dg0yt

@dg0yt sorry, I have trouble understanding what you are trying to say. Could you explain, please?

pfirsich avatar May 29 '23 20:05 pfirsich