I am working on a project which takes considerable time to build (10-15) minutes. I have recompiled to verify if there is a compilation error. Now I want to change the install directory so that I have a new version of executable with the new changes. Is there a method to just modify the install path so that the 'make install' installs to a new location rather than the old one?
The installation directory is usually left at its default, which is /usr/local . Installing software here ensures that it is automatically available to users. It is possible to specify a different installation directory by adding -DCMAKE_INSTALL_PREFIX=/path/to/install/dir to the CMake command line.
The installation path is a standard location and cannot be changed. If you have another drive that has space, you can move any amount of your files to that drive by mounting your big directories at partitions on that drive (this is easiest to do when you are first installing Ubuntu).
CMake provides the install command to specify how a project is to be installed. This command is invoked by a project in the CMakeLists file and tells CMake how to generate installation scripts. The scripts are executed at install time to perform the actual installation of files.
cmake contains the commands generated by install command from your CMakeLists. txt . You can execute it by cmake -P cmake_install. cmake and it performs the installation of your project even on windows.
CMake generated makefiles support the DESTDIR coding convention for makefiles. Thus you can override the default installation location by setting the DESTDIR
variable upon invoking make:
$ make install DESTDIR=/opt/local
There is no need to re-run CMake.
I don't know whether this is generally true, but I can give an example of an application for which the accepted answer by sakra
does not work properly. If you modify the install directory by modifying DESTDIR
when installing ITK, it will just append DESTDIR
to its already formed install path:
make install DESTDIR=/opt/local
[...]
-- Installing: /opt/local/usr/local/lib/cmake/ITK-4.4/WrapITK/Configuration/Typedefs/itkRenyiEntropy[...]
On the other hand, following this answer by Fraser
will result in proper install paths without recompilation:
cmake -DCMAKE_INSTALL_PREFIX=/opt/local /path/to/ITK_source make install
[...]
-- Installing: /opt/local/lib/cmake/ITK-4.4/WrapITK/Configuration/Typedefs/itkRenyiEntropy[...]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With