[CMake] CMAKE_INSTALL_PREFIX not being used?

Tom Davis tom at recursivedream.com
Thu Apr 30 16:45:01 EDT 2015


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