diff options
| author | ruki <[email protected]> | 2025-01-09 00:42:04 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-01-09 00:42:04 +0800 |
| commit | 672112971ac26e4ed5bc5789938a82e8dbc22c86 (patch) | |
| tree | d93c6d49bd01ab1ead7049b67f8225398658fdcc | |
| parent | 53f150785e89570e481a50be252df2ab300b6e52 (diff) | |
improve has_config test
| -rw-r--r-- | tests/apis/namespace/option/xmake.lua | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/tests/apis/namespace/option/xmake.lua b/tests/apis/namespace/option/xmake.lua index 7043caf9d..b39b764f1 100644 --- a/tests/apis/namespace/option/xmake.lua +++ b/tests/apis/namespace/option/xmake.lua @@ -29,14 +29,16 @@ namespace("ns1", function () add_deps("foo", "ns2::bar") add_files("src/main.cpp") add_options("opt0", "opt1", "ns2::opt2") - if has_config("opt0") then - add_defines("HAS_OPT0") - end - if has_config("opt1") then - add_defines("HAS_NS1_OPT1") - end - if has_config("ns2::opt2") then - add_defines("HAS_NS2_OPT2") - end + on_load(function (target) + if has_config("opt0") then + target:add("defines", "HAS_OPT0") + end + if has_config("opt1") then + target:add("defines", "HAS_NS1_OPT1") + end + if has_config("ns2::opt2") then + target:add("defines", "HAS_NS2_OPT2") + end + end) end) |
