diff options
| author | ruki <[email protected]> | 2024-02-19 23:07:12 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-02-19 23:07:12 +0800 |
| commit | 49de9a9a700de09485b6a60eaff920fb3232302e (patch) | |
| tree | 2580d89983f9a873a7027bcb25c0b76ddc99fbaa | |
| parent | 87d27fbdd46f44690f5d47cff8ad8145664aa19d (diff) | |
fix link objects for cmake/modules
| -rw-r--r-- | xmake/plugins/project/cmake/cmakelists.lua | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/xmake/plugins/project/cmake/cmakelists.lua b/xmake/plugins/project/cmake/cmakelists.lua index 6a19f111a..c358d401f 100644 --- a/xmake/plugins/project/cmake/cmakelists.lua +++ b/xmake/plugins/project/cmake/cmakelists.lua @@ -169,6 +169,11 @@ function _sourcebatch_is_built(sourcebatch) end end +-- get c++ modules rules +function _get_cxxmodules_rules() + return {"c++.build.modules", "c++.build.modules.builder"} +end + -- translate flag function _translate_flag(flag, outputdir) if flag then @@ -835,11 +840,22 @@ function _add_target_link_libraries(cmakelists, target, outputdir) cmakelists:print(")") end + -- ignore c++ modules rules + local cxxmodules_rules + if _can_native_support_for_cxxmodules() then + cxxmodules_rules = _get_cxxmodules_rules() + end + if cxxmodules_rules then + cxxmodules_rules = hashset.from(cxxmodules_rules) + else + cxxmodules_rules = hashset.new() + end + -- add other object files, maybe from custom rules local objectfiles_set = hashset.new() local sourcebatches = target:sourcebatches() for _, sourcebatch in table.orderpairs(sourcebatches) do - if _sourcebatch_is_built(sourcebatch) then + if _sourcebatch_is_built(sourcebatch) or cxxmodules_rules:has(sourcebatch.rulename) then for _, objectfile in ipairs(sourcebatch.objectfiles) do objectfiles_set:insert(objectfile) end @@ -1002,7 +1018,7 @@ function _add_target_custom_commands(cmakelists, target, outputdir) -- ignore c++ modules rules local ignored_rules if _can_native_support_for_cxxmodules() then - ignored_rules = {"c++.build.modules", "c++.build.modules.builder"} + ignored_rules = _get_cxxmodules_rules() end -- add before commands |
