[CMake] Why CPack does not _ALWAYS_ use DESTDIR?

Bill Hoffman bill.hoffman at kitware.com
Tue May 13 09:41:06 EDT 2008


Eric Noulard wrote:
> 2008/5/13, David Cole <david.cole at kitware.com>:
>> On Windows, where you have DESTDIR=C:/MyDir and an "absolute" install path
>> of "C:/Program Files/Whatever"....
>>
>> "C:/MyDir/C:/Program Files/Whatever" is probably going to make somebody a
>> bit grumpy...
> 
> Ok right, I see, DESTDIR and ABSOLUTE path should be mergeable
> which is the case on Unix and not on Windows, because of those nasty
> letter drive thing.
> 
> I may propose to default use of DESTDIR
> 
> _For CPack generator_
> AND
> _For UNIX platform only_
> 
> but keep reading it may be worth a look on WIN32 too.
> 
> Currently people cannot use _ANY_ CPack generator on Unix platform
> if their project use absolute path install unless they
> SET(CPACK_SET_DESTDIR "ON") in the CMakeList.txt
> 
> I think it wasn't a user-friendly behavior.
> 
>> Big picture perspective needed. Do not hastily change default behaviors.
> 
> Be sure I'm really concerned with not changing default behavior
> and thus not to break "backward compatibility".
> 
> However I find the default behavior to be more than buggy.
> 
> In fact if ever you are root when doing "make package" on Unix
> (which is NOT a good idea I admit)
> not only you are building a package but your are
> installing the absolute installed file for good :=)
> 
> As you should have guessed I'm not a Windows man but in order
> to be sure I've just tested the preceding scheme on a Windows box
> nearby and guess what, when you build NSIS or ZIP installer using
> CPack (2.6.0) not only the absolute path installed file are not included in
> the NSIS installer/zip but the file are installed for good when you are building
> the installer.
> 
> You may try the attached project on a windows box, in order to make sure
> I did not do something wrong.
> 
> In fact I think (or I hope) no-one is using absolute path install
> on windows precisely because the "letter drive" may make your installer
> just buggy.
> 
> Using absolute path install on unix is not a good idea either but
> you sometimes have to use it to put you file in /etc/ .
> 
> Be sure I'm not willing to break some backward compatibilty but
> to avoid strange behavior when building installer.
> 
> 
There is one more issue.  CPack is supposed to work with any build 
system not just CMake.   It might just be a set of hand crafted 
makefiles, and it may or may not support DESTDIR.   I suppose this could 
be taken care of by only making DESTDIR the default if it is a CMake 
based project.   However, people can inject code into the install rules 
for a cmake project that may not honor DESTDIR.  You can write any cmake 
script you want into the install files.   I am almost certain someone's 
code will break if we change this.  However, I can not point to it, and 
I am guessing the projects depending on it won't even know that they are 
depending on it, until we break it for them.  Adding an extra set is not 
such a big deal.

-Bill



More information about the CMake mailing list