diff options
-rw-r--r-- | CMakeLists.txt | 14 | ||||
-rw-r--r-- | sway/main.c | 6 |
2 files changed, 19 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1365a9ae..fe424728 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,20 @@ 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 log -1 --format=%h + OUTPUT_VARIABLE GIT_COMMIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE + ) +else(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git") + set(GIT_COMMIT_HASH "Not Found") +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) diff --git a/sway/main.c b/sway/main.c index afbdab33..0880cb8c 100644 --- a/sway/main.c +++ b/sway/main.c @@ -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 |