[CMake] Configuring CPack to Build Packages My Way

Stewart, Robert Robert.Stewart at sig.com
Mon Sep 23 09:00:32 EDT 2013


Eric Noulard wrote:
> 2013/9/13 Stewart, Robert <Robert.Stewart at sig.com>:
> > Bill Hoffman wrote:
>
> [...]
>
> > 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).
>
> That's pretty clear, however giving a minimal set of example
> files including CMakeLists.txt would ease understanding.

I will try to create a reduced set.

> I have several question:
>
> Q1) Do all your install(... DESTINATION relpath/to/install)
> have relative path destination or not?

All relative.

> Q2) What is the exact set of CPack generator you need?
> all the archive generators (ZIP, TGZ, TBZ2, etc...) may be
> handled the same way but "installers" (DEB, RPM,NSIS, ...) do
> have specific config var.

I'm trying to use TGZ and RPM on Linux, and ZIP and NSIS on
Windows.

> Q3) Do you use COMPONENT packaging or not?

No.

> > Suppose a user is using a tarball from CPack:
> >
> >> $cd foo
> >> $ls
> >> $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.
>
> Could you give us a complete (minimal) example of what you
> get and what you would expect?

The tar.gz contains files with pathnames like the following (I substituted the variables that affect the different parts of the pathname):

${CPACK_PACKAGE_FILE_NAME}/${CMAKE_INSTALL_PREFIX}/lib/debug/libsomething.a

What I want is the following:

installed/other/directories/lib/debug/libsomething.a

(I set CMAKE_INSTALL_PREFIX to ${CMAKE_SOURCE_DIR}/installed/other/directories so the desired structure appears within my build tree.)

Extracting into a directory will then recreate "installed" and its subdirectories right in that directory instead of creating all directories from CMAKE_SOURCE_DIR and then "installed" and its subdirectories.

> With the "archive" generator like TGZ you may play with:
>
> CPACK_INCLUDE_TOPLEVEL_DIRECTORY

Setting that to FALSE removed ${CPACK_PACKAGE_FILE_NAME} from
the front.  That's a good start.  I still need to remove more,
because CMAKE_INSTALL_PREFIX contains things like my home
directory in it.  Effectively, I want the content relative to
CMAKE_SOURCE_DIR.

> CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY
> in order to put/remove the toplevel directory in the archive.

I'm not doing component-based installs, so that doesn't apply.

> > 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.
>
> cpack --help-variable CPACK_PACKAGE_INSTALL_DIRECTORY
> cpack --help-variable CPACK_PACKAGING_INSTALL_PREFIX
> cpack --help-variable CPACK_NSIS_INSTALL_ROOT

I'm already using those variables.

> > Is that clearer?  If so, what do I need to do to configure
> > CPack?
>
> If you have more question please give us a
> non-working complete but minimal example to play with.

I'll have to unroll some of the logic now in functions, but I'll
work on that.

Thanks for your help so far.

_____
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