summaryrefslogtreecommitdiffstats
path: root/cmake/GitFunctions.cmake
diff options
context:
space:
mode:
authorJan Dalheimer <jan@dalheimer.de>2014-04-07 17:44:52 +0200
committerJan Dalheimer <jan@dalheimer.de>2014-04-07 17:44:52 +0200
commit3cd2b898e5bbf00d22647b2b114502c0a8076495 (patch)
treecff8e7bcd5c210c07011ffafaede79dc00b69082 /cmake/GitFunctions.cmake
parentdd7b6642a3b171734126b6b4a14236cfe6406fcf (diff)
parent17d4947b30f00a347d7fb8648040271e4b65f966 (diff)
downloadMultiMC-3cd2b898e5bbf00d22647b2b114502c0a8076495.tar
MultiMC-3cd2b898e5bbf00d22647b2b114502c0a8076495.tar.gz
MultiMC-3cd2b898e5bbf00d22647b2b114502c0a8076495.tar.lz
MultiMC-3cd2b898e5bbf00d22647b2b114502c0a8076495.tar.xz
MultiMC-3cd2b898e5bbf00d22647b2b114502c0a8076495.zip
Merge remote-tracking branch 'origin/develop' into feature_cmake_style
Conflicts: CMakeLists.txt
Diffstat (limited to 'cmake/GitFunctions.cmake')
-rw-r--r--cmake/GitFunctions.cmake37
1 files changed, 37 insertions, 0 deletions
diff --git a/cmake/GitFunctions.cmake b/cmake/GitFunctions.cmake
new file mode 100644
index 00000000..e0868725
--- /dev/null
+++ b/cmake/GitFunctions.cmake
@@ -0,0 +1,37 @@
+if(__GITFUNCTIONS_CMAKE__)
+ return()
+endif()
+set(__GITFUNCTIONS_CMAKE__ TRUE)
+
+find_package(Git QUIET)
+
+include(CMakeParseArguments)
+
+if(GIT_FOUND)
+ function(git_run)
+ set(oneValueArgs OUTPUT_VAR DEFAULT)
+ set(multiValueArgs COMMAND)
+ cmake_parse_arguments(GIT_RUN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ execute_process(COMMAND ${GIT_EXECUTABLE} ${GIT_RUN_COMMAND}
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ RESULT_VARIABLE GIT_RESULTVAR
+ OUTPUT_VARIABLE GIT_OUTVAR
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+
+ if(GIT_RESULTVAR EQUAL 0)
+ set(${GIT_RUN_OUTPUT_VAR} "${GIT_OUTVAR}" PARENT_SCOPE)
+ else()
+ set(${GIT_RUN_OUTPUT_VAR} ${GIT_RUN_DEFAULT})
+ message(STATUS "Failed to run Git: ${GIT_OUTVAR}")
+ endif()
+ endfunction()
+else()
+ function(git_run)
+ set(oneValueArgs OUTPUT_VAR DEFAULT)
+ set(multiValueArgs COMMAND)
+ cmake_parse_arguments(GIT_RUN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+ set(${GIT_RUN_OUTPUT_VAR} ${GIT_RUN_DEFAULT})
+ endfunction(git_run)
+endif()