c++luagame-developmentpremake

Why is this post build command not working when trying to copy the SDL3.dll to the same folder as the exe (premake)


filter "system:windows"
    cppdialect "C++17"
    staticruntime "On"
    systemversion "latest"

    defines 
    {}

    postbuildcommands {
        "{COPYFILE} vendor/SDL3/lib/SDL3.dll bin/Debug-windows-x86_64"
    }

I'm trying to learn premake and having troubles copying over a dll file with a post build command.

Above is the post build command im using (you can see it at the bottom of the code snippet). However, when trying to run the application after running the premake file and generating the solution, it says 'The system cannot find the path specified.'. Seems like it either cant find the SDL3.dll or the exe itself.

What could be happening here and what im doing wrong?


Solution

  • Path in postbuildcommands should be made relative to project; to inform premake that such string contains paths, you have to enclosed them by %[..], i.e

    postbuildcommands {
        "{COPYFILE} %[vendor/SDL3/lib/SDL3.dll] %[bin/Debug-windows-x86_64]"
    }
    

    For this kind of postbuildcommands, a good alternative is

    files "vendor/SDL3/lib/SDL3.dll"
    
    filters "files:**.dll"
        buildaction "Copy"
    filters {}
    

    Which would copy the file only when missing or outdated