ScmRevGen.cmake 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. cmake_minimum_required(VERSION 3.13)
  2. # for revision info
  3. if(GIT_FOUND)
  4. # defines DOLPHIN_WC_REVISION
  5. execute_process(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
  6. OUTPUT_VARIABLE DOLPHIN_WC_REVISION
  7. OUTPUT_STRIP_TRAILING_WHITESPACE)
  8. # defines DOLPHIN_WC_DESCRIBE
  9. execute_process(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} describe --always --long --dirty
  10. OUTPUT_VARIABLE DOLPHIN_WC_DESCRIBE
  11. OUTPUT_STRIP_TRAILING_WHITESPACE)
  12. # remove hash (and trailing "-0" if needed) from description
  13. string(REGEX REPLACE "(-0)?-[^-]+((-dirty)?)$" "\\2" DOLPHIN_WC_DESCRIBE "${DOLPHIN_WC_DESCRIBE}")
  14. # defines DOLPHIN_WC_BRANCH
  15. execute_process(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
  16. OUTPUT_VARIABLE DOLPHIN_WC_BRANCH
  17. OUTPUT_STRIP_TRAILING_WHITESPACE)
  18. # defines DOLPHIN_WC_COMMITS_AHEAD_MASTER
  19. execute_process(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD ^master
  20. OUTPUT_VARIABLE DOLPHIN_WC_COMMITS_AHEAD_MASTER
  21. OUTPUT_STRIP_TRAILING_WHITESPACE)
  22. # defines DOLPHIN_WC_TAG
  23. execute_process(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} describe --exact-match HEAD
  24. OUTPUT_VARIABLE DOLPHIN_WC_TAG
  25. OUTPUT_STRIP_TRAILING_WHITESPACE
  26. ERROR_QUIET)
  27. endif()
  28. # version number
  29. set(DOLPHIN_VERSION_MAJOR "2409")
  30. set(DOLPHIN_VERSION_MINOR "0")
  31. set(DOLPHIN_VERSION_PATCH ${DOLPHIN_WC_REVISION})
  32. # If Dolphin is not built from a Git repository, default the version info to
  33. # reasonable values.
  34. if(NOT DOLPHIN_WC_REVISION)
  35. set(DOLPHIN_WC_DESCRIBE "${DOLPHIN_VERSION_MAJOR}.${DOLPHIN_VERSION_MINOR}")
  36. set(DOLPHIN_WC_REVISION "${DOLPHIN_WC_DESCRIBE} (no further info)")
  37. set(DOLPHIN_WC_BRANCH "master")
  38. set(DOLPHIN_WC_COMMITS_AHEAD_MASTER 0)
  39. endif()
  40. # If this is a tag (i.e. a release), then set the current patch version and
  41. # the number of commits ahead to zero.
  42. if(DOLPHIN_WC_TAG)
  43. set(DOLPHIN_VERSION_PATCH "0")
  44. set(DOLPHIN_WC_COMMITS_AHEAD_MASTER 0)
  45. endif()
  46. function(configure_source_file path)
  47. configure_file(
  48. "${PROJECT_SOURCE_DIR}/${path}.in"
  49. "${PROJECT_BINARY_DIR}/${path}.tmp"
  50. )
  51. execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_BINARY_DIR}/${path}.tmp" "${PROJECT_BINARY_DIR}/${path}")
  52. file(REMOVE "${PROJECT_BINARY_DIR}/${path}.tmp")
  53. endfunction()
  54. configure_source_file("Source/Core/Common/scmrev.h")
  55. if(APPLE)
  56. configure_source_file("Source/Core/DolphinQt/Info.plist")
  57. configure_source_file("Source/Core/MacUpdater/Info.plist")
  58. endif()