summaryrefslogtreecommitdiff
path: root/xmake/plugins/project/cmake/cmakelists.lua
diff options
context:
space:
mode:
authorfcying <[email protected]>2025-06-22 13:08:01 +0800
committerfcying <[email protected]>2025-06-26 09:49:14 +0800
commit42e25f69c356dbb014459f472da1e99e27849418 (patch)
treef5307ec2275f36abe268b30dae03fc53e158ce0a /xmake/plugins/project/cmake/cmakelists.lua
parent749d449e2ff77f43771467b986aa203546f3a808 (diff)
feat(plugin/project): support gen compile_commands.json for specific target
Diffstat (limited to 'xmake/plugins/project/cmake/cmakelists.lua')
-rw-r--r--xmake/plugins/project/cmake/cmakelists.lua7
1 files changed, 5 insertions, 2 deletions
diff --git a/xmake/plugins/project/cmake/cmakelists.lua b/xmake/plugins/project/cmake/cmakelists.lua
index 5b5513307..c492ce6e2 100644
--- a/xmake/plugins/project/cmake/cmakelists.lua
+++ b/xmake/plugins/project/cmake/cmakelists.lua
@@ -31,6 +31,7 @@ import("lib.detect.find_tool")
import("private.utils.batchcmds")
import("private.utils.target", {alias = "target_utils"})
import("plugins.project.utils.target_cmds", {rootdir = os.programdir()})
+import("plugins.project.utils.target_utils", {rootdir = os.programdir()})
import("rules.c++.modules.support", {alias = "module_support", rootdir = os.programdir()})
-- get cmake version
@@ -348,7 +349,8 @@ function _add_project(cmakelists, outputdir)
-- set project name
local project_name = project.name()
if not project_name then
- for _, target in table.orderpairs(project.targets()) do
+ local project_targets = target_utils.get_project_targets()
+ for _, target in table.orderpairs(project_targets) do
project_name = target:name()
end
end
@@ -1389,7 +1391,8 @@ function _generate_cmakelists(cmakelists, outputdir)
_add_project(cmakelists, outputdir)
-- add targets
- for _, target in table.orderpairs(project.targets()) do
+ local project_targets = target_utils.get_project_targets()
+ for _, target in table.orderpairs(project_targets) do
_add_target(cmakelists, target, outputdir)
end
end