[CMake] How to check/set CMAKE_INSTALL_PREFIX

Alan W. Irwin irwin at beluga.phys.uvic.ca
Mon Oct 16 14:38:16 EDT 2006


On 2006-10-16 18:22+0200 Eric Noulard wrote:

> 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 :((

Try dropping the Boolean logic and FORCE.  i.e., use just

SET(CMAKE_INSTALL_PREFIX "/opt/${PACKAGE_NAME}-${PACKAGE_VERSION}"
CACHE PATH "Install path prefix")

That style works for us to provide a default option that can be changed by
the user.  I assume that style will also work to override a variable that has
already been cached, but I don't know for sure.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the Yorick front-end to PLplot (yplot.sf.net); the
Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list