Building and installing neovim to location different from CMAKE_INSTALL_PREFIX

I am trying to build the latest neovim from sources on Ubuntu 20.04. I want the destination to be /opt/alexj . So I do the following:


So far, so good. However, I don’t want to istall neovim into /opt/alexj directly. I manage my installs in /opt/alexj with stow, so I really want make install to copy all the required files under /opt/alexj/stow/neovim.

This is the part I am struggling with. If I specify CMAKE_INSTALL_PREFIX=/opt/alexj, this is where make install tries to copy all the files. And if I specify CMAKE_INSTALL_PREFIX=/opt/alexj/stow/neovim, then nvim is compiled to look in this folder for all runtime files (this kind of works with stow workflow, but looks ugly). I have tried to use different CMAKE_INSTALL_PREFIX for make and make install, but this does not work also, because make install rebuilds nvim before isntalling…

I did some googling, but was unable to find a working advice so far.

This article has a good advice, but only for autotools build:

./configure --prefix=/usr/local && make && sudo make install prefix=/usr/local/stow/foo

This page mentions similar solution for CMake, but I was not able to apply it to neovim build …:

cmake -DCMAKE_INSTALL_PREFIX=/tmp/test1 -P cmake_install.cmake
cmake -DCMAKE_INSTALL_PREFIX=/tmp/test2 -P cmake_install.cmake

Any help would be appreciated.

You may want to take a look at the neovim wiki - installing from source section for that.

Basically, run make with make CMAKE_EXTRA_FLAGS="-DCMAKE_INSTALL_PREFIX=/opt/alexj/neovim"

And then run make install

May need to provide sudo since you are accessing root directories.