Version.cmake 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # Copyright 2013 OSMOCOM Project
  2. #
  3. # This file is part of rtl-sdr
  4. #
  5. # rtl-sdr is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 3, or (at your option)
  8. # any later version.
  9. #
  10. # rtl-sdr is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with rtl-sdr; see the file COPYING. If not, write to
  17. # the Free Software Foundation, Inc., 51 Franklin Street,
  18. # Boston, MA 02110-1301, USA.
  19. if(DEFINED __INCLUDED_VERSION_CMAKE)
  20. return()
  21. endif()
  22. set(__INCLUDED_VERSION_CMAKE TRUE)
  23. # VERSION_INFO_* variables must be provided by user
  24. set(MAJOR_VERSION ${VERSION_INFO_MAJOR_VERSION})
  25. set(MINOR_VERSION ${VERSION_INFO_MINOR_VERSION})
  26. set(PATCH_VERSION ${VERSION_INFO_PATCH_VERSION})
  27. ########################################################################
  28. # Extract the version string from git describe.
  29. ########################################################################
  30. find_package(Git QUIET)
  31. if(GIT_FOUND)
  32. message(STATUS "Extracting version information from git describe...")
  33. execute_process(
  34. COMMAND ${GIT_EXECUTABLE} describe --always --abbrev=4 --long
  35. OUTPUT_VARIABLE GIT_DESCRIBE OUTPUT_STRIP_TRAILING_WHITESPACE
  36. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  37. )
  38. else()
  39. set(GIT_DESCRIBE "v${MAJOR_VERSION}.${MINOR_VERSION}.x-xxx-xunknown")
  40. endif()
  41. ########################################################################
  42. # Use the logic below to set the version constants
  43. ########################################################################
  44. if("${PATCH_VERSION}" STREQUAL "git")
  45. # VERSION: 3.6git-xxx-gxxxxxxxx
  46. # LIBVER: 3.6git
  47. set(VERSION "${GIT_DESCRIBE}")
  48. set(LIBVER "${MAJOR_VERSION}.${MINOR_VERSION}${PATCH_VERSION}")
  49. else()
  50. # This is a numbered release.
  51. # VERSION: 3.6.1
  52. # LIBVER: 3.6.1
  53. set(VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}")
  54. set(LIBVER "${VERSION}")
  55. endif()