Reputation: 862
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.
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?
Upvotes: 0
Views: 1352
Reputation: 862
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 {}
Upvotes: 2
Reputation: 113
I see that you have already marked an accepted solution but I thought I would leave this here in the hope of helping future searchers.
I needed my project to be a utility project so that I could still manually compile items from within the project, which I could not do if the project kind is changed to 'None'.
So I ended up adding this.
require('vstudio')
premake.api.register {
name = "buildenabled",
scope = "config",
kind = "string",
allowed = {
"Default",
"Off",
"On"
},
}
-- \modules\vstudio\vs2005_solution.lua
premake.override(premake.vstudio.sln2005.elements, "projectConfigurationPlatforms", function(base, cfg, context)
if context.prjCfg.buildenabled and context.prjCfg.buildenabled == "Off" then
return {
premake.vstudio.sln2005.activeCfg
}
else
return base(cfg, context)
end
end)
Then inside a project you want to disable the build you just add
buildenabled "Off"
to disable the project.
It's very rough but might help others find a solution that works for them.
Upvotes: 0
Reputation: 67
I am assuming here but should you not be able to just to this workspace use configmap to manage this?
https://github.com/premake/premake-core/wiki/Configurations-and-Platforms
use the filter.
project "Application"
configurations { "Release" }
kind "ConsoleApp"
targetdir "bin/%{cfg.buildcfg}"
filter "configurations:Release"
as shown here https://github.com/premake/premake-core/wiki/kind
and I pretty sure you can use https://github.com/premake/premake-core/wiki/Build-Settings to get the appropriate settings to have control of the platform needed.
you can also probably just use defines keyword as well that basically goes.
Upvotes: 1