Correctly handle possible missing GIT_SHA1. (#5401)

Currently, if get_git_head_revision() doesn't define GIT_SHA1 (which it
doesn't in some cases) it's possible to end up with the following error:

    CMake Error at CMakeLists.txt:69 (if):
      if given arguments:

        "STREQUAL" "GITDIR-NOTFOUND"

      Unknown arguments specified

Fix this by making sure both left and right hand arguments to STREQUAL
are always strings, even if GIT_SHA1 is undefined.

Signed-off-by: Kyle Fazzari <kyle@canonical.com>
This commit is contained in:
Kyle Fazzari 2016-12-21 05:14:26 -08:00 committed by Markus Goetz
parent 030e3a5d4a
commit d1237cdda3

View file

@ -69,7 +69,7 @@ get_git_head_revision(GIT_REFSPEC GIT_SHA1)
# if we cannot get it from git, directly try .tag (packages) # if we cannot get it from git, directly try .tag (packages)
# this will work if the tar balls have been properly created # this will work if the tar balls have been properly created
# via git-archive. # via git-archive.
if (${GIT_SHA1} STREQUAL "GITDIR-NOTFOUND") if ("${GIT_SHA1}" STREQUAL "GITDIR-NOTFOUND")
file(READ ${CMAKE_SOURCE_DIR}/.tag sha1_candidate) file(READ ${CMAKE_SOURCE_DIR}/.tag sha1_candidate)
string(REPLACE "\n" "" sha1_candidate ${sha1_candidate}) string(REPLACE "\n" "" sha1_candidate ${sha1_candidate})
if (NOT ${sha1_candidate} STREQUAL "$Format:%H$") if (NOT ${sha1_candidate} STREQUAL "$Format:%H$")