You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

FetchMegBrainVersion.cmake 1.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Parses the version set in src/core/include/megbrain/version.h Exports the following
  2. # variables: MGB_VER_MAJOR: Major version MGB_VER_MINOR: Minor version MGB_VER_PATCH:
  3. # Patch version MGB_IS_DEV: Is development version MGB_VER_STRING: Version string
  4. option(MGB_FORCE_DEV_VERSION "Force -dev tag in version stamp" OFF)
  5. file(READ "${CMAKE_CURRENT_SOURCE_DIR}/src/core/include/megbrain/version.h" content)
  6. string(REGEX MATCH "MGB_MAJOR +([0-9]+)" _ ${content})
  7. set(MGB_VER_MAJOR ${CMAKE_MATCH_1})
  8. string(REGEX MATCH "MGB_MINOR +([0-9]+)" _ ${content})
  9. set(MGB_VER_MINOR ${CMAKE_MATCH_1})
  10. string(REGEX MATCH "MGB_PATCH *([0-9]+)" _ ${content})
  11. set(MGB_VER_PATCH ${CMAKE_MATCH_1})
  12. string(REGEX MATCH "MGE_MAJOR +([0-9]+)" _ ${content})
  13. set(MGE_VER_MAJOR ${CMAKE_MATCH_1})
  14. string(REGEX MATCH "MGE_MINOR +([0-9]+)" _ ${content})
  15. set(MGE_VER_MINOR ${CMAKE_MATCH_1})
  16. string(REGEX MATCH "MGE_PATCH *([0-9]+)" _ ${content})
  17. set(MGE_VER_PATCH ${CMAKE_MATCH_1})
  18. string(REGEX MATCH "MGE_EXTRA_NAME *\"(.*)\"" _ ${content})
  19. set(MGE_EXTRA_NAME ${CMAKE_MATCH_1})
  20. if(MGB_FORCE_DEV_VERSION)
  21. set(MGB_IS_DEV 1)
  22. else()
  23. string(REGEX MATCH "MGB_IS_DEV +([01])" _ ${content})
  24. set(MGB_IS_DEV ${CMAKE_MATCH_1})
  25. endif()
  26. if(DEFINED MGB_VER_MAJOR)
  27. set(MGB_VER_STRING "${MGB_VER_MAJOR}.${MGB_VER_MINOR}.${MGB_VER_PATCH}")
  28. else()
  29. set(MGB_VER_STRING "${MGE_VER_MAJOR}.${MGE_VER_MINOR}.${MGE_VER_PATCH}")
  30. endif(DEFINED MGB_VER_MAJOR)
  31. if(MGB_IS_DEV)
  32. set(MGB_VER_STRING "${MGB_VER_STRING}-dev")
  33. endif()
  34. message(STATUS "Building MegBrain ${MGB_VER_STRING}")