summaryrefslogtreecommitdiffstats
path: root/cmake/GitFunctions.cmake
diff options
context:
space:
mode:
authorJan Dalheimer <jan@dalheimer.de>2014-04-06 18:02:28 +0200
committerJan Dalheimer <jan@dalheimer.de>2014-04-06 18:02:28 +0200
commit6ef38d0873bc424ff72d0eb5363924b00b0cadc2 (patch)
treed9d605817acb3eec481a221e1e0d2d3956ece894 /cmake/GitFunctions.cmake
parent482ad250a4454d993a98488edfe01d7f9dc35de7 (diff)
downloadMultiMC-6ef38d0873bc424ff72d0eb5363924b00b0cadc2.tar
MultiMC-6ef38d0873bc424ff72d0eb5363924b00b0cadc2.tar.gz
MultiMC-6ef38d0873bc424ff72d0eb5363924b00b0cadc2.tar.lz
MultiMC-6ef38d0873bc424ff72d0eb5363924b00b0cadc2.tar.xz
MultiMC-6ef38d0873bc424ff72d0eb5363924b00b0cadc2.zip
Coverity build and upload target. Also GitFunctions.
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()