diff options
| author | ruki <[email protected]> | 2024-08-30 22:49:47 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-08-30 22:49:47 +0800 |
| commit | 456eedcebb5adac9063d9417f68a47ebe0cddb49 (patch) | |
| tree | 2578e3f3262e46c854497c2e861bd8d29d831c67 | |
| parent | d1b64e63ff0e39badc4bd03b65033149af66c5f8 (diff) | |
fix map runtime flags
| -rw-r--r-- | xmake/core/package/package.lua | 11 | ||||
| -rw-r--r-- | xmake/modules/package/tools/cmake.lua | 14 |
2 files changed, 11 insertions, 14 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index a833a2f0b..22a8dfb2b 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -2372,17 +2372,18 @@ function _instance:_generate_build_configs(configs, opt) end if runtimes then local sourcekind = opt.sourcekind or "cxx" - local linker = self:linker("binary", sourcekind) - local fake_target = {is_shared = function(_) return false end, - sourcekinds = function(_) return sourcekind end} local compiler = self:compiler(sourcekind) - local cxflags = compiler:map_flags("runtime", runtimes, {target = fake_target}) + local cxflags = compiler:map_flags("runtime", runtimes, {target = self}) configs.cxflags = table.wrap(configs.cxflags) table.join2(configs.cxflags, cxflags) - local ldflags = linker:map_flags("runtime", runtimes, {target = fake_target}) + local ldflags = self:linker("binary", sourcekind):map_flags("runtime", runtimes, {target = self}) configs.ldflags = table.wrap(configs.ldflags) table.join2(configs.ldflags, ldflags) + + local shflags = self:linker("shared", sourcekind):map_flags("runtime", runtimes, {target = self}) + configs.shflags = table.wrap(configs.shflags) + table.join2(configs.shflags, shflags) end if self:config("lto") then local configs_lto = self:_generate_lto_configs(opt.sourcekind or "cxx") diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index 7d5550390..938d96dad 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -881,15 +881,11 @@ function _get_envs_for_runtime_flags(package, configs, opt) local envs = {} local runtimes = package:runtimes() if runtimes then - local fake_target = {is_shared = function(_) return false end, - sourcekinds = function(_) return "cc" end} - envs[format("CMAKE_C_FLAGS_%s", buildtype)] = _map_compflags(fake_target, "c", "runtime", runtimes) - fake_target.sourcekinds = function(_) return "cxx" end - envs[format("CMAKE_CXX_FLAGS_%s", buildtype)] = _map_compflags(fake_target, "cxx", "runtime", runtimes) - envs[format("CMAKE_EXE_LINKER_FLAGS_%s", buildtype)] = _map_linkflags(fake_target, "binary", {"cxx"}, "runtime", runtimes) - envs[format("CMAKE_STATIC_LINKER_FLAGS_%s", buildtype)] = _map_linkflags(fake_target, "static", {"cxx"}, "runtime", runtimes) - fake_target.is_shared = function(_) return true end - envs[format("CMAKE_SHARED_LINKER_FLAGS_%s", buildtype)] = _map_linkflags(fake_target, "shared", {"cxx"}, "runtime", runtimes) + envs[format("CMAKE_C_FLAGS_%s", buildtype)] = _map_compflags(package, "c", "runtime", runtimes) + envs[format("CMAKE_CXX_FLAGS_%s", buildtype)] = _map_compflags(package, "cxx", "runtime", runtimes) + envs[format("CMAKE_EXE_LINKER_FLAGS_%s", buildtype)] = _map_linkflags(package, "binary", {"cxx"}, "runtime", runtimes) + envs[format("CMAKE_STATIC_LINKER_FLAGS_%s", buildtype)] = _map_linkflags(package, "static", {"cxx"}, "runtime", runtimes) + envs[format("CMAKE_SHARED_LINKER_FLAGS_%s", buildtype)] = _map_linkflags(package, "shared", {"cxx"}, "runtime", runtimes) end return envs end |
