[CMake] How to detect whether CMake scripts are executing under / within CPack environment?

David Cole david.cole at kitware.com
Mon Dec 20 08:17:13 EST 2010


On Mon, Dec 20, 2010 at 7:51 AM, Mike McQuaid <mike at mikemcquaid.com> wrote:

> On 20 December 2010 12:34, David Cole <david.cole at kitware.com> wrote:
> > On Sun, Dec 19, 2010 at 3:50 PM, Mike McQuaid <mike at mikemcquaid.com>
> wrote:
> > When you find yourself in the "must escape too much" situation in an
> > INSTALL(CODE scenario.... you should switch to writing out a script that
> you
> > then include with an INSTALL(SCRIPT command. They are absolutely
> equivalent,
> > except with CODE you specify the code inline when it does not need
> > significant escaping, or if it's just a line or two. If it does need lots
> of
> > escaping or is longer than 1-3 lines, I would say it should be the SCRIPT
> > form anyway.
> >
> > And honestly, I think that Eric's suggestion of using a
> > CPACK_PROJECT_CONFIG_FILE is the way to go here. If you have one, CPack
> will
> > include it before running your install rules. You can use any sentinel
> you
> > like within that file: it will only ever be included by CPack, so if
> you're
> > in its context, then you know you're being run by CPack.
>
> That's a good suggestion and could do with being better documented
> (like most of CPack)!
>
> I still think the nicest solution would be to provide INSTALL(...
> PACKAGE) or something similar so you can do this all easily and
> visibly from your existing CMakeLists.txt files. That's my main
> reservation with using too many external script files, it's not
> obvious to someone reading the CMakeLists file what is actually
> happening.
>
> I'm happy to write a patch for this. Would this be accepted? Is this
> the wrong approach? If you guide me to creating an acceptable one, I'd
> be happy to write this.
>
> I created a bug about this so this is probably a good point of discussion:
> http://public.kitware.com/Bug/view.php?id=11142
>
> --
> Mike McQuaid
> http://mikemcquaid.com
>


I don't think an INSTALL(... PACKAGE construct is necessary. And, in fact, I
think it might be harmful. (For one thing, INSTALL(PACKAGE sounds like
you're installing "a package", not like you're installing "something you've
built but only as part of an installer package.")

For the simple case, the binary package is nothing more than a copy of the
"make install" tree. Adding stuff to the tree, but only for package
installers, is unusual. But it is possible with existing mechanisms. (I
still wouldn't recommend doing it.)

Why do you have differences in one install tree vs. another?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20101220/6117c71e/attachment.htm>


More information about the CMake mailing list