diff --git a/modules/vstudio/tests/vc2010/test_link.lua b/modules/vstudio/tests/vc2010/test_link.lua index 1a420c02..52f33cdc 100644 --- a/modules/vstudio/tests/vc2010/test_link.lua +++ b/modules/vstudio/tests/vc2010/test_link.lua @@ -723,7 +723,7 @@ ]] end - -- +-- -- Test ignoring default libraries with extensions specified. -- @@ -737,4 +737,33 @@ true ]] - end \ No newline at end of file + end + +-- +-- Test for not including additional dependencies. +-- + + function suite.inheritDependenciesOff() + inheritdependencies "Off" + prepare() + test.capture [[ + + Windows + + bin\Debug\MyProject.lib + + ]] + end + + function suite.inheritDependenciesOn() + inheritdependencies "On" + links { "kernel32" } + prepare() + test.capture [[ + + Windows + kernel32.lib;%(AdditionalDependencies) + bin\Debug\MyProject.lib + + ]] + end diff --git a/modules/vstudio/vs2010_vcxproj.lua b/modules/vstudio/vs2010_vcxproj.lua index 57a37db3..90e74780 100644 --- a/modules/vstudio/vs2010_vcxproj.lua +++ b/modules/vstudio/vs2010_vcxproj.lua @@ -1422,9 +1422,18 @@ links = vstudio.getLinks(cfg, explicit) end - if #links > 0 then - links = path.translate(table.concat(links, ";")) - m.element("AdditionalDependencies", nil, "%s;%%(AdditionalDependencies)", links) + links = path.translate(table.concat(links, ";")) + + local additional = ";%(AdditionalDependencies)" + if cfg.inheritdependencies ~= nil then + if not cfg.inheritdependencies then + additional = "" + end + end + + -- If there are no links and dependencies should be inherited, the tag doesn't have to be generated. + if #links > 0 or additional == "" then + m.element("AdditionalDependencies", nil, "%s%s", links, additional) end end diff --git a/src/_premake_init.lua b/src/_premake_init.lua index e3a6ac5a..3eac1fc1 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -644,6 +644,12 @@ tokens = true, } + api.register { + name = "inheritdependencies", + scope = "config", + kind = "boolean", + } + api.register { name = "icon", scope = "project", diff --git a/website/docs/inheritdependencies.md b/website/docs/inheritdependencies.md new file mode 100644 index 00000000..061811ea --- /dev/null +++ b/website/docs/inheritdependencies.md @@ -0,0 +1,29 @@ +inheritdependencies + +```lua +inheritdependencies "value" +``` + +For Visual Studio project files, this controls the generation of the `%(AdditionalDependencies)` entry in the list of libraries that a project links. + +### Parameters ### + +`value` one of: +* `On` - The project(s) will inherit library dependencies based on the parent project (if any) and project default settings. This is the default behavior. +* `Off` - The project(s) will not inherit any library dependencies. Only explicitly specified dependencies will be linked. + +## Applies To ### + +The `config` scope. + +### Availability ### + +Visual Studio 2015 and later. +Premake 5.0-beta2 or later. + +### Examples ### + +```lua +inheritdependencies "Off" +``` + diff --git a/website/sidebars.js b/website/sidebars.js index f11188a3..60529708 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -179,6 +179,7 @@ module.exports = { 'implibsuffix', 'importdirs', 'includedirs', + 'inheritdependencies', 'inlinesvisibility', 'inlining', 'intrinsics',