Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lua/cmake-tools/const.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ local const = {
-- copy: this will automatically copy compile commands file to target
-- lsp: this will automatically set compile commands file location using lsp
-- none: this will make this option ignored
target = vim.loop.cwd(), -- path to directory, this is used only if action == "soft_link" or action == "copy"
---@type string|fun(): string
target = vim.loop.cwd, -- path or function returning path to directory, this is used only if action == "soft_link" or action == "copy"
},
cmake_kits_path = nil, -- this is used to specify global cmake kits path, see CMakeKits for detailed usage
cmake_variants_message = {
Expand Down
12 changes: 10 additions & 2 deletions lua/cmake-tools/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,11 @@ function cmake.copy_compile_commands()
end

local source = config:build_directory_path() .. "/compile_commands.json"
local destination = const.cmake_compile_commands_options.target .. "/compile_commands.json"
local target = const.cmake_compile_commands_options.target
if type(target) == "function" then
target = target()
end
local destination = target .. "/compile_commands.json"
utils.copyfile(source, destination)
end

Expand All @@ -1492,7 +1496,11 @@ function cmake.compile_commands_from_soft_link()
end

local source = config:build_directory_path() .. "/compile_commands.json"
local destination = const.cmake_compile_commands_options.target .. "/compile_commands.json"
local target = const.cmake_compile_commands_options.target
if type(target) == "function" then
target = target()
end
local destination = target .. "/compile_commands.json"
utils.softlink(source, destination)
end

Expand Down
Loading