[cmake-developers] [CMake 0012359]: Windows 7 CMAKE_INSTALL_PREFIX does not work within Visual Studio due to permission problems

Mantis Bug Tracker mantis at public.kitware.com
Mon Jul 25 10:58:55 EDT 2011


The following issue has been SUBMITTED. 
====================================================================== 
http://cmake.org/Bug/view.php?id=12359 
====================================================================== 
Reported By:                Russ Tayor
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   12359
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2011-07-25 10:58 EDT
Last Modified:              2011-07-25 10:58 EDT
====================================================================== 
Summary:                    Windows 7 CMAKE_INSTALL_PREFIX does not work within
Visual Studio due to permission problems
Description: 
Windows 7 requires programs that copy files into Program Files to not only be
run by users with permission to write there, but also to be "Run as
administrator."  This breaks the INSTALL build when it is set to there.

I attach a workaround under Additional Information that changes the install dir
on all WIN32 platforms; if we could find just Windows 7, that could be better.

Basically, the default needs to be set to somewhere the user can write. 
/usr/local seems as good a place as any to me.

Steps to Reproduce: 
Build INSTALL project on Windows 7.

Additional Information: 
###
# On Windows 7, it does not work to install in the default location,
# which is the Program Files directory, because you have to not only have
# file permission to write there but also "run as administrator."  This
# means that "make install" from a Visual Studio project fails.  To get
# around that, we need to set CMAKE_INSTALL_PREFIX to something other
# than the default.  However, it is a cache variable that has already been
# set.  If we make a local variable, it uses this rather than the cache
# variable and never tells the poor user what happened (the GUI location
# looks standard but the files end up somewhere else).  If we make it a
# non-forced cache variable, it already has a value so does not change.
# If we make it a forced cache variable, it gets overwritten everytime
# and the user cannot change it on the GUI.  So we have a workaround here.
# We make a cache variable that records whether we have ever forced the
# install prefix.  If not, we force it.  If so, we don't force it again.
# This has the effect of setting it the first time cmake is run, showing
# the change in the GUI, and also letting the user change the value in
# the GUI if they don't like what we did.  If I knew how to do this only
# happen on Windows 7, I'd make the if(WIN32) more specific.
if (WIN32)
        if (NOT ONCE_SET_CMAKE_INSTALL_PREFIX)
                set(ONCE_SET_CMAKE_INSTALL_PREFIX true CACHE BOOL
                        "Have we set the install prefix yet?" FORCE)
                set(CMAKE_INSTALL_PREFIX /usr/local CACHE PATH
                    "Install path prefix, prepended onto install directories"
                    FORCE)
        endif (NOT ONCE_SET_CMAKE_INSTALL_PREFIX)
endif (WIN32)
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2011-07-25 10:58 Russ Tayor     New Issue                                    
======================================================================




More information about the cmake-developers mailing list