Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to modify the install-path without running the configure script/cmake again

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?

like image 754
A. K. Avatar asked Nov 20 '12 19:11

A. K.


People also ask

How do I specify the install directory in CMake?

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.

How do I change the installation directory in Linux?

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).

What is install command in CMake?

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.

What is Cmake_install CMake file?

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.


2 Answers

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.

like image 112
sakra Avatar answered Oct 02 '22 19:10

sakra


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[...]
like image 40
kara deniz Avatar answered Oct 02 '22 19:10

kara deniz