[CMake] Configuring CPack to Build Packages My Way

Stewart, Robert Robert.Stewart at sig.com
Fri Sep 13 17:10:44 EDT 2013


Bill Hoffman wrote:
> On 9/10/2013 1:42 PM, Stewart, Robert wrote:
> >>Likewise, I want an NSIS installer or RPM that will create
> >>that directory structure in either a default location from
> >>my CMakeLists.txt or in a directory selected by the user
> >>during installation (via the GUI for NSIS or --prefix for
> >>rpm).
> >>
> >>What must I do to effect this?
> >>
> The basic idea of CPack is that it uses the install tree and
> packages it.

As I noted, in my original message, I got INSTALL() to build the structure I was after, under the top of my build tree.  The files are laid out in the directory structure I want, just not in the final location, which is what I expect of the installer.

> I am not sure I understand exactly what you are asking.

I thought I was being very clear, but obviously not.

> The make install step should create your directory structure.

It does, but within my build tree, not in the final installation location, which isn't even known, beyond a default location, until installation.

> This might be a variable you want to look at
> CPACK_SET_DESTDIR.

That won't work, because it means running make DESTDIR=something install rather than running an installer, unless I've misunderstood the documentation in http://www.cmake.org/cmake/help/v2.8.11/cpack.html#variable:CPACK_SET_DESTDIR.

I'll try again.  In my build tree, I arranged for the INSTALL() commands to create and populate some directories, noted by "installed" below:

/my/build/directory/
   builds/
   installed/
   source/
   CMakeLists.txt

That is, installed will have files and directories within it, and each subdirectory will have files and directories within it.  The contents of installed aren't important, just that I can collect them in the desired arrangement and then put them into a package, created by CPack, so they can be installed where the user chooses.  I'd also like a default location for installers (not for zip files or tarballs, of course).

Suppose a user is using a tarball from CPack:

> cd foo
> ls foo
> tar zxf my_package.tar.gz
> ls
installed

If the user runs cd installed, everything that CMake would have put into /my/build/directory/installed would appear.

I don't want any other directories to be created when extracting the tarball.  Presently, I get extra directories within which installed appears.

Now suppose a user is using the NSIS installer.  They run the installer, which offers the default installation directory.  They choose a different directory.  When finished, the installer will have put installed, and everything within it, in the selected directory.

Is that clearer?  If so, what do I need to do to configure CPack?

_____
Rob Stewart
Software Engineer
Dev Tools & Components
Susquehanna International Group, LLP




________________________________

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.


More information about the CMake mailing list