Skip to content
Snippets Groups Projects
Commit 8cf4731b authored by Axel Naumann's avatar Axel Naumann
Browse files

[CMake] Use CMake to generate etc/gitinfo.txt, RGitCommit.h.tmp.

parent 3a5d257d
No related branches found
No related tags found
No related merge requests found
...@@ -71,21 +71,38 @@ add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/include/RGitCommit.h ...@@ -71,21 +71,38 @@ add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/include/RGitCommit.h
COMMENT "" COMMENT ""
DEPENDS ${CMAKE_BINARY_DIR}/RGitCommit.h.tmp DEPENDS ${CMAKE_BINARY_DIR}/RGitCommit.h.tmp
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
if(WIN32)
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/RGitCommit.h.tmp execute_process(COMMAND ${GIT_EXECUTABLE} --git-dir=${CMAKE_SOURCE_DIR}/.git describe --all
COMMAND ${CMAKE_SOURCE_DIR}/build/win/gitinfo.bat ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE GIT_DESCRIBE_ALL
COMMAND ${CMAKE_SOURCE_DIR}/build/win/githeader.bat RGitCommit.h.tmp RESULT_VARIABLE GIT_DESCRIBE_ERRCODE
COMMENT "Recording the git revision now" ERROR_QUIET
DEPENDS ${dep_objects} move_artifacts OUTPUT_STRIP_TRAILING_WHITESPACE)
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) if(NOT GIT_DESCRIBE_ERRCODE)
else() execute_process(COMMAND ${GIT_EXECUTABLE} --git-dir=${CMAKE_SOURCE_DIR}/.git describe --always
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/RGitCommit.h.tmp OUTPUT_VARIABLE GIT_DESCRIBE_ALWAYS
COMMAND ${CMAKE_SOURCE_DIR}/build/unix/gitinfo.sh ${CMAKE_SOURCE_DIR} ERROR_QUIET
COMMAND ${CMAKE_SOURCE_DIR}/build/unix/githeader.sh RGitCommit.h.tmp OUTPUT_STRIP_TRAILING_WHITESPACE)
COMMENT "Recording the git revision now" string(TIMESTAMP GIT_TIMESTAMP "%b %d %Y, %H:%M:%S" UTC)
DEPENDS ${dep_objects} move_artifacts
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
endif() endif()
message("Recording the git revision now")
file(WRITE ${CMAKE_BINARY_DIR}/etc/gitinfo.txt
"${GIT_DESCRIBE_ALL}
${GIT_DESCRIBE_ALWAYS}
${GIT_TIMESTAMP}
"
)
file(WRITE ${CMAKE_BINARY_DIR}/RGitCommit.h.tmp
"#ifndef ROOT_RGITCOMMIT_H
#define ROOT_RGITCOMMIT_H
#define ROOT_GIT_BRANCH \"${GIT_DESCRIBE_ALL}\"
#define ROOT_GIT_COMMIT \"${GIT_DESCRIBE_ALWAYS}\"
#endif
"
)
add_custom_target(gitcommit ALL DEPENDS ${CMAKE_BINARY_DIR}/RGitCommit.h.tmp) add_custom_target(gitcommit ALL DEPENDS ${CMAKE_BINARY_DIR}/RGitCommit.h.tmp)
set_source_files_properties(${CMAKE_BINARY_DIR}/RGitCommit.h.tmp PROPERTIES GENERATED TRUE) set_source_files_properties(${CMAKE_BINARY_DIR}/RGitCommit.h.tmp PROPERTIES GENERATED TRUE)
add_dependencies(gitcommit ${dep_targets}) add_dependencies(gitcommit ${dep_targets})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment