diff --git a/src/base/config.lua b/src/base/config.lua index b232ad91..c936b57f 100755 --- a/src/base/config.lua +++ b/src/base/config.lua @@ -262,10 +262,20 @@ local link = cfg.links[i] local item + -- Strip linking decorators from link, to determine if the link + -- is a "sibling" project. + local endswith = function(s, ptrn) + return ptrn == string.sub(s, -string.len(ptrn)) + end + local name = link + if endswith(name, ":static") or endswith(name, ":shared") then + name = string.sub(name, 0, -8) + end + -- Sort the links into "sibling" (is another project in this same -- workspace) and "system" (is not part of this workspace) libraries. - local prj = p.workspace.findproject(cfg.workspace, link) + local prj = p.workspace.findproject(cfg.workspace, name) if prj and kind ~= "system" then -- Sibling; is there a matching configuration in this project that diff --git a/tests/config/test_links.lua b/tests/config/test_links.lua index dadc4564..ba51a87b 100755 --- a/tests/config/test_links.lua +++ b/tests/config/test_links.lua @@ -222,3 +222,45 @@ local r = prepare("all", "fullpath") test.isequal({ "bin/Debug/MyProject2.lib" }, r) end + +-- +-- Linking decorators need to be passed through +-- + + function suite.canLink_StaticDecoratorSystemLib() + links { "SystemLibrary:static" } + local r = prepare("all", "fullpath") + test.isequal({ "SystemLibrary:static" }, r) + end + + function suite.canLink_SharedDecoratorSystemLib() + links { "SystemLibrary:shared" } + local r = prepare("all", "fullpath") + test.isequal({ "SystemLibrary:shared" }, r) + end + +-- +-- Linking decorators need to be stripped for sibling projects +-- + + function suite.canLink_StaticDecoratorSiblingLib() + links { "SiblingLibrary:static" } + + project "SiblingLibrary" + kind "StaticLib" + language "C++" + + local r = prepare("all", "fullpath") + test.isequal({ "bin/Debug/SiblingLibrary.lib" }, r) + end + + function suite.canLink_SharedDecoratorSiblingLib() + links { "SiblingLibrary:shared" } + + project "SiblingLibrary" + kind "SharedLib" + language "C++" + + local r = prepare("all", "fullpath") + test.isequal({ "bin/Debug/SiblingLibrary.lib" }, r) + end