installationcmake

How to properly set CMAKE_INSTALL_PREFIX from the command-line


I want to generate a Makefile with an install target, making installation to /usr instead of default /usr/local. Assuming that the build directory is a subdirectory of the source directory, I execute:

cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr ..

CMakeCache.txt contains: CMAKE_INSTALL_PREFIX:PATH=/usr (OK?)

Now I execute:

make
make install

All files are still installed to usr/local. What is wrong?

Edit: There is no CMAKE_INSTALL_PREFIX in any of the CMakeLists.txt project files. Before running cmake, I delete everything from the output directory. install directives in CMakeLists.txt look like:

install(TARGETS mylibrary DESTINATION lib)

Solution

  • That should be (see the docs):

    cmake -DCMAKE_INSTALL_PREFIX=/usr ..