authorgravatar for jay@jayschwa.netJay Petacat <jay@jayschwa.net> 2018-06-29 22:22:04-04:00
committergravatar for jay@jayschwa.netJay Petacat <jay@jayschwa.net> 2018-06-29 22:22:04-04:00
log25bbb1a8ff7074a56b4da98de24a549e223d0009
tree4e7f7190753ab9b8f4d15d9d5242fd626600446f
parenta3ab4325fd05807c4a5b70aed3b515ce7ccd753f

Fix version detection for out-of-source builds

Git was called in the build directory and not the source directory. This works fine when the build directory resides within the source repository, but doesn't work for out-of-source builds. Example: ``` ~/zigbuild$ cmake ../zig fatal: not a git repository (or any of the parent directories): .git Configuring zig version 0.2.0+ ``` Use Git's `-C <path>` flag to always point to the source directory so that it doesn't matter where the build directory lives.

1 files changed, 1 insertions(+), 1 deletions(-)

CMakeLists.txt+1-1
...@@ -22,7 +22,7 @@ set(ZIG_VERSION "${ZIG_VERSION_MAJOR}.${ZIG_VERSION_MINOR}.${ZIG_VERSION_PATCH}"...@@ -22,7 +22,7 @@ set(ZIG_VERSION "${ZIG_VERSION_MAJOR}.${ZIG_VERSION_MINOR}.${ZIG_VERSION_PATCH}"
22find_program(GIT_EXE NAMES git)22find_program(GIT_EXE NAMES git)
23if(GIT_EXE)23if(GIT_EXE)
24 execute_process(24 execute_process(
25 COMMAND ${GIT_EXE} name-rev HEAD --tags --name-only --no-undefined --always25 COMMAND ${GIT_EXE} -C ${CMAKE_SOURCE_DIR} name-rev HEAD --tags --name-only --no-undefined --always
26 OUTPUT_VARIABLE ZIG_GIT_REV26 OUTPUT_VARIABLE ZIG_GIT_REV
27 OUTPUT_STRIP_TRAILING_WHITESPACE)27 OUTPUT_STRIP_TRAILING_WHITESPACE)
28 if(ZIG_GIT_REV MATCHES "\\^0$")28 if(ZIG_GIT_REV MATCHES "\\^0$")