Search code examples
premake

extension according platform Premake


I have a premake file that handles a bunch of Matlab/Mex functions and static librarys. One project per matlab's function and one project per static library.

I'm using four platforms

platforms { "Win32", "Win64","Linux32","Linux64" }

I need that in the Win32 and Linux32 platforms the extension of the matlab's functions (targetextension) be ".mexglx" and in the "Win64" and "Linux64" platforms the extension (targetextension) be ".mexa64". But I don't want that extension in the library projects.

I think that I'm need to use rules but I couldn't figure out how to use it.

It's run with

if os.is64bit() then
    extension = ".mexa64"
else
    extension = ".mexglx"
end
...
project "foo"
    kind "ConsoleApp"
    language "C++"
    files { "foo.cpp" }
    targetextension(extension)

but it's clearly awful


Solution

  • How about this?

    filter { "platforms:*32", "kind:not StaticLib" }
       targetextension ".mexglx"
    
    filter { "platforms:*64", "kind:not StaticLib" }
       targetextension ".mexa64"