[CMake] is ccmake reliable?

James C. Sutherland James.Sutherland at utah.edu
Tue Sep 15 16:08:44 EDT 2009


On Sep 15, 2009, at 12:59 PM, Tyler Roscoe wrote:

> On Tue, Sep 15, 2009 at 12:37:27PM -0600, James C. Sutherland wrote:
>> A related question:  If I set CMAKE_INSTALL_PREFIX in my
>> CMakeLists.txt file
>>> set( CMAKE_INSTALL_PREFIX
>>> ${CMAKE_CURRENT_BINARY_DIR}
>>> )
>> and then run ccmake, I find that the CMAKE_INSTALL_PREFIX variable is
>> set to /usr/local rather than the binary directory.  Is this a  
>> bug?  I
>
> There is a world of difference between set() and set(... CACHE ...).
> Consult the docs.
>
> What you've done above is set a variable that has nothing to do
> with the cache, and in fact will override whatever is in the cache.
> Hence:
>
>>> message( STATUS "Files will be installed to: " $
>>> {CMAKE_INSTALL_PREFIX} )
>>
>> then it reflects the correct directory, but the CMakeCache.txt file
>
> In a project configured the way you show in this email, your manually
> set variable will always be used; the cache variable will always be
> ignored.
>
> tyler

Thanks for the tip.

So assuming that I wanted my CMakeLists.txt file to modify the default  
install location, but allow the user to change this, wouldn't I do  
something like:
> set( CMAKE_INSTALL_PREFIX
>  ${CMAKE_CURRENT_BINARY_DIR}
>  CACHE PATH "installation path"
>  )
This doesn't work - I assume that this is because CMAKE_INSTALL_PREFIX  
is a special (internally defined) variable?  When I run ccmake and  
configure, the value remains as /usr/local.


More information about the CMake mailing list