Merge pull request #135 from Luminarys/master

Added in build version based on git hash
This commit is contained in:
Drew DeVault 2015-08-26 10:18:06 -04:00
commit c4257055eb
2 changed files with 17 additions and 1 deletions

View File

@ -6,6 +6,18 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin/")
add_definitions("-Wall -Wextra -Wno-unused-parameter")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMake)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
execute_process(
COMMAND git describe --always
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
SET(GIT_VERSION_FLAG "-DSWAY_GIT_VERSION=\"${GIT_COMMIT_HASH}\"")
add_definitions("${GIT_VERSION_FLAG}")
find_package(XKBCommon REQUIRED)
find_package(WLC REQUIRED)
find_package(A2X REQUIRED)

View File

@ -78,7 +78,11 @@ int main(int argc, char **argv) {
debug = 1;
break;
case 'v': // version
// todo
#ifdef SWAY_GIT_VERSION
fprintf(stdout, "sway build %s\n", SWAY_GIT_VERSION);
#else
fprintf(stdout, "version not detected\n");
#endif
exit(0);
break;
case 'V': // verbose