Search code examples
makefilecmakeconfigurebuild-system

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?


Solution

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