Fixed SNC linking to static library projects

This commit is contained in:
Jason Perkins 2012-02-28 17:14:28 -05:00
parent 5761e86cb6
commit adb36bf3e1
2 changed files with 19 additions and 9 deletions

View File

@ -81,17 +81,10 @@
--
-- Return the list of libraries to link, formatted for the linker command line.
-- The linking behavior is the same as GCC.
--
function snc.getlinks(cfg)
local result = {}
local links = config.getlinks(cfg, "all", "basename")
for _, link in ipairs(links) do
table.insert(result, "-l" .. link)
end
return result
end
snc.getlinks = premake.tools.gcc.getlinks

View File

@ -76,4 +76,21 @@
prepare()
test.isequal({ "-lfs_stub", "-lnet_stub" }, snc.getlinks(cfg))
end
--
-- When linking to a static sibling library, the relative path to the library
-- should be used instead of the "-l" flag. This prevents linking against a
-- shared library of the same name, should one be present.
--
function suite.links_onStaticSiblingLibrary()
links { "MyProject2" }
test.createproject(sln)
kind "StaticLib"
location "MyProject2"
targetdir "lib"
prepare()
test.isequal({ "lib/libMyProject2.a" }, snc.getlinks(cfg))
end