summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-04-20 00:56:50 +0800
committerruki <[email protected]>2022-04-20 00:56:50 +0800
commit93ea7fcca2680a7a8cf94b7147d6e3b04c77eef1 (patch)
treed2b76adc721208b8b66fff6ca7cbb6f593a9672f
parente71bc3a2e6d2f71784cdbf5463706311cb25efb2 (diff)
add source group to cmake
-rw-r--r--xmake/plugins/project/cmake/cmakelists.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/xmake/plugins/project/cmake/cmakelists.lua b/xmake/plugins/project/cmake/cmakelists.lua
index dba4e0c0e..ee056c5b4 100644
--- a/xmake/plugins/project/cmake/cmakelists.lua
+++ b/xmake/plugins/project/cmake/cmakelists.lua
@@ -215,6 +215,27 @@ function _add_target_sources(cmakelists, target)
end
end
+-- add target source groups
+function _add_target_source_groups(cmakelists, target)
+ --[[TODO
+ local filegroups = target:get("filegroups")
+ for _, filegroup in ipairs(filegroups) do
+ local files = target:extraconf("filegroups", filegroup, "files") or "**"
+ local mode = target:extraconf("filegroups", filegroup, "mode")
+ if mode and mode == "plain" then
+ mode = ""
+ else
+ mode = "TREE "
+ end
+ local rootdir = target:extraconf("filegroups", filegroup, "rootdir")
+ assert(rootdir, "please set root directory, e.g. add_filegroups(%s, {rootdir = 'xxx'})", filegroup)
+ for _, filepattern in ipairs(files) do
+ cmakelists:print("source_group(%s%s %s REGULAR_EXPRESSION %s)",
+ mode, _get_unix_path(filegroup), _get_unix_path(rootdir), _get_unix_path(filepattern))
+ end
+ end]]
+end
+
-- add target precompilied header
function _add_target_precompiled_header(cmakelists, target)
local precompiled_header = target:get("pcheader") or target:get("pcxxheader")
@@ -782,6 +803,9 @@ function _add_target(cmakelists, target)
-- add target sources
_add_target_sources(cmakelists, target)
+ -- add target source groups
+ _add_target_source_groups(cmakelists, target)
+
-- end
cmakelists:print("")
end