diff options
author | Sander Vrijders <[email protected]> | 2016-02-11 15:50:16 +0100 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2016-02-11 15:50:16 +0100 |
commit | f78310f4886bad7029cc039971159ab7a97e00af (patch) | |
tree | c1609e42197af649ab52888a0c50186218f7a3d8 /cmake/GitVersionGen.cmake | |
parent | 5f3ee106ad32e07e8d00513212eb0968a84b59a1 (diff) | |
download | ouroboros-f78310f4886bad7029cc039971159ab7a97e00af.tar.gz ouroboros-f78310f4886bad7029cc039971159ab7a97e00af.zip |
Initial build infrastructure
Contains the initial build infrastructure. Cmake was chosen for
portability reasons.
Diffstat (limited to 'cmake/GitVersionGen.cmake')
-rw-r--r-- | cmake/GitVersionGen.cmake | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/cmake/GitVersionGen.cmake b/cmake/GitVersionGen.cmake new file mode 100644 index 00000000..53ac166d --- /dev/null +++ b/cmake/GitVersionGen.cmake @@ -0,0 +1,43 @@ +macro(GIT_VERSION_GEN) + +include(FindGit) +if(NOT GIT_FOUND) + message(FATAL_ERROR "This is not a git repository") +endif() + +find_program(SORT "sort") +mark_as_advanced(SORT) +if (${SORT} STREQUAL "") + message(FATAL_ERROR "Cannot find the sort executable") +endif() + +find_program(TAIL "tail") +mark_as_advanced(TAIL) +if (${TAIL} STREQUAL "") + message(FATAL_ERROR "Cannot find the tail executable") +endif() + +execute_process( + COMMAND ${GIT_EXECUTABLE} tag -l -n0 + COMMAND ${SORT} -V + COMMAND ${TAIL} -n 1 + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE _git_tag + RESULT_VARIABLE _git_result + OUTPUT_STRIP_TRAILING_WHITESPACE) +if(NOT ${_git_result} EQUAL 0) + message(FATAL_ERROR "Cannot fetch repository tag") +endif() +message(STATUS "Repository tag is: ${_git_tag}") + +string(REGEX REPLACE + "[^0-9]*([0-9]+)\\.[0-9]+.*" "\\1" + _version_major "${_git_tag}") +string(REGEX REPLACE + "[^0-9]*[0-9]+\\.([0-9]+).*" "\\1" + _version_minor "${_git_tag}") + +set(PACKAGE_VERSION_MAJOR "${_version_major}") +set(PACKAGE_VERSION_MINOR "${_version_minor}") + +endmacro(GIT_VERSION_GEN) |