MantisBT - CMake
View Issue Details
0006560CMakeCPackpublic2008-03-07 10:372016-06-10 14:30
Eric NOULARD 
Bill Hoffman 
normalminoralways
closedmoved 
 
 
0006560: Exclude build tree when building SOURCE package with CPack
As discussed on the list:
http://www.cmake.org/pipermail/cmake/2008-March/020390.html [^]

It seems reasonable to systematically exclude the
${CMAKE_BINARY_DIR} from the SOURCE packaged files
this is useful when the build tree is a subdirectory
of the source tree.

A simple modification would be to systematically add
${CMAKE_BINARY_DIR}/* to CPACK_SOURCE_IGNORE_FILES.

This could be done by adding it to
Modules/CPack.cmake

No tags attached.
Issue History
2008-03-07 10:37Eric NOULARDNew Issue
2008-03-27 22:02Bill HoffmanStatusnew => assigned
2008-03-27 22:02Bill HoffmanAssigned To => Bill Hoffman
2008-03-28 04:37Eric NOULARDNote Added: 0010945
2008-10-01 14:29Bill HoffmanNote Added: 0013665
2008-10-01 17:19Eric NOULARDNote Added: 0013695
2010-08-21 18:18ClausKleinNote Added: 0021876
2010-08-21 18:18ClausKleinNote Added: 0021877
2010-08-21 18:19ClausKleinNote Deleted: 0021877
2010-08-22 10:36ClausKleinNote Edited: 0021876
2016-06-10 14:27Kitware RobotNote Added: 0041414
2016-06-10 14:27Kitware RobotStatusassigned => resolved
2016-06-10 14:27Kitware RobotResolutionopen => moved
2016-06-10 14:30Kitware RobotStatusresolved => closed

Notes
(0010945)
Eric NOULARD   
2008-03-28 04:37   
As noted by Hendrik
http://www.cmake.org/pipermail/cmake/2008-March/020398.html [^]
one should verify that we are not build in-source because
in this case excluding CMake generated files may not be easy

I think it is (almost) the same problem as "make clean"
because if we were able to get the list of generated files
then excluding them from CPack source package may well be easy.

Assuming CMake may know a list of generated files
from "clean target" and "ADDITIONAL_MAKE_CLEAN_FILES"
CPack source package may package the source tree
excluding those files/dirs unless
specific behavior like the ones proposed there
http://www.cmake.org/pipermail/cmake/2008-March/020406.htm [^]
is specified.
(0013665)
Bill Hoffman   
2008-10-01 14:29   
So, the list had a more extensive request of using source properties to specify the files to cpack:

http://www.cmake.org/pipermail/cmake/2008-March/020412.html [^]
(0013695)
Eric NOULARD   
2008-10-01 17:19   
Yes I know :-)
I was part of the proposal.

The idea is simple we should be able to tell CPack
to ADD or IGNORE file, may be in the same way
autotools gives you "dist/nodist and EXTRA_DIST":
http://www.gnu.org/software/automake/manual/html_node/Dist.html#Dist [^]

This may be done with a new property:

to ADD:
set_source_files_properties(file1 file2 ...
                            PROPERTIES CPACK_PACKAGE_SOURCE true)
to IGNORE
set_source_files_properties(file1 file2 ...
                            PROPERTIES CPACK_PACKAGE_SOURCE false)

this should work even of the file is GENERATED.

We did not discussed the fact that may be we should be able to
use a "directory" property:

set_directory_properties(PROPERTIES CPACK_SOURCE_ADD "list of regex")
set_directory_properties(PROPERTIES CPACK_SOURCE_IGNORE "list of regex")

However I thought,
this may not be enough if we want to ADD files (or directory) which are
outside the source tree, for example [doxygen] generated documentation.

Thus we may want to be able to use regular expression for
"pattern-like" inclusion or exclusion.

Thus the idea of:
SET(CPACK_SOURCE_ADD_FILES "list of regular_expressions")
SET(CPACK_SOURCE_IGNORE_FILES "list of regular_expressions")
Which may be global inclusion of exclusion rules.

May be a "real" CPACK_SOURCE_ADD / IGNORE macro would be better for this
the macro would be

CPACK_SOURCE_ADD(FILES "list of files or regex"
                INTO <relative path in source tree>)

CPACK_SOURCE_ADD(DIRECTORIES "list of directories"
                RENAME_TO <relative path in source tree>)

For example:
CPACK_SOURCE_ADD(DIRECTORIES "${CMAKE_BINARY_DIR}/doxygen/doc/html"
                RENAME_TO "doc/html")

would add the content of the directory ${CMAKE_BINARY_DIR}/doxygen/doc/html
into "doc/html" in the source package, whereas
CPACK_SOURCE_ADD(DIRECTORIES "${CMAKE_BINARY_DIR}/doxygen/doc/html")
would add the "html" directory to the source package.

CPACK_SOURCE_ADD(FILES /path/to/whatever/doc/tutorial.pdf
                INTO "doc")

would add the file "tutorial.pdf" to a "doc" directory in the
source package.

You may imagine a similar
CPACK_SOURCE_IGNORE("regex")

CPACK_SOURCE_IGNORE and CPACK_SOURCE_ADD should be cumulative.
If ignore and add rules are in conflict then we should decide
what to do...


I think the exclusion scheme is easy, but the out-of-build tree
inclusion may not be.

I personnally think properties on [generated] source files and directories
is a good starter but I found
CPACK_SOURCE_ADD/IGNORE macro more powerful.

it is just like if you use

ADD_LIBRARY
or
ADD_EXECUTABLE

but not for building but for packaging.

CPACK_SOURCE_ADD/IGNORE should certainly support the COMPONENT
framework.

Here are the ideas, for this time I won't be able to provide patch
any time soon, work is hitting me again :-)
(0021876)
ClausKlein   
2010-08-21 18:18   
(edited on: 2010-08-22 10:36)
I simple add this line in my CMakeLists.txt before i include cpack:

set (CPACK_SOURCE_IGNORE_FILES "/build/;/CVS/;/\\.svn/;/\\.bzr/;/\\.hg/;/\\.git/;\\.swp$;\\.#;/#" CACHE STRING "CPACK will ignore this files" )

so my build directory (which is my CMAKE_BINARY_DIR) is than excluded.

My be it a quick hack, but it works and is configurable with cmake-gui.

My by to add the build directory to that list automatically is more comfortable, but not really needed.

(0041414)
Kitware Robot   
2016-06-10 14:27   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.