[CMake] Finally got CPACK_SOURCE_IGNORE_FILES to work

Alan W. Irwin irwin at beluga.phys.uvic.ca
Fri Jul 7 20:41:06 EDT 2006


I am following the recommendations at
http://public.kitware.com/pipermail/cmake/2006-May/009060.html and
http://public.kitware.com/pipermail/cmake/2006-July/010002.html to create the
CMake equivalent of the autotools "make dist" command, but for a long time,
I could not get the CPACK_SOURCE_IGNORE_FILES part of it to work at all.

It turned out, the problem (in the cpack version that comes with version
2.4.2 of cmake, at least) was the first (bad) CPACK_SOURCE_IGNORE_FILES
value I tried was set in concrete for all time even if I re-ran the cmake
command. The only way I could get a new version of CPACK_SOURCE_IGNORE_FILES
to be used was to completely remove the _CPack_Packages subdirectory in the
build tree and then follow with the cmake command then the :"make
package_source" command.

The first of these steps (rm -rf _CPack_Package) is non-obvious and smells
to me like a work-around for some bug, and I hope that bug gets fixed.

Also, I don't think the cmake command should be required either.  For example,
"make all" does implicitly re-run at least part of the cmake command if
the top-level CMakeLists.txt (and probably any other CMakeLists.txt as well)
has been touched, but
"make package_source" does not account for CMakeLists.txt changes at all, and
you have to run cmake by hand first to pick those changes up.

I hope this bug is fixed as well.

Finally, I have a number of questions about the required regex expressions
to ignore directories and files.

Just for reference here is the cpack-relevant part of my top-level
CMakeLists.txt file:

#
# Packing stuff
#
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The Scientific Plotting Library
PLplot")
set(CPACK_PACKAGE_VENDOR "PLplot development team")
set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README)
set(CPACK_PACKAGE_VERSION_MAJOR 5)
set(CPACK_PACKAGE_VERSION_MINOR 6)
set(CPACK_PACKAGE_VERSION_PATCH 1)
set(CPACK_GENERATOR TGZ)
set(CPACK_SOURCE_GENERATOR TGZ)
set(CPACK_SOURCE_IGNORE_FILES
"/CVS/"
"Makefile\\\\.in$"
"/bindings/"
"/build_dir/"
"/cf/"
"/data/"
"/debian/"
"/doc/"
"/drivers/"
"/examples/"
"/fonts/"
"/include/"
"/libltdl/"
"/old/"
"/pkgcfg/"
"/rpm/"
"/scripts/"
"/src/"
"/sys/"
"/test/"
"/utils/"
)
message("CPACK_SOURCE_IGNORE_FILES = ${CPACK_SOURCE_IGNORE_FILES}")
include(CPack)

Note, I am only part way through an autotool to cmake transition so that
is why I am excluding so many directories.

My interpretation of the above working regular expressions is they match
anywhere in the path+filename. 
Thus, the "/xxxx/" construct ignores all files in any
xxxx directory in the full path and "Makefile\\\\.in$" ignores all files
named Makefile.in. However, Makefile.in.in will not be ignored because of
the "$" marking the end of the path+filename.

Could some CPack expert here confirm this interpretation is correct?  Also,
is that relative path or absolute path?  If the latter, there could be an
accident waiting to happen from the above if the source directory is say a
subdirectory of the test directory.  Then everything will get excluded!

Also, I don't completely understand why the \\\\ is required to escape the
"." in Makefile.in.  Could somebody comment on this please?

I do notice that the cmake message output from the above is

CPACK_SOURCE_IGNORE_FILES =
/CVS/;Makefile\\.in$;/bindings/;/build_dir/;/cf/;/data/;/debian/;/doc/;/drivers/;/examples/;/fonts/;/include/;/libltdl/;/old/;/pkgcfg/;/rpm/;/scripts/;/src/;/sys/;/test/;/utils/

which halves the number of "\" escapes for some reason, but there must be
some additional processing going on that halves them again so that the final
regex for that component of the vector is just Makefile\.in$.

I presume if I wanted a regex for windows directories the above would have
to read
"\\\\\\\\CVS\\\\\\\\"

etc., to boil down to a regex of

\\CVS\\

to create a regex to ignore all files in the directory named \CVS\ in
path+filename.

Is that interpretation correct?

I just hope to God you don't have to go up to 16 repeated "\" characters at
some point... :-)

Alan
__________________________ 
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the Yorick front-end to PLplot (yplot.sf.net); the
Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list