if branch for links json data
[dueringa_WikiWalker.git] / src / version.cmake
blob25c83fd8b98f303a58394d8e348cac1dc45c95d9
1 # version.cmake
3 # You need to pass SRC and BIN for this to work
4 # SRC is the source directory which contains version.h.in
5 # BIN is the binary directory where to write version.h to
7 # thanks to https://cmake.org/pipermail/cmake/2010-July/038015.html 
9 find_package(Git QUIET)
11 if(Git_FOUND)
12     execute_process(
13         COMMAND
14         ${GIT_EXECUTABLE} -C ${SRC} describe --always --dirty --tags
15         RESULT_VARIABLE GIT_RETCODE
16         OUTPUT_VARIABLE GIT_OUTPUT_VERSION
17         ERROR_VARIABLE GIT_RAN_ERROR
18         OUTPUT_STRIP_TRAILING_WHITESPACE
19     )
20 else() # Git_FOUND
21     message("Git not found, won't be able to autogenerate version")
22 endif() # Git_FOUND
24 # exit status 0 means successful
25 if(NOT Git_FOUND OR GIT_RETCODE)
26     set(GIT_RAN_SUCCESSFULLY 0)
27 else() # GIT_RETCODE
28     set(GIT_RAN_SUCCESSFULLY 1)
29 endif() #GIT_RETCODE
31 # also, project_...?
32 # overwriting version.h in ok (?), I want the generated one to be preferred
33 # and I guess include_directories in only appended...
34 configure_file(
35     "${SRC}/version.h.in"
36     "${BIN}/version.h"