diff options
| author | ruki <[email protected]> | 2023-06-30 22:49:45 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-06-30 22:49:45 +0800 |
| commit | c0054507841b34eddfe163fc4b64ff39bb3865a0 (patch) | |
| tree | 8c3d58bdc7b21b84179812559a0ccb1544c2e149 | |
| parent | b408fc1e987970fc00c0afdebedd5d99376a1307 (diff) | |
fix pch for clang-cl #3905
| -rw-r--r-- | xmake/modules/core/tools/cl.lua | 8 | ||||
| -rw-r--r-- | xmake/modules/core/tools/clang_cl.lua | 24 |
2 files changed, 24 insertions, 8 deletions
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua index 2a0bc556c..e5addc78a 100644 --- a/xmake/modules/core/tools/cl.lua +++ b/xmake/modules/core/tools/cl.lua @@ -314,11 +314,7 @@ end -- make the c precompiled header flag function nf_pcheader(self, pcheaderfile, target) - - -- for c source file if self:kind() == "cc" then - - -- patch objectfile local objectfiles = target:objectfiles() if objectfiles then table.insert(objectfiles, target:pcoutputfile("c") .. ".obj") @@ -329,11 +325,7 @@ end -- make the c++ precompiled header flag function nf_pcxxheader(self, pcheaderfile, target) - - -- for c++ source file if self:kind() == "cxx" then - - -- patch objectfile local objectfiles = target:objectfiles() if objectfiles then table.insert(objectfiles, target:pcoutputfile("cxx") .. ".obj") diff --git a/xmake/modules/core/tools/clang_cl.lua b/xmake/modules/core/tools/clang_cl.lua index 07b8691f7..dde36b31c 100644 --- a/xmake/modules/core/tools/clang_cl.lua +++ b/xmake/modules/core/tools/clang_cl.lua @@ -104,6 +104,30 @@ function nf_optimize(self, level) return maps[level] end +-- make the c precompiled header flag +function nf_pcheader(self, pcheaderfile, target) + if self:kind() == "cc" then + local objectfiles = target:objectfiles() + if objectfiles then + table.insert(objectfiles, target:pcoutputfile("c") .. ".obj") + end + return {"-Yu" .. path.filename(pcheaderfile), "-FI" .. path.filename(pcheaderfile), "-I" .. path.directory(pcheaderfile), "-Fp" .. target:pcoutputfile("c")} + end +end + +-- make the c++ precompiled header flag +function nf_pcxxheader(self, pcheaderfile, target) + if self:kind() == "cxx" then + local objectfiles = target:objectfiles() + if objectfiles then + table.insert(objectfiles, target:pcoutputfile("cxx") .. ".obj") + end + -- https://github.com/xmake-io/xmake/issues/3905 + -- clang-cl need extra include search path + return {"-Yu" .. path.filename(pcheaderfile), "-FI" .. path.filename(pcheaderfile), "-I" .. path.directory(pcheaderfile), "-Fp" .. target:pcoutputfile("c")} + end +end + -- compile the source file function compile(self, sourcefile, objectfile, dependinfo, flags) |
