View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0012340CMakeCMakepublic2011-07-14 16:562012-01-02 15:56
ReporterRuss Tayor 
Assigned ToDavid Cole 
PriorityhighSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformPCOSWindowsOS Version7
Product VersionCMake 2.8.4 
Target VersionFixed in Version 
Summary0012340: Setting CMAKE_INSTALL_PREFIX does not behave as expected
DescriptionWhen I set CMAKE_INSTALL_PREFIX in a CMakeLists.txt file as follows:

#-----------------------------------------------------------------------------
# Put this in /usr/local unless overridden. The default on Windows is
# in Program Files, but that breaks on Windows 7 because you have to be
# admin to write there.

set(CMAKE_INSTALL_PREFIX /usr/local/)

the behavior is not as expected. First, that value for the prefix does not show up in the GUI. Second, the value that is set in CMakeLists.txt file is the one that is actually used (so the one shown in cmake-gui is not used). Thus, there is no way to see that it has been changed or to override it.

This is not what happens with other variables in CMake.
Steps To ReproduceAdd the above into your CMakeLists.txt file for your favorite project.
Additional InformationThis also happens on MacOSX under CMake 2.8.2.
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0027037)
David Cole (manager)
2011-07-14 17:23

You must be relatively new to CMake...

CMAKE_INSTALL_PREFIX is a cache variable. The value you see in the gui is the cache value. When you write:

  set(CMAKE_INSTALL_PREFIX /usr/local/)

in a CMakeLists file, you are providing a local variable value that overrides the cache value for the remainder of the CMakeLists file. However, the overridden value does NOT show up in the gui. That's just the way that cache variables work in CMake.

So, learn to expect that. :-)

When you say "This is not what happens with other variables in CMake." I'm curious what you mean...? Because that is exactly what happens with all cache variables in CMake.

The values set in the CMakeLists files override the cached values, assuming that the programmer who writes the CMakeLists knows what he's doing.

CMAKE_INSTALL_PREFIX is "special" in this respect: CMake chooses a reasonable platform-specific default value for you very early in the configuration process, so there is no way for a project to define its own default value for the cache variable in a CMakeLists file without doing something fancy. If you want to do such a thing, I recommend using your own variable named <YOUR_PROJECT>_INSTALL_PREFIX and then doing:

  set(CMAKE_INSTALL_PREFIX "${xxxx_INSTALL_PREFIX}" CACHE INTERNAL "")

Making CMAKE_INSTALL_PREFIX an INTERNAL CACHE variable has a nice side-effect of hiding it from the gui, so users do not get confused.

This has all been discussed a very lot on the CMake users mailing list. Search the list archives for more information about CMAKE_INSTALL_PREFIX...
(0027050)
David Cole (manager)
2011-07-16 19:34

Please feel free to discuss further on the CMake users mailing list, or to re-open this issue if you need more information.
(0028105)
David Cole (manager)
2012-01-02 15:56

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2011-07-14 16:56 Russ Tayor New Issue
2011-07-14 17:10 David Cole Assigned To => David Cole
2011-07-14 17:10 David Cole Status new => assigned
2011-07-14 17:23 David Cole Note Added: 0027037
2011-07-16 19:34 David Cole Note Added: 0027050
2011-07-16 19:34 David Cole Status assigned => resolved
2011-07-16 19:34 David Cole Resolution open => no change required
2012-01-02 15:56 David Cole Note Added: 0028105
2012-01-02 15:56 David Cole Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team