Skip to content

Commit

Permalink
Merge pull request #39 from gerd/master
Browse files Browse the repository at this point in the history
fix empty version number output by using the version option at the release
  • Loading branch information
holgerBerger authored Mar 16, 2020
2 parents 4c04243 + 0c6b599 commit 5f1d692
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
23 changes: 15 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,21 @@ ENDIF (YAML)
get_directory_property(LINKER_VAR LINK_DIRECTORIES)
message(STATUS "LINKER_VAR: ${LINKER_VAR}")

# git commit hash macro
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
add_definitions("-DGIT_COMMIT_HASH=\"${GIT_COMMIT_HASH}\"")
IF (IS_DIRECTORY "${PROJECT_SOURCE_DIR}/.git")
SET (IS_GIT_REPOSITORY ON)
# git commit hash macro
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE WS_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
ELSE ()
SET (IS_GIT_REPOSITORY OFF)
# set to version number of the latest release
SET (WS_VERSION 1.0.0)
ENDIF ()
add_definitions("-DWS_VERSION=\"${WS_VERSION}\"")

SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${workspace_BINARY_DIR}/bin)

Expand Down
2 changes: 1 addition & 1 deletion src/ws_allocate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void commandline(po::variables_map &opt, string &name, int &duration, string &fi
}

if (opt.count("version")) {
cout << "workspace version " << GIT_COMMIT_HASH << endl;
cout << "workspace version " << WS_VERSION << endl;
exit(1);
}

Expand Down
2 changes: 1 addition & 1 deletion src/ws_release.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void commandline(po::variables_map &opt, string &name, int &duration,
}

if (opt.count("version")) {
cout << "workspace version " << GIT_COMMIT_HASH << endl;
cout << "workspace version " << WS_VERSION << endl;
exit(1);
}

Expand Down
2 changes: 1 addition & 1 deletion src/ws_restore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void commandline(po::variables_map &opt, string &name, string &target,
}

if (opt.count("version")) {
cout << "workspace version " << GIT_COMMIT_HASH << endl;
cout << "workspace version " << WS_VERSION << endl;
exit(1);
}

Expand Down

0 comments on commit 5f1d692

Please sign in to comment.