diff --git a/CHANGELOG.md b/CHANGELOG.md index 764e0ae1193..b764ef4b97c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ * [#2580](https://github.com/xmake-io/xmake/issues/2580): Set stdout to line buffering * [#2571](https://github.com/xmake-io/xmake/issues/2571): Improve task scheduling for parallel and distributed compilation based on memory/cpu usage * [#2410](https://github.com/xmake-io/xmake/issues/2410): Improve cmakelists generator +* [#2690](https://github.com/xmake-io/xmake/issues/2690): Improve to pass toolchains to packages ### Bugs fixed @@ -1373,6 +1374,7 @@ * [#2580](https://github.com/xmake-io/xmake/issues/2580): 设置 stdout 到 line 缓冲输出 * [#2571](https://github.com/xmake-io/xmake/issues/2571): 改进分布式编译的调度算法,增加 cpu/memory 状态权重 * [#2410](https://github.com/xmake-io/xmake/issues/2410): 改进 cmakelists 生成 +* [#2690](https://github.com/xmake-io/xmake/issues/2690): 改机传递 toolchains 到包 ### Bugs 修复 diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua index aa7fc9b96d7..e90922171d8 100644 --- a/xmake/modules/private/action/require/impl/package.lua +++ b/xmake/modules/private/action/require/impl/package.lua @@ -466,19 +466,21 @@ function _init_requireinfo(requireinfo, package, opt) requireinfo.configs = requireinfo.configs or {} if opt.is_toplevel then requireinfo.is_toplevel = true - if not package:is_headeronly() then - if package:is_library() then - requireinfo.configs.toolchains = requireinfo.configs.toolchains or project.get("target.toolchains") - if project.policy("package.inherit_external_configs") then - requireinfo.configs.toolchains = requireinfo.configs.toolchains or get_config("toolchain") - end - end - requireinfo.configs.vs_runtime = requireinfo.configs.vs_runtime or project.get("target.runtimes") + + -- we always pass some configurations from toplevel even it's headeronly, because it's library deps need inherit them + -- but we will reset it for headeronly package after finishing requireinfo + -- @see https://github.com/xmake-io/xmake/issues/2688 + if package:is_library() then + requireinfo.configs.toolchains = requireinfo.configs.toolchains or project.get("target.toolchains") if project.policy("package.inherit_external_configs") then - requireinfo.configs.vs_runtime = requireinfo.configs.vs_runtime or get_config("vs_runtime") + requireinfo.configs.toolchains = requireinfo.configs.toolchains or get_config("toolchain") end - requireinfo.configs.lto = requireinfo.configs.lto or project.policy("build.optimization.lto") end + requireinfo.configs.vs_runtime = requireinfo.configs.vs_runtime or project.get("target.runtimes") + if project.policy("package.inherit_external_configs") then + requireinfo.configs.vs_runtime = requireinfo.configs.vs_runtime or get_config("vs_runtime") + end + requireinfo.configs.lto = requireinfo.configs.lto or project.policy("build.optimization.lto") end end @@ -487,6 +489,8 @@ function _finish_requireinfo(requireinfo, package) requireinfo.configs = requireinfo.configs or {} if package:is_headeronly() then requireinfo.configs.vs_runtime = nil + requireinfo.configs.toolchains = nil + requireinfo.configs.lto = nil else if requireinfo.configs.vs_runtime == nil and package:is_plat("windows") then requireinfo.configs.vs_runtime = "MT"