ThePhD / sol2

Sol3 (sol2 v3.0) - a C++ <-> Lua API wrapper with advanced features and top notch performance - is here, and it's great! Documentation:
http://sol2.rtfd.io/
MIT License
4.18k stars 515 forks source link

Include lua headers from custom directory #1496

Open pfirsich opened 1 year ago

pfirsich commented 1 year ago

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.

dg0yt commented 1 year ago

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

pfirsich commented 1 year ago

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