Open learn-more opened 1 year ago
Related to https://github.com/premake/premake-core/issues/1346
As premake uses Lua, you might still create Lua functions:
function useGsl()
externalincludedirs { "gsl/include" }
defines { "HAS_GSL" }
end
and then
project "example_1"
kind "ConsoleApp"
files { "main.cpp" }
useGsl()
project "example_2"
kind "ConsoleApp"
files { "main.cpp" }
That works, until you move the function to other directories, because the relative paths will be relative to where the function is used, instead of where the function is defined.
This isn't something that's on the roadmap for v5 currently (we would gladly accept PRs for something like this, though). What I personally do is use a table and just reference that in the scripts.
This isn't something that's on the roadmap for v5 currently (we would gladly accept PRs for something like this, though). What I personally do is use a table and just reference that in the scripts.
Do you happen to have an example for this?
In Meson these are called dependencies, which I think is a much better name. I think there may be some slight differences with CMake interface libraries, though I think they do everything listed above.
Is there a Premake alternative to the CMake concept of an 'interface' library?
An 'interface' library has the following properties when linking against it:
The main advantage I see with this is that we don't have to pollute the preprocessor macro's / include / link paths for all projects, just for the projects that need it.
Given this pseudo
premake5.lua
file:This would mean that
example_1
has the foldergsl/include
added to the include paths, and the defineHAS_GSL
set.