c++17build-systempremakebuild-script

Premake issues with lua


I using premake as a build system and I have my Lua script but for some reason when I open my vs2022 and run it some things don't get made right. some of the projects and items have a red circle with a minus sign. and my sandbox project isn't in my directories at all.

Im using premake5-beta beta2

heres my lua script.

workspace "Almond"
    architecture "x64"

    configurations
    {
        "Debug",
        "Release",
        "Dist"
    }

outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"

project "Almond"
    location "Almond"
    kind "SharedLib"
    language "C++"

    targetdir ("bin/" .. outputdir .. "/%{prj.name}")
    objdir ("bin-int/" .. outputdir .. "/%{prj.name}")

    files
    {
        "%{prj.name}/src/**.h", 
        "%{prj.name}/src/**.cpp"
    }

    filter "system:windows"
        cppdialect "C++17"
        staticruntime "On"
        systemversion "latest"
        
        defines
        {
            "AM_PLATFORM_WINDOWS",
            "AM_BUILD_DLL"
        }

        postbuildcommands
        {
            ("{COPY} %{cfg.buildtarget.relpath} ../bin/" .. outputdir .. "/Sandbox")
        }
    
    filter "configurations:Debug"
        defines "AM_DEBUG"
        symbols "On"

    filter "configurations:Release"
        defines "AM_RELEASE"
        optimize "On"

    filter "configurations:Dist"
        defines "AM_DIST"
        optimize "On"

project "Sanbox"
        location "Sandbox"
        kind "ConsoleApp"
        language "C++"

        targetdir ("bin/" .. outputdir .. "/%{prj.name}")
        objdir ("bin-int/" .. outputdir .. "/%{prj.name}")

            files
        {
            "%{prj.name}/src/**.h", 
            "%{prj.name}/src/**.cpp"
        }

        includedirs
        {
            "Almond/src"
        }

        links
        {
            "Almond"
        }

        filter "system:windows"
            cppdialect "C++17"
            staticruntime "On"
            systemversion "latest"
        
            defines
            {
            "AM_PLATFORM_WINDOWS"
            }

    filter "configurations:Debug"
        defines "AM_DEBUG"
        symbols "On"

    filter "configurations:Release"
        defines "AM_RELEASE"
        optimize "On"

    filter "configurations:Dist"
        defines "AM_DIST"
        optimize "On"

Ive never used premake before but ive heard its simpler than cmake for beginner. "-thecherno"


Solution

  • You have 3 issues:

    Following postbuildcommands should fix the issue:

    postbuildcommands
    {
        "{MKDIR} %[bin/" .. outputdir .. "/Sandbox]",
        "{COPYFILE} %[%{!cfg.buildtarget.abspath}] %[bin/" .. outputdir .. "/Sandbox]"
    }