[CMake] How to check/set CMAKE_INSTALL_PREFIX

Eric Noulard eric.noulard at gmail.com
Mon Oct 16 12:22:54 EDT 2006


Hi all,

I want to setup a default value for CMAKE_INSTALL_PREFIX
if the user did not indicate a value.

so I put:

IF (NOT CMAKE_INSTALL_PREFIX)
  SET(CMAKE_INSTALL_PREFIX "/opt/${PACKAGE_NAME}-${PACKAGE_VERSION}"
CACHE PATH "Install path prefix" FORCE)
ELSE (NOT CMAKE_INSTALL_PREFIX)
  MESSAGE("CMAKE_INSTALL_PREFIX already set to: ${CMAKE_INSTALL_PREFIX}")
ENDIF (NOT CMAKE_INSTALL_PREFIX)

but is seems that CMAKE_INSTALL_PREFIX is always set in cache
BEFORE I test this :((

What is the good way to change the default value of CMAKE_INSTALL_PREFIX
besides the usual:

cmake -DCMAKE_INSTALL_PREFIX=/opt/ ../mysource

I wanted the cmake run as simple as possible like

cmake /path/to/source


-- 
Erk


More information about the CMake mailing list