Ensure CMakeLists.txt and include versions match. This causes the release script to abort if the Ceres version in the headers, command line, and CMake files don't match. Change-Id: I38c4f1b4ebf3499d2ba4f698fa3f4936538c3de7
diff --git a/scripts/make_release b/scripts/make_release index cdded82..404aa75 100755 --- a/scripts/make_release +++ b/scripts/make_release
@@ -47,11 +47,35 @@ ABI_VERSION=$(grep 'SET(CERES_ABI_VERSION' CMakeLists.txt | \ sed -e 's/SET(CERES_ABI_VERSION //' | \ sed -e 's/)//') +VERSION_IN_HEADER=$(grep '#define CERES_VERSION' include/ceres/ceres.h | \ + sed -e 's/#define CERES_VERSION //') +ABI_VERSION_IN_HEADER=$(grep '#define CERES_ABI_VERSION' \ + include/ceres/ceres.h | \ + sed -e 's/#define CERES_ABI_VERSION //') GIT_COMMIT=$(git log -1 HEAD |grep commit) if [[ $1 != $VERSION ]] ; then - echo "ERROR: Version $1 does not match CERES_VERSION in CMakeLists.txt." - echo " which is $VERSION. You may not be in the toplevel source dir." + echo "ERROR: Version from the command line $1 does not match CERES_VERSION" + echo " in CMakeLists.txt, which is $VERSION. You may not be in the " + echo " toplevel source dir." + exit 1 +fi + +if [[ $VERSION_IN_HEADER != $VERSION ]] ; then + echo "ERROR: CERES_VERSION version from include/ceres/ceres.h, which is" + echo " $VERSION_IN_HEADER, does not match the ABI version" + echo " from the toplevel CMakeLists.txt, which is $ABI_VERSION." + echo " You may not be in the toplevel source directory, or the" + echo " versions are out of sync." + exit 1 +fi + +if [[ $ABI_VERSION_IN_HEADER != $ABI_VERSION ]] ; then + echo "ERROR: CERES_ABI_VERSION from include/ceres/ceres.h, which is" + echo " $ABI_VERSION_IN_HEADER, does not match the ABI version" + echo " from the toplevel CMakeLists.txt, which is $ABI_VERSION." + echo " You may not be in the toplevel source directory, or the" + echo " versions are out of sync." exit 1 fi