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

Mike McQuaid mike at mikemcquaid.com
Mon Dec 20 08:35:31 EST 2010


On 20 December 2010 13:17, David Cole <david.cole at kitware.com> wrote:
> 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.")

Ok. I'm not saying that's the best keyword or anything like that but
just something that handles the escaping for you but lets you specify
files within CMake.

> 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?

Anyone who uses GetPrerequisites or BundleUtilities will do. I've had
this problem now on 5+ projects between 2+ employers. You will want to
install the libraries for your application to a package you can
distribute but not to people on e.g. Linux who just want to type "make
install" and had it use their system libraries.

Another case is adding things like the README which should be in the
root of the zip/dmg package but in  $PREFIX/share/doc for
installations. Also, you might want to fix up RPATHS for installed
versions but not local ones. You'll also need to supply a qt.conf file
for Qt installations at package-time but not install-time.

Any open-source project where you want to provide binary package
support using CMake but allow people to create normal Linux/Mac
packages themselves (e.g. Debian) will require a different
install/package tree. In my experience, literally every time I've used
CPack for a project or recommended it to others they've required this
functionality. That's not to say that it is used in every single
project using CPack out there but it seems to be necessary to a lot of
users.

-- 
Mike McQuaid
http://mikemcquaid.com


More information about the CMake mailing list