make build work without git

also moved the generated version.c to the build dir to avoid polluting
the source tree and to prevent different build dirs from conflicting
with each other
This commit is contained in:
Andrei "Akari" Alexeyev 2017-09-17 06:30:25 +03:00
parent 8a0e98e0b6
commit 185e217d7a
No known key found for this signature in database
GPG key ID: 048C3D2A5648B785
3 changed files with 20 additions and 6 deletions

1
.gitignore vendored
View file

@ -6,4 +6,3 @@ osxbuild/
# autogenerated
*.out
src/version.c

View file

@ -9,10 +9,25 @@ list(APPEND CMAKE_MODULE_PATH "${BUILDSCRIPTS_DIR}/cmake-modules/git")
include(GetGitRevisionDescription)
git_describe(TAISEI_VERSION)
git_revision(TAISEI_REVISION)
set(TAISEI_VERSION_FALLBACK "1.1")
string(SUBSTRING ${TAISEI_VERSION} 1 32 TAISEI_VERSION) # erase the leading v
set(TAISEI_VERSION_FULL_STR "Taisei v${TAISEI_VERSION} (rev. ${TAISEI_REVISION})")
if(TAISEI_VERSION STREQUAL "GIT-NOTFOUND")
message(WARNING "Git is not installed. Version information will be less accurate.")
set(TAISEI_VERSION "")
elseif(TAISEI_VERSION STREQUAL "HEAD-HASH-NOTFOUND")
message(WARNING "Source tree doesn't seem to be in a git repository. Version information will be less accurate.")
set(TAISEI_VERSION "")
endif()
if(TAISEI_VERSION)
git_revision(TAISEI_REVISION)
string(SUBSTRING ${TAISEI_VERSION} 1 32 TAISEI_VERSION) # erase the leading v
set(TAISEI_VERSION_FULL_STR "Taisei v${TAISEI_VERSION} (rev. ${TAISEI_REVISION})")
else()
set(TAISEI_VERSION "${TAISEI_VERSION_FALLBACK}")
set(TAISEI_REVISION 0)
set(TAISEI_VERSION_FULL_STR "Taisei v${TAISEI_VERSION}")
endif()
if(DEFINED TAISEI_DEBUG)
# XXX: avoid using this unless you absolutely have to

View file

@ -27,7 +27,7 @@ endif()
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/version.c.in"
"${CMAKE_CURRENT_SOURCE_DIR}/version.c"
"${CMAKE_CURRENT_BINARY_DIR}/version.c"
)
set(SRCs
@ -113,7 +113,7 @@ set(SRCs
vfs/vdir.c
vfs/zipfile.c
vfs/zippath.c
version.c
"${CMAKE_CURRENT_BINARY_DIR}/version.c"
)
if(WIN32)