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--------
This question has come up several times and I've been deferring a fix
until a project-specified initial cache feature is implemented. That
feature has been delayed because it is tricky.
I've just added a fix to CVS CMake for this. It will be in 2.4.4 (the
upcoming patch release). Basically your code needs to know whether the
current value of CMAKE_INSTALL_PREFIX was set by the user on the command
line or initialized by CMake. Now when CMake initializes the variable
it also sets CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT to true. This
enables projects to change the default install prefix like this:
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
SET(CMAKE_INSTALL_PREFIX
"/opt/foo" CACHE PATH "FOO install prefix" FORCE
)
ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
----
> Does it do this for all internal cmake variables or only for CMAKE_INSTALL_PREFIX ? Just the install prefix. I don't want to do it for every variable. For that we need a PreLoad.cmake feature (which is partially implemented but not really working) to have project-specific initial cache entries. I just put this one in as a hack because so many users have asked for this specific capability and it is a simple change before the 2.4.4 release. -Brad
-----
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=======================================CMAKE_INSTALL_PREFIX: cmake ../kdelibs -DCMAKE_INSTALL_PREFIX=/opt/kde4 is the equivalent to ./configure --prefix=/opt/kde4
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.