summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-08-21 23:42:12 +0800
committerruki <[email protected]>2023-08-21 23:42:12 +0800
commitd528d56c990bf06f99dcff2412fb19d9b1730c4f (patch)
treefdfa088e57da84c31e30c96c12522afe1c80acd4
parente73df8b4713c4b8c928c77d0baa4185be1db6517 (diff)
add force includes #4101
-rw-r--r--xmake/languages/c++/load.lua2
-rw-r--r--xmake/languages/c++/xmake.lua2
-rw-r--r--xmake/modules/core/tools/cl.lua14
-rw-r--r--xmake/modules/core/tools/gcc.lua14
4 files changed, 32 insertions, 0 deletions
diff --git a/xmake/languages/c++/load.lua b/xmake/languages/c++/load.lua
index 828385f6f..40d4b4bd8 100644
--- a/xmake/languages/c++/load.lua
+++ b/xmake/languages/c++/load.lua
@@ -35,6 +35,8 @@ function _get_apis()
, "target.add_undefines"
, "target.add_frameworks"
, "target.add_rpathdirs" -- @note do not translate path, it's usually an absolute path or contains $ORIGIN/@loader_path
+ , "target.add_cincludes"
+ , "target.add_cxxincludes"
-- option.add_xxx
, "option.add_cincludes"
, "option.add_cxxincludes"
diff --git a/xmake/languages/c++/xmake.lua b/xmake/languages/c++/xmake.lua
index 2df4ba6c9..99b60fb07 100644
--- a/xmake/languages/c++/xmake.lua
+++ b/xmake/languages/c++/xmake.lua
@@ -51,6 +51,8 @@ language("c++")
, "target.encodings"
, "target.pcheader"
, "target.pcxxheader"
+ , "target.cincludes"
+ , "target.cxxincludes"
, "toolchain.includedirs"
, "toolchain.defines"
, "toolchain.undefines"
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua
index b043370d1..44e696f4b 100644
--- a/xmake/modules/core/tools/cl.lua
+++ b/xmake/modules/core/tools/cl.lua
@@ -281,6 +281,20 @@ function nf_includedir(self, dir)
return {"-I" .. path.translate(dir)}
end
+-- make the force c include flag
+function nf_cinclude(self, headerfile)
+ if self:kind() == "cc" then
+ return {"-FI", headerfile}
+ end
+end
+
+-- make the force c++ include flag
+function nf_cxxinclude(self, headerfile)
+ if self:kind() == "cxx" then
+ return {"-FI", headerfile}
+ end
+end
+
-- make the sysincludedir flag
function nf_sysincludedir(self, dir)
local has_external_includedir = _g._HAS_EXTERNAL_INCLUDEDIR
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index 60bfc8e5e..37f1f345a 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -278,6 +278,20 @@ function nf_sysincludedir(self, dir)
return {"-isystem", path.translate(dir)}
end
+-- make the force c include flag
+function nf_cinclude(self, headerfile)
+ if self:kind() == "cc" then
+ return {"-include", headerfile}
+ end
+end
+
+-- make the force c++ include flag
+function nf_cxxinclude(self, headerfile)
+ if self:kind() == "cxx" then
+ return {"-include", headerfile}
+ end
+end
+
-- make the link flag
function nf_link(self, lib)
if lib:endswith(".a") or lib:endswith(".so") or lib:endswith(".dylib") or lib:endswith(".lib") then