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

前端 未结 5 1946
情歌与酒
情歌与酒 2021-01-30 16:55

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 d

相关标签:
5条回答
  • 2021-01-30 17:16

    Just in case if someone is not using CMake then there is a method to do that in Makefile. If you have Makefile.config file generated in your build directory, find the prefix. This prefix is the install path where binaries/headers etc. will be installed. Changing this will install the binaries/headers to the modified path.

    0 讨论(0)
  • 2021-01-30 17:31

    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.

    0 讨论(0)
  • 2021-01-30 17:34

    The canonical definition of DESTDIR and prefix is: the files are installed to $DESTDIR$prefix, but prepared as if their final install location was just $prefix.

    So DESTDIR is only for people building packages or tarballs of binaries; CMAKE_INSTALL_PREFIX is for anyone who wants to specify where the built binaries should live in the end.

    0 讨论(0)
  • 2021-01-30 17:38

    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[...]

    0 讨论(0)
  • 2021-01-30 17:41

    Running CMake with -DCMAKE_INSTALL_PREFIX=<somewhere different to last time> shouldn't cause your project to need recompiled. If you pass other command line parameters to CMake which e.g. alter the compiler flags, that would force a rebuild of affected targets, but simply changing the install prefix won't.

    0 讨论(0)
提交回复
热议问题