diff options
| author | ruki <[email protected]> | 2023-07-24 22:54:40 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-07-24 22:54:40 +0800 |
| commit | 2d76e97e891dc655df0fe97c02c626b6497c0b45 (patch) | |
| tree | 53e116f8a55b78647860f6bbb60d22f61ec799f8 | |
| parent | a66ddd6fca5c2334a5d812730857b3a2665866be (diff) | |
fix pch for #3988
| -rw-r--r-- | xmake/modules/private/action/build/object.lua | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/xmake/modules/private/action/build/object.lua b/xmake/modules/private/action/build/object.lua index 479ef8add..6668d9695 100644 --- a/xmake/modules/private/action/build/object.lua +++ b/xmake/modules/private/action/build/object.lua @@ -90,15 +90,25 @@ function _do_build_file(target, sourcefile, opt) dependinfo.files = {} assert(compinst:compile(sourcefile, objectfile, {dependinfo = dependinfo, compflags = compflags})) - -- update files and values to the dependent file + -- update files and values to the depfiles dependinfo.values = depvalues table.insert(dependinfo.files, sourcefile) - local pcoutputfile = target:pcoutputfile("cxx") - if target:has_sourcekind("cxx") and pcoutputfile then - table.insert(dependinfo.files, pcoutputfile) - end + + -- add precompiled header to the depfiles when building sourcefile + local build_pch + local pcxxoutputfile = target:pcoutputfile("cxx") local pcoutputfile = target:pcoutputfile("c") - if target:has_sourcekind("cc") and pcoutputfile then + if pcxxoutputfile or pcoutputfile then + -- https://github.com/xmake-io/xmake/issues/3988 + local extension = path.extension(sourcefile) + if (extension:startswith(".h") or extension == ".inl") then + build_pch = true + end + end + if target:has_sourcekind("cxx") and pcxxoutputfile and not build_pch then + table.insert(dependinfo.files, pcxxoutputfile) + end + if target:has_sourcekind("cc") and pcoutputfile and not build_pch then table.insert(dependinfo.files, pcoutputfile) end depend.save(dependinfo, dependfile) |
