[CMake] avoiding complete rebuild when the user changes

David Cole david.cole at kitware.com
Wed Apr 18 07:19:26 EDT 2012


On Wed, Apr 18, 2012 at 7:00 AM, Eric Noulard <eric.noulard at gmail.com>wrote:

> 2012/4/18 pellegrini <pellegrini at ill.fr>:
> > Dear CMakers,
> >
> > I introduced recently a colleague of mine to the wonders of cmake. He
> has a
> > problem that neither he or me could solve.
> >
> > When he cmakes and builds his project as root and builds subsenquently
>  its
> > project as himself the whole project is rebuilt even if
> > nothing has been changed.
>
> Building as root is evil and cmake try it hard to discourage the practice
> by rebuilding over & over :-]
>
> > I may be wrong but I think this is not an actual problem with cmake but
> > rather a general property of make that do not consider only the
> > timestamp but also the owner of a file and if one of these changes, the
> file
> > is marked as having to be rebuild.
>
> A nice idea suggested by Bill sometimes ago was to.
>
>
> 0) Create a pristine  git repo
>
> 1) Add the source and an empty build dir to the repo
>    commit.
>
> 1) Build out of source in the build dir.
>    add+commit all thing in the build dir.
>
> 2) Try "make"
>    then git diff or git status in order to see what have changed.
>
> >
> > What do you think ? Would you see one way to escape from this feature ?
>
> avoid building as root?
>
> Why would he need to build as root in the first place?
> Usually only the ultimate install step may need root privilege, and for
> that one
> $ sudo make install
> may be simple enough?
>
> --
> Erk
> Le gouvernement représentatif n'est pas la démocratie --
> http://www.le-message.org
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>


It may not be prohibited, but to me, it makes absolutely no sense to try to
do a build as one user, and then do an incremental re-build as another
user, regardless of whether one of those users is 'root' or not.

Think about it: doing a build means writing a ton of files, as the user who
is doing the build. In order to switch to another user, and still have
everything work, you'd need to make sure that all of those files written in
the build tree by the first user are over-writeable (if necessary) by the
second user. It would be a privilege analysis nightmare unless you
guarantee that both users and all build tools involved write the files with
a shared group where both users have equivalent group permissions.

Since that's not true in general, or by default, .... it's a good idea to
avoid switching users in a build tree and expecting it to work.

You *could* get it to work, but I think you'd have to be very careful to
get it to work well.


Cheers,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120418/ca091e62/attachment.htm>


More information about the CMake mailing list