cmake: add distclean target

There's no way to properly/fully clean a cmake build when it's configured
in-tree because they only really want to support out-of-tree builds.  Add
a custom script to handle this instead.
master
Mike Frysinger 2016-07-21 21:40:56 +05:30
parent ae2eea3de3
commit 1e9d800842
3 changed files with 49 additions and 9 deletions

View File

@ -225,6 +225,8 @@ endif (USE_EXT_GD)
add_subdirectory(tests)
add_subdirectory(examples)
add_custom_target(distclean ${GD_SOURCE_DIR}/cmake/distclean.sh)
SET(CPACK_PACKAGE_NAME "libgd")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "libGD, powerful and easy to use graphic library")
SET(CPACK_PACKAGE_VENDOR "http://www.libgd.org")

View File

@ -3,12 +3,4 @@ SUBDIRS = src config tests
EXTRA_DIST = test docs examples windows VMS cmake netware bootstrap.sh CMakeLists.txt CONTRIBUTORS README.md
clean-local:
find . -maxdepth 3 \
'(' \
-name CMakeCache.txt -o \
-name CMakeFiles -o \
-name CTestTestfile.cmake -o \
-name cmake_install.cmake \
')' \
-exec rm -rf {} +
rm -rf Bin CPackConfig.cmake CPackSourceConfig.cmake
$(srcdir)/cmake/distclean.sh --automake

46
cmake/distclean.sh Executable file
View File

@ -0,0 +1,46 @@
#!/bin/sh
# CMake doesn't provide the equiv of "distclean" which makes it impossible to
# properly clean up after it when you build in-tree. This script emulates it.
# It assumes it's run in the dir you want to clean.
usage() {
cat <<-EOF
Usage: $0 [--automake]
Clean all the cmake generated output files.
Options:
--automake Do not clean files autotools also creates
EOF
exit ${1:-0}
}
AUTOMAKE="false"
while [ $# -ne 0 ]; do
case $1 in
-h|--help) usage ;;
--automake) AUTOMAKE="true" ;;
*) usage 1 ;;
esac
shift
done
set -x
find . -maxdepth 3 \
'(' \
-name CMakeCache.txt -o \
-name CMakeFiles -o \
-name CTestTestfile.cmake -o \
-name cmake_install.cmake \
')' \
-exec rm -rf {} +
rm -rf \
Bin Testing \
CPackConfig.cmake CPackSourceConfig.cmake \
DartConfiguration.tcl
if [ "${AUTOMAKE}" = "false" ]; then
find . -maxdepth 3 '!' -wholename './windows/*' -a -name Makefile -exec rm -rf {} +
rm -f src/config.h
fi