Skip to content

Commit 456eedc

Browse files
committed
fix map runtime flags
1 parent d1b64e6 commit 456eedc

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

xmake/core/package/package.lua

+6-5
Original file line numberDiff line numberDiff line change
@@ -2372,17 +2372,18 @@ function _instance:_generate_build_configs(configs, opt)
23722372
end
23732373
if runtimes then
23742374
local sourcekind = opt.sourcekind or "cxx"
2375-
local linker = self:linker("binary", sourcekind)
2376-
local fake_target = {is_shared = function(_) return false end,
2377-
sourcekinds = function(_) return sourcekind end}
23782375
local compiler = self:compiler(sourcekind)
2379-
local cxflags = compiler:map_flags("runtime", runtimes, {target = fake_target})
2376+
local cxflags = compiler:map_flags("runtime", runtimes, {target = self})
23802377
configs.cxflags = table.wrap(configs.cxflags)
23812378
table.join2(configs.cxflags, cxflags)
23822379

2383-
local ldflags = linker:map_flags("runtime", runtimes, {target = fake_target})
2380+
local ldflags = self:linker("binary", sourcekind):map_flags("runtime", runtimes, {target = self})
23842381
configs.ldflags = table.wrap(configs.ldflags)
23852382
table.join2(configs.ldflags, ldflags)
2383+
2384+
local shflags = self:linker("shared", sourcekind):map_flags("runtime", runtimes, {target = self})
2385+
configs.shflags = table.wrap(configs.shflags)
2386+
table.join2(configs.shflags, shflags)
23862387
end
23872388
if self:config("lto") then
23882389
local configs_lto = self:_generate_lto_configs(opt.sourcekind or "cxx")

xmake/modules/package/tools/cmake.lua

+5-9
Original file line numberDiff line numberDiff line change
@@ -881,15 +881,11 @@ function _get_envs_for_runtime_flags(package, configs, opt)
881881
local envs = {}
882882
local runtimes = package:runtimes()
883883
if runtimes then
884-
local fake_target = {is_shared = function(_) return false end,
885-
sourcekinds = function(_) return "cc" end}
886-
envs[format("CMAKE_C_FLAGS_%s", buildtype)] = _map_compflags(fake_target, "c", "runtime", runtimes)
887-
fake_target.sourcekinds = function(_) return "cxx" end
888-
envs[format("CMAKE_CXX_FLAGS_%s", buildtype)] = _map_compflags(fake_target, "cxx", "runtime", runtimes)
889-
envs[format("CMAKE_EXE_LINKER_FLAGS_%s", buildtype)] = _map_linkflags(fake_target, "binary", {"cxx"}, "runtime", runtimes)
890-
envs[format("CMAKE_STATIC_LINKER_FLAGS_%s", buildtype)] = _map_linkflags(fake_target, "static", {"cxx"}, "runtime", runtimes)
891-
fake_target.is_shared = function(_) return true end
892-
envs[format("CMAKE_SHARED_LINKER_FLAGS_%s", buildtype)] = _map_linkflags(fake_target, "shared", {"cxx"}, "runtime", runtimes)
884+
envs[format("CMAKE_C_FLAGS_%s", buildtype)] = _map_compflags(package, "c", "runtime", runtimes)
885+
envs[format("CMAKE_CXX_FLAGS_%s", buildtype)] = _map_compflags(package, "cxx", "runtime", runtimes)
886+
envs[format("CMAKE_EXE_LINKER_FLAGS_%s", buildtype)] = _map_linkflags(package, "binary", {"cxx"}, "runtime", runtimes)
887+
envs[format("CMAKE_STATIC_LINKER_FLAGS_%s", buildtype)] = _map_linkflags(package, "static", {"cxx"}, "runtime", runtimes)
888+
envs[format("CMAKE_SHARED_LINKER_FLAGS_%s", buildtype)] = _map_linkflags(package, "shared", {"cxx"}, "runtime", runtimes)
893889
end
894890
return envs
895891
end

0 commit comments

Comments
 (0)