[CMake] DESTDIR behaviour with different variable name

Tomasz Grobelny tomasz at grobelny.oswiecenia.net
Mon Apr 11 12:22:02 EDT 2011


On Mon, 11 Apr 2011 09:01:09 -0700, Tyler <tyler at cryptio.net> wrote:
> On Mon, Apr 11, 2011 at 8:54 AM, Tomasz Grobelny
> <tomasz at grobelny.oswiecenia.net> wrote:
>> Ok, but is there a way to achieve the same effect so that the user can
>> type just "make install" and not know anything about DESTDIR
environment
>> variable (provided he knows about MYDESTDIR)? Maybe it is possible to
put
>> this "DESTDIR=$MYDESTDIR" in the generated Makefiles somehow...
> 
> If I understand your use case right (which I might not as you haven't
> described what you're trying to do, just how you're trying to do it),
> maybe you can just override CMAKE_INSTALL_PREFIX.
> 
> If you go this route, check the archives because of the whole
> _INITIALIZED_TO_DEFAULT aspect of that particular cache variable.
> 
I already tried playing with CMAKE_INSTALL_PREFIX but the problem was that
value of MYDESTDIR was read (and saved to CMAKE_INSTALL_PREFIX) only when
configuring first time. That's why DESTDIR mechanism comes closer to what
I'm trying to achieve. My use case is something like that:
1. User has some default MYDESTDIR to non writable location.
2. User executes "cmake . && make install".
3. The installation fails because user has no rights to $MYDESTDIR.
4. User changes MYDESTDIR to another location (writable this time).
5. User executes "make install" once again and it should succeed.

Of course the user could set MYDESTDIR to correct location before building
but people often forget that. Now the tricky part is that users are already
used to this mechanism (for particular variable name, called MYDESTDIR
here). So taking different environment variable instead of DESTDIR would
allow me to minimize confusion among users. Otherwise I'll just tell them
to set yet another variable (DESTDIR). But I would like to avoid that if at
all possible.
-- 
Regards,
Tomasz Grobelny


More information about the CMake mailing list