c++visual-studiopremake

Exclude project from build by Premake


I have two projects in the solution. One of them is a debug lib, which should be built only in Debug workspace configuration. In VS I can just disable the 'Build' checkbox in Configuration Manager.

enter image description here

But I need this to be done with Premake 5.0, which include all project in build by default. I tried to use filter by configuration, but this didn't worked for me.

solution "Workspace"

configurations 
{   
    "Debug",
    "Release"
}

project "Application"
    language "C++"
    kind "ConsoleApp"

    files
    {
        "../sources/**.hpp",
        "../sources/**.cpp",
    }

filter "configurations:Debug"   

project "DebugLib"
    language "C++"
    kind "StaticLib"

    files
    {
        "../sources/**.hpp",
        "../sources/**.cpp",
    }
    
filter {}

Maybe this way could for me, but I didn't find how to make if condition with solution configuration.

How can I achieve this behaviour with Premake?


Solution

  • I have dived into project kind and find out that None kind can suit my needs.

    A configuration which is not included in the build. Useful for projects containing only web pages, header files, or support documentation.

    I changed my config, and put kind under the filter by configuration, which solved the problem. Now it looks this way:

    project "DebugLib"
        language "C++"
        
        filter "configurations:Release" 
            kind "None"
        filter "configurations:Debug"
            kind "StaticLib"
        filter {}