2
0

GenerateVersion.cmake 824 B

1234567891011121314151617181920212223242526
  1. # Always run during 'make'
  2. if(DEVELOPMENT_BUILD)
  3. execute_process(COMMAND git rev-parse --short HEAD
  4. WORKING_DIRECTORY "${GENERATE_VERSION_SOURCE_DIR}"
  5. OUTPUT_VARIABLE VERSION_GITHASH OUTPUT_STRIP_TRAILING_WHITESPACE
  6. ERROR_QUIET)
  7. if(VERSION_GITHASH)
  8. set(VERSION_GITHASH "${VERSION_STRING}-${VERSION_GITHASH}")
  9. execute_process(COMMAND git diff-index --quiet HEAD
  10. WORKING_DIRECTORY "${GENERATE_VERSION_SOURCE_DIR}"
  11. RESULT_VARIABLE IS_DIRTY)
  12. if(IS_DIRTY)
  13. set(VERSION_GITHASH "${VERSION_GITHASH}-dirty")
  14. endif()
  15. message(STATUS "*** Detected Git version ${VERSION_GITHASH} ***")
  16. endif()
  17. endif()
  18. if(NOT VERSION_GITHASH)
  19. set(VERSION_GITHASH "${VERSION_STRING}")
  20. endif()
  21. configure_file(
  22. ${GENERATE_VERSION_SOURCE_DIR}/cmake_config_githash.h.in
  23. ${GENERATE_VERSION_BINARY_DIR}/cmake_config_githash.h)