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

115 lines
4.8 KiB

  1. #
  2. # This program source code file is part of KICAD, a free EDA CAD application.
  3. #
  4. # Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
  5. # Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
  6. #
  7. # This program is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU General Public License
  9. # as published by the Free Software Foundation; either version 2
  10. # of the License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, you may find one here:
  19. # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. # or you may search the http://www.gnu.org website for the version 2 license,
  21. # or you may write to the Free Software Foundation, Inc.,
  22. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. #
  24. # Create the KiCad version strings
  25. include( ${KICAD_CMAKE_MODULE_PATH}/KiCadVersion.cmake )
  26. include( ${KICAD_CMAKE_MODULE_PATH}/KiCadFullVersion.cmake )
  27. # Extract the major and minor build version as a string
  28. string( REGEX MATCH
  29. "([0-9]+)\\.([0-9]+)\\.([0-9]+).*"
  30. KICAD_MAJOR_MINOR_PATCH_VERSION
  31. "${KICAD_SEMANTIC_VERSION}"
  32. )
  33. if( CMAKE_MATCH_COUNT EQUAL 3 )
  34. # Match slot 0 is the full string, so we want slots 1 & 2
  35. set( KICAD_MAJOR_MINOR_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}" )
  36. set( KICAD_MAJOR_MINOR_PATCH_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}" )
  37. set( KICAD_MAJOR_MINOR_PATCH_TUPLE "{ ${CMAKE_MATCH_1}, ${CMAKE_MATCH_2}, ${CMAKE_MATCH_3} }" )
  38. set( KICAD_MAJOR_VERSION "${CMAKE_MATCH_1}" )
  39. set( KICAD_MINOR_VERSION "${CMAKE_MATCH_2}" )
  40. set( KICAD_PATCH_VERSION "${CMAKE_MATCH_3}" )
  41. if( KICAD_MINOR_VERSION STREQUAL "99" )
  42. set( KICAD_IS_NIGHTLY "1" )
  43. else()
  44. set( KICAD_IS_NIGHTLY "0" )
  45. endif()
  46. set( KICAD_WIN32_RC_FILEVER_STR "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}.${KICAD_GIT_REV}\\0" )
  47. set( KICAD_WIN32_RC_FILEVER "${CMAKE_MATCH_1}, ${CMAKE_MATCH_2}, ${CMAKE_MATCH_3}, ${KICAD_GIT_REV}" )
  48. set( KICAD_WIN32_RC_PRODVER_STR "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}\\0" )
  49. set( KICAD_WIN32_RC_PRODVER "${CMAKE_MATCH_1}, ${CMAKE_MATCH_2}, ${CMAKE_MATCH_3}, ${KICAD_GIT_REV}" )
  50. else()
  51. message( FATAL_ERROR "Unable to extract major, minor and patch version string" )
  52. endif()
  53. set( _wvh_new_version_text
  54. "/* Do not modify this file, it was automatically generated by CMake. */
  55. /*
  56. * Define the KiCad build version strings.
  57. */
  58. #ifndef __KICAD_VERSION_H__
  59. #define __KICAD_VERSION_H__
  60. #ifndef INCLUDE_KICAD_VERSION
  61. #error Do not include kicad_build_version.h directly. Include build_version.h instead.
  62. #endif
  63. #define KICAD_COMMIT_HASH \"${KICAD_COMMIT_HASH}\"
  64. #define KICAD_VERSION_FULL \"${KICAD_VERSION_FULL}\"
  65. #define KICAD_SEMANTIC_VERSION \"${KICAD_SEMANTIC_VERSION}\"
  66. #define KICAD_MAJOR_VERSION \"${KICAD_MAJOR_VERSION}\"
  67. #define KICAD_MINOR_VERSION \"${KICAD_MINOR_VERSION}\"
  68. #define KICAD_PATCH_VERSION \"${KICAD_PATCH_VERSION}\"
  69. #define KICAD_IS_NIGHTLY ${KICAD_IS_NIGHTLY}
  70. #define KICAD_MAJOR_MINOR_VERSION \"${KICAD_MAJOR_MINOR_VERSION}\"
  71. #define KICAD_MAJOR_MINOR_PATCH_VERSION \"${KICAD_MAJOR_MINOR_PATCH_VERSION}\"
  72. #define KICAD_MAJOR_MINOR_PATCH_TUPLE ${KICAD_MAJOR_MINOR_PATCH_TUPLE}
  73. #define KICAD_WIN32_RC_PRODVER ${KICAD_WIN32_RC_PRODVER}
  74. #define KICAD_WIN32_RC_PRODVER_STR \"${KICAD_WIN32_RC_PRODVER_STR}\"
  75. #define KICAD_WIN32_RC_FILEVER ${KICAD_WIN32_RC_FILEVER}
  76. #define KICAD_WIN32_RC_FILEVER_STR \"${KICAD_WIN32_RC_FILEVER_STR}\"
  77. #endif /* __KICAD_VERSION_H__ */
  78. " )
  79. set( _wvh_write_version_file ON )
  80. # Only write the header if it has changed, to avoid rebuilds
  81. if( EXISTS ${OUTPUT_FILE} )
  82. file( READ ${OUTPUT_FILE} _wvh_old_version_text )
  83. if( _wvh_old_version_text STREQUAL _wvh_new_version_text )
  84. message( STATUS "Not updating ${OUTPUT_FILE}" )
  85. set( _wvh_write_version_file OFF )
  86. endif()
  87. endif()
  88. if( _wvh_write_version_file )
  89. message( STATUS "Writing ${OUTPUT_FILE} file with version: ${KICAD_VERSION_FULL}" )
  90. file( WRITE ${OUTPUT_FILE} ${_wvh_new_version_text} )
  91. # Write a simple document with only the full version
  92. file( WRITE ${TEXT_OUTPUT_FILE} "${KICAD_VERSION_FULL}" )
  93. endif()
  94. # There should always be a valid version.h file. Otherwise, the build will fail.
  95. if( NOT EXISTS ${OUTPUT_FILE} )
  96. message( FATAL_ERROR "Configuration failed to write file ${OUTPUT_FILE}." )
  97. endif()