[CMake] CMAKE_INSTALL_PREFIX not being used?

Tom Davis tom at recursivedream.com
Tue May 5 14:26:44 EDT 2015


I now believe this is related to a thread back in December:

http://public.kitware.com/pipermail/cmake/2014-December/059298.html

It's super easy to reproduce: make a CMakeLists.txt file with
set(CMAKE_INSTALL_PREFIX "foo") and watch it get written to cmake_install.cmake
regardless of any command-line arguments or cache entries.

Tom Davis writes:

> I'm trying to install a project to /home/tom/usr/local instead of the standard
> /usr/local. I have tried the following:
>
> $ mkdir build && cd build
> $ cmake -DCMAKE_INSTALL_PREFIX:PATH=/home/tom ..
>
> At this point, I have a CMakeCache.txt file that contains the correct path. I
> have a cmake_install.cmake with the lines:
>
>     if(NOT DEFINED CMAKE_INSTALL_PREFIX)
>       set(CMAKE_INSTALL_PREFIX "foo")
>     endif()
>
> Where "foo" is found in the project's CMakeLists.txt as a default install prefix
> via `set(CMAKE_INSTALL_PREFIX ${CMAKE_PROJECT_NAME})`. Unfortunately, when I run
> `make install`, the project is still being installed to `build/foo/`. My
> apparently incorrect understanding is that passing the value on the command line
> initially would override whatever was set() in the project's CMakeLists.txt, but
> that isn't the case.
>
> Since I'm actually installing this project using ExternalProject_Add(), how can
> I override the set() in the project's CMakeLists.txt, if not by using the extra
> argument during the CONFIGURE step?


More information about the CMake mailing list