Skip to content

Commit

Permalink
Fixed "Executable "<name>" was not found" after :CMake call
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyachur committed Mar 11, 2024
1 parent 52048fe commit 6eb25f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions autoload/utils/cmake.vim
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ function! utils#cmake#getBuildDir() abort
endfunction

function! utils#cmake#getBinaryPath(...) abort
let l:cmake_info = utils#cmake#common#getInfo()
let l:build_dir = utils#cmake#getBuildDir()
let l:cmake_info = utils#cmake#common#getInfo(l:build_dir)
let l:build_type = s:detectCMakeBuildType()
if has_key(l:cmake_info, 'targets') && has_key(l:cmake_info['targets'], l:build_type) && has_key(l:cmake_info['targets'][l:build_type], g:cmake_build_target)
if !has('win32')
Expand All @@ -319,7 +320,7 @@ function! utils#cmake#getBinaryPath(...) abort
let l:exec_path = ''
" Check absolute path /...
if l:target['pathes'][0][0] !=# '/'
let l:exec_path = utils#cmake#getBuildDir() . '/'
let l:exec_path = l:build_dir . '/'
endif
let l:exec_path .= l:target['pathes'][0]
return l:exec_path
Expand All @@ -329,7 +330,7 @@ function! utils#cmake#getBinaryPath(...) abort
let l:exec_path = ''
" Check absolute path C:...
if l:path[1] !=# ':'
let l:exec_path = utils#cmake#getBuildDir() . '/'
let l:exec_path = l:build_dir . '/'
endif
let l:exec_path .= l:path
return l:exec_path
Expand All @@ -344,7 +345,7 @@ function! utils#cmake#getBinaryPath(...) abort
let l:exec_filename = g:cmake_build_target
endif

let l:exec_path = findfile(exec_filename, utils#fs#fnameescape(utils#cmake#getBuildDir()) . '/**')
let l:exec_path = findfile(exec_filename, utils#fs#fnameescape(l:build_dir) . '/**')
if !empty(l:exec_path)
let l:exec_path = fnamemodify(l:exec_path, ':p')
endif
Expand Down
4 changes: 3 additions & 1 deletion autoload/utils/cmake/common.vim
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ function! utils#cmake#common#getInfo(...) abort
if exists('a:1') && !empty(a:1)
let l:build_dir = a:1
endif
if !empty(l:build_dir) && empty(s:cmake_cache_info)
" Recall collecting information if cmake info doesn't contain information
" about targets
if !empty(l:build_dir) && (empty(s:cmake_cache_info) || !has_key(s:cmake_cache_info, 'targets'))
call utils#cmake#common#collectCMakeInfo(l:build_dir)
endif
if !executable('cmake') || empty(s:cmake_cache_info)
Expand Down

0 comments on commit 6eb25f2

Please sign in to comment.