forked from T3mps/Astra
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpremake-LinkTimeModule.lua
More file actions
32 lines (29 loc) · 906 Bytes
/
Copy pathpremake-LinkTimeModule.lua
File metadata and controls
32 lines (29 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
local p = premake
-- Register API (use 'field' for compatibility with older Premake)
p.api.register {
name = "linktimeoptimization",
scope = "config",
kind = "string",
allowed = {
"On",
"Off",
}
}
-- Try to override getldflags for both c and cpp modules if available
local function add_lto_override(module)
if module and module.getldflags then
p.override(module, "getldflags", function(base, cfg)
local flags = base(cfg)
if cfg.linktimeoptimization == "On" then
if cfg.system == p.WINDOWS then
table.insert(flags, "/LTCG")
elseif cfg.system == p.LINUX or cfg.system == p.MACOSX then
table.insert(flags, "-flto")
end
end
return flags
end)
end
end
add_lto_override(p.modules.c)
add_lto_override(p.modules.cpp)