if(PROJECT_VER_GIT)
set(PROJECT_VER ${PROJECT_VER_GIT})
else()
- message(STATUS "Project is not inside a git repository, \
- will not use 'git describe' to determine PROJECT_VER.")
+ message(STATUS "Project is not inside a git repository, or git repository has no commits;"
+ " will not use 'git describe' to determine PROJECT_VER.")
+ set(PROJECT_VER 1)
endif()
endif()
endif()
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
else()
- configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
- file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
- if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
- set(HEAD_HASH "${CMAKE_MATCH_1}")
+ if(EXISTS "@GIT_DIR@/packed-refs")
+ configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
+ file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
+ if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
+ set(HEAD_HASH "${CMAKE_MATCH_1}")
+ endif()
endif()
endif()
else()