telescope-fzf-native.nvim icon indicating copy to clipboard operation
telescope-fzf-native.nvim copied to clipboard

CMake deprecation error < 3.5

Open D3vil0p3r opened this issue 1 year ago • 10 comments
trafficstars

I'm using NixOS with Neovim. Installing telescope-fzf-native.nvim by the following telescope.lua file:

local status_ok, telescope = pcall(require, "telescope")
if not status_ok then
  return
end

local actions = require "telescope.actions"

vim.api.nvim_set_keymap('v', '<C-g>', 'y<ESC>:Telescope live_grep default_text=<c-r>0<CR>',{ noremap = true, silent = true })

telescope.setup {
  pickers = {
    find_files = {
      previewer = false,
      hidden = true
    },
    colorscheme = {
      enable_preview = true,
    },
  },
  extensions_list = { "themes", "terms" },
  defaults = {
    prompt_prefix = " ",
    selection_caret = " ",
    path_display = { "smart" },
    file_ignore_patterns = { "node_modules" },
    mappings = {
      i = {
        ["<C-j>"] = actions.move_selection_next,
        ["<C-k>"] = actions.move_selection_previous,
        ["<C-c>"] = actions.close,
        ["<C-n>"] = actions.cycle_history_next,
        ["<C-p>"] = actions.cycle_history_prev,
        ["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
        ["<CR>"] = actions.select_default,
      },
      n = {
        ["j"] = actions.move_selection_next,
        ["k"] = actions.move_selection_previous,
        ["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
        ["<C-x>"] = actions.select_horizontal,
        ["<C-v>"] = actions.select_vertical,
      },
    },
  },
}

-- Enable telescope fzf native, if installed
pcall(telescope.load_extension, 'fzf')

and when I place telescope.lua among the plugins of Neovim, when I run nvim for the first time, at compilation time of this plugin I get

image

In plugins.lua it is dealt with:

  {
    'nvim-telescope/telescope-fzf-native.nvim',
    build =
    'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build'
  },
  {
    "nvim-telescope/telescope.nvim",
    dependencies = {
      'nvim-telescope/telescope-fzf-native.nvim', -- file icons on nvim-tree
    },
  },

Why I get this deprecation error despite I'm using CMake 3.27? The problem is in CMakeLists.txt at:

cmake_minimum_required(VERSION 3.2)

?

D3vil0p3r avatar Jan 28 '24 02:01 D3vil0p3r

we could bump the minimum_required cmake version to idk 3.9

Conni2461 avatar Mar 05 '24 14:03 Conni2461

we could bump the minimum_required cmake version to idk 3.9

We can try to see if it fixes this issue.

D3vil0p3r avatar Mar 05 '24 17:03 D3vil0p3r

The real issue is in the build command advertised by the plugin. The final install step fails at

file(INSTALL DESTINATION "/home/x/.local/share/nvim/lazy/telescope-fzf-native.nvim/build" TYPE SHARED_LIBRARY FILES "/home/x/.local/share/nvim/lazy/telescope-fzf-native.nvim/build/libfzf.so")

At first look this install step is entirely redundant. On second look its dangerous because it is undefined behavior which new versions of cmake seem to have affected. So PSA for people coming here:

-          cmake --build build --config Release && \
-          cmake --install build --prefix build",
+          cmake --build build --config Release",

Alternatively use build = 'make'

ditsuke avatar Jul 01 '24 14:07 ditsuke

I get the same issue, also on NixOS. I tried changing the build command in my lua config to both 'make' and 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release' and it did not seem to change anything; I still get the issue.

I did, however, find a workaround: just go to your shell and manually run make:

cd [nvim data dir]/lazy/telescope-fzf-native.nvim
make

copperthief avatar Jul 03 '24 16:07 copperthief

I ran into the same issue on Nix using LazyVim. Seems they check whether cmake is installed or fall back to make if it's not. Perhaps you could add a similar check and just build with make until this gets resolved.

https://github.com/LazyVim/LazyVim/blob/12818a6cb499456f4903c5d8e68af43753ebc869/lua/lazyvim/plugins/extras/editor/telescope.lua#L65-L67

99linesofcode avatar Jul 26 '24 12:07 99linesofcode