[CMake] How to run an install command as administrator?

Alan W. Irwin irwin at beluga.phys.uvic.ca
Thu May 26 13:29:20 EDT 2016


On 2016-05-26 10:16-0600 Juan Dent wrote:

> Hi,
>
>
>
> I have a simple CMakeLists.txt that tries to install at a place in the drive
> that requires administrator privileges. How can I make that install command
> to run as administrator, is there a way in CMake?

CMake configures a build and install, but does not actually do those
tasks.  For example, for the "Unix Makefiles" generator, cmake
configures the Makefiles, but to do the actual build you typically use

make all

and to do the actual install (using the installation prefix you have
configured with CMake) you typically use

make install

So the answer to your question for that latter case is to do that
action with administrator privileges.  For example, on Unix systems you
would log in as the root account first before running "make install".

And similarly for other generators and other platforms that require
administrator privileges to install in the installation location you
have specified with CMake.

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); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); 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