Merged in ben_ratzlaff/premake-dev (pull request #146)
Implement 'RelativeLinks" flag to effect makefile creation to use -l and -L instead of linking against the full path of a dynamic object library
This commit is contained in:
commit
878d108367
@ -402,6 +402,7 @@
|
||||
"Optimize", -- DEPRECATED
|
||||
"OptimizeSize", -- DEPRECATED
|
||||
"OptimizeSpeed", -- DEPRECATED
|
||||
"RelativeLinks",
|
||||
"ReleaseRuntime",
|
||||
"SEH",
|
||||
"ShadowedVariables",
|
||||
|
@ -237,6 +237,15 @@
|
||||
table.insert(flags, '-L' .. project.getrelative(cfg.project, dir))
|
||||
end
|
||||
|
||||
if cfg.flags.RelativeLinks then
|
||||
for _, dir in ipairs(premake.config.getlinks(cfg, "siblings", "directory")) do
|
||||
local libFlag = "-L" .. premake.project.getrelative(cfg.project, dir)
|
||||
if not table.contains(flags, libFlag) then
|
||||
table.insert(flags, libFlag)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return flags
|
||||
end
|
||||
|
||||
@ -249,12 +258,21 @@
|
||||
function gcc.getlinks(cfg, systemonly)
|
||||
local result = {}
|
||||
|
||||
-- Don't use the -l form for sibling libraries, since they may have
|
||||
-- custom prefixes or extensions that will confuse the linker. Instead
|
||||
-- just list out the full relative path to the library.
|
||||
|
||||
if not systemonly then
|
||||
result = config.getlinks(cfg, "siblings", "fullpath")
|
||||
if cfg.flags.RelativeLinks then
|
||||
local libFiles = premake.config.getlinks(cfg, "siblings", "basename")
|
||||
for _, link in ipairs(libFiles) do
|
||||
if string.find(link, "lib") == 1 then
|
||||
link = link:sub(4)
|
||||
end
|
||||
table.insert(result, "-l" .. link)
|
||||
end
|
||||
else
|
||||
-- Don't use the -l form for sibling libraries, since they may have
|
||||
-- custom prefixes or extensions that will confuse the linker. Instead
|
||||
-- just list out the full relative path to the library.
|
||||
result = config.getlinks(cfg, "siblings", "fullpath")
|
||||
end
|
||||
end
|
||||
|
||||
-- The "-l" flag is fine for system libraries
|
||||
|
@ -124,6 +124,26 @@
|
||||
]]
|
||||
end
|
||||
|
||||
--
|
||||
-- Check a linking to a sibling shared library using -l and -L.
|
||||
--
|
||||
|
||||
function suite.links_onSiblingSharedLib()
|
||||
links "MyProject2"
|
||||
flags { "RelativeLinks" }
|
||||
|
||||
test.createproject(sln)
|
||||
kind "SharedLib"
|
||||
location "build"
|
||||
|
||||
prepare { "ldFlags", "libs", "ldDeps" }
|
||||
test.capture [[
|
||||
ALL_LDFLAGS += $(LDFLAGS) -Lbuild -s
|
||||
LIBS += -lMyProject2
|
||||
LDDEPS += build/libMyProject2.so
|
||||
]]
|
||||
end
|
||||
|
||||
--
|
||||
-- When referencing an external library via a path, the directory
|
||||
-- should be added to the library search paths, and the library
|
||||
|
Loading…
Reference in New Issue
Block a user