summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2023-01-11 17:31:14 +0100
committerArthur LAURENT <[email protected]>2023-01-11 17:31:14 +0100
commit98e4399340bca560915c8faef19a632840046a0e (patch)
tree5d998779c531c71bcc2e2151110999bef403df83
parenta70a59a68f39d9c9ba3538baa94dcce6132f1241 (diff)
use policies instead of target values
-rw-r--r--tests/projects/c++/modules/stdmodules/xmake.lua4
-rw-r--r--tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua4
-rw-r--r--xmake/core/project/policy.lua2
-rw-r--r--xmake/rules/c++/modules/modules_support/clang.lua4
4 files changed, 8 insertions, 6 deletions
diff --git a/tests/projects/c++/modules/stdmodules/xmake.lua b/tests/projects/c++/modules/stdmodules/xmake.lua
index 8007553ed..496961cd0 100644
--- a/tests/projects/c++/modules/stdmodules/xmake.lua
+++ b/tests/projects/c++/modules/stdmodules/xmake.lua
@@ -5,11 +5,11 @@ target("mod")
set_kind("static")
add_files("src/*.cpp", "src/*.mpp")
- set_values("c++.clang.module.stdmodules", true)
+ set_policy("c++.clang.module.stdmodules", true)
target("stdmodules")
set_kind("binary")
add_files("test/*.cpp")
add_deps("mod")
- set_values("c++.clang.module.stdmodules", true)
+ set_policy("c++.clang.module.stdmodules", true)
diff --git a/tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua b/tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua
index 330fa56f8..3501597ff 100644
--- a/tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua
+++ b/tests/projects/c++/modules/stdmodules_multiple_targets/xmake.lua
@@ -5,10 +5,10 @@ target("mod")
set_kind("static")
add_files("src/*.cpp", "src/*.mpp")
- set_values("c++.clang.module.stdmodules", true)
+ set_policy("c++.clang.module.stdmodules", true)
target("mod2")
set_kind("static")
add_files("src/*.cpp", "src/*.mpp")
- set_values("c++.clang.module.stdmodules", true)
+ set_policy("c++.clang.module.stdmodules", true)
diff --git a/xmake/core/project/policy.lua b/xmake/core/project/policy.lua
index 8148a37e2..ac93415f9 100644
--- a/xmake/core/project/policy.lua
+++ b/xmake/core/project/policy.lua
@@ -35,6 +35,8 @@ function policy.policies()
if not policies then
policies =
{
+ -- enable clang std modulemap
+ ["c++.clang.module.stdmodules"] = {description = "Enable clang std modulemap.", default = false, type = "boolean"},
-- we will check and ignore all unsupported flags by default, but we can also pass `{force = true}` to force to set flags, e.g. add_ldflags("-static", {force = true})
["check.auto_ignore_flags"] = {description = "Enable check and ignore unsupported flags automatically.", default = true, type = "boolean"},
-- we will map gcc flags to the current compiler and linker by default.
diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua
index 74b2f62cc..747c62166 100644
--- a/xmake/rules/c++/modules/modules_support/clang.lua
+++ b/xmake/rules/c++/modules/modules_support/clang.lua
@@ -84,7 +84,7 @@ function load(target)
target:add("cxxflags", modulestsflag)
end
- if target:values("c++.clang.modules.stdmodules") then
+ if target:policy("c++.clang.module.stdmodules") then
target:add("cxxflags", builtinmodulemapflag, {force = true})
target:add("cxxflags", implicitmodulesflag, {force = true})
else
@@ -298,7 +298,7 @@ function generate_dependencies(target, sourcebatch, opt)
end
end
- assert(not (has_std_modules and not target:values("c++.clang.modules.stdmodules")),
+ assert(not (has_std_modules and not target:policy("c++.clang.modules.stdmodules")),
[[On llvm <= 16 standard C++ modules are not supported ;
they can be emulated through clang modules and supported only on libc++ ;
please add -stdlib=libc++ cxx flag or disable strict mode]])