diff options
| author | Arthur LAURENT <[email protected]> | 2025-05-05 18:10:07 +0200 |
|---|---|---|
| committer | Arthur LAURENT <[email protected]> | 2025-05-09 15:56:33 +0200 |
| commit | 41bb46475576049e3b0dc6c008311c41d8432f62 (patch) | |
| tree | 5559a7e4be1000fada433b54aefb6fc6fcd91bf5 /xmake/rules/c++/modules/scanner.lua | |
| parent | 5d6d36e0db45d90dfa7f0cdf2937d989de683833 (diff) | |
(C++ modules support) fix CMake generation
Diffstat (limited to 'xmake/rules/c++/modules/scanner.lua')
| -rw-r--r-- | xmake/rules/c++/modules/scanner.lua | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/xmake/rules/c++/modules/scanner.lua b/xmake/rules/c++/modules/scanner.lua index d42c2d93e..da15e9177 100644 --- a/xmake/rules/c++/modules/scanner.lua +++ b/xmake/rules/c++/modules/scanner.lua @@ -766,21 +766,25 @@ function get_modules(target) end function after_scan(target) - local sourcebatch_scanner = target:sourcebatches()["c++.build.modules.scanner"] - local sourcebatch_builder = target:sourcebatches()["c++.build.modules.builder"] - if target:data("cxx.has_modules") and not target:is_moduleonly() then - local _, _, objectfiles = sort_modules_by_dependencies(target, get_modules(target), {jobgraph = target:policy("build.jobgraph")}) - sourcebatch_scanner.objectfiles = objectfiles - sourcebatch_builder.objectfiles = objectfiles - elseif sourcebatch_scanner then - -- avoid duplicate linking of object files of non-module programs - sourcebatch_scanner.objectfiles = {} - sourcebatch_builder.objectfiles = {} + local compile_commands = os.getenv("XMAKE_IN_PROJECT_GENERATOR") and os.getenv("XMAKE_IN_COMPILE_COMMANDS_PROJECT_GENERATOR") + if not os.getenv("XMAKE_IN_PROJECT_GENERATOR") or compile_commands then + local sourcebatch_scanner = target:sourcebatches()["c++.build.modules.scanner"] + local sourcebatch_builder = target:sourcebatches()["c++.build.modules.builder"] + if target:data("cxx.has_modules") and not target:is_moduleonly() then + local _, _, objectfiles = sort_modules_by_dependencies(target, get_modules(target), {jobgraph = target:policy("build.jobgraph")}) + sourcebatch_scanner.objectfiles = objectfiles + sourcebatch_builder.objectfiles = objectfiles + elseif sourcebatch_scanner then + -- avoid duplicate linking of object files of non-module programs + sourcebatch_scanner.objectfiles = {} + sourcebatch_builder.objectfiles = {} + end end end function main(target, jobgraph, sourcebatch) - if target:data("cxx.has_modules") then + local compile_commands = os.getenv("XMAKE_IN_PROJECT_GENERATOR") and os.getenv("XMAKE_IN_COMPILE_COMMANDS_PROJECT_GENERATOR") + if target:data("cxx.has_modules") and (not os.getenv("XMAKE_IN_PROJECT_GENERATOR") or compile_commands) then _patch_sourcebatch(target, sourcebatch) _schedule_module_dependencies_scan(target, jobgraph, sourcebatch) end |
