1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
#!/bin/bash -eu
function print_usage(){
cat<<END
NAME
cmake-fedora-reset - clean and reset cmake environment to default
SYNOPSIS
cmake-fedora-reset [options] <path-to-source>
ARGUMENTS
<path-to-source>
The directory that contains the main CMakeLists.txt
OPTIONS
-h
Show the detailed help
DESCRIPTION
This program wipes out the previous generated files, then run the cmake
again to generate build files.
Note that all Makefiles are also wiped out. So this is unsuidable for the
projects that customize their Makefiles.
ENVIRONMENT
CMAKE_FEDORA_ENABLE_FEDORA_BUILD
Boolean value for enabling fedora support
Default: ON
CMAKE_FEDORA_MANAGE_MESSAGE_LEVEL
Verbose level of cmake-fedora, the higher the value, the more verbose
messages are.
Default: 6
END
}
##== Variables ==
: ${CMAKE_FEDORA_ENABLE_FEDORA_BUILD:=ON}
function parse_options(){
while getopts "h" opt;do
case $opt in
h )
print_usage
exit 0
;;
* )
echo "[ERROR]: Invalid options $opt" > /dev/stderr
echo 'Run "cmake-fedora-reset -h" to get help"' > /dev/stderr
exit 1
;;
esac
done
shift $((OPTIND-1))
if [ $SystemLocales -eq 1 ];then
CmakeOptionArray+=( -D system_locales=1 )
fi
}
if [ $# = 0 ]; then
print_usage
exit 1
fi
SourceDir=$1
cd $SourceDir
find . -path "*/CMakeFiles/*" -print -delete
find . -name "Makefile" -print -delete
rm -fv CMakeCache.txt
rm -fv cmake_install.cmake
rm -fv cmake_uninstall.cmake
rm -fv CPackConfig.cmake
rm -frv _CPack_Packages
rm -fv CPackSourceConfig.cmake
rm -fv CTestTestfile.cmake
rm -frv NO_PACK
rm -frv Testing
cd -
cmake -DCMAKE_FEDORA_ENABLE_FEDORA_BUILD=${CMAKE_FEDORA_ENABLE_FEDORA_BUILD} -DMANAGE_MESSAGE_LEVEL=6 -DCMAKE_BUILD_TYPE=Debug $SourceDir
|