We can now configure, compile, link, and test the code, but we are missing the install target, which we will add in this section.
This is the Autotools approach to building and installing code:
$ ./configure --prefix=/some/install/path
$ make
$ make install
And this is the CMake way:
$ mkdir -p build
$ cd build
$ cmake -D CMAKE_INSTALL_PREFIX=/some/install/path ..
$ cmake --build .
$ cmake --build . --target install
To add an install target, we add the following snippet in src/CMakeLists.txt:
install(
TARGETS
vim
RUNTIME DESTINATION
${CMAKE_INSTALL_BINDIR}
)
In this example, we only install the executable. The Vim project installs a large number of files along with the binary (symbolic links and documentation files). To keep this section digestible, we don't install all other files in this example migration. For your own project, you should verify...