FindBAZAAR.cmake 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #
  2. # This program source code file is part of KICAD, a free EDA CAD application.
  3. #
  4. # Copyright (C) 2010 Wayne Stambaugh <stambaughw@verizon.net>
  5. # Copyright (C) 2010 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. # This CMake script finds the BAZAAR version control system executable and
  25. # and fetches the veresion string to valid that BAZAAR was found and executes
  26. # properly.
  27. #
  28. # Usage:
  29. # find_package( BAZAAR )
  30. #
  31. # User definable.
  32. # BAZAAR_EXECUTABLE Set this to use a version of BAZAAR that is not in
  33. # current path. Defaults to bzr.
  34. #
  35. # Defines:
  36. # BAZAAR_FOUND Set to TRUE if BAZAAR command line client is found
  37. # and the bzr --version command executes properly.
  38. # BAZAAR_VERSION Result of the bzr --version command.
  39. #
  40. set( BAZAAR_FOUND FALSE )
  41. find_program( BAZAAR_EXECUTABLE bzr
  42. DOC "BAZAAR version control system command line client" )
  43. mark_as_advanced( BAZAAR_EXECUTABLE )
  44. if( BAZAAR_EXECUTABLE )
  45. # BAZAAR commands should be executed with the C locale, otherwise
  46. # the message (which are parsed) may be translated causing the regular
  47. # expressions to fail.
  48. set( _BAZAAR_SAVED_LC_ALL "$ENV{LC_ALL}" )
  49. set( ENV{LC_ALL} C )
  50. # Fetch the BAZAAR executable version.
  51. execute_process( COMMAND ${BAZAAR_EXECUTABLE} --version
  52. OUTPUT_VARIABLE _bzr_version_output
  53. ERROR_VARIABLE _bzr_version_error
  54. RESULT_VARIABLE _bzr_version_result
  55. OUTPUT_STRIP_TRAILING_WHITESPACE )
  56. if( ${_bzr_version_result} EQUAL 0 )
  57. set( BAZAAR_FOUND TRUE )
  58. string( REGEX REPLACE "^[\n]*Bazaar \\(bzr\\) ([0-9.a-z]+).*"
  59. "\\1" BAZAAR_VERSION "${_bzr_version_output}" )
  60. if( NOT BAZAAR_FIND_QUIETLY )
  61. message( STATUS "BAZAAR version control system version ${BAZAAR_VERSION} found." )
  62. endif()
  63. endif()
  64. # restore the previous LC_ALL
  65. set( ENV{LC_ALL} ${_BAZAAR_SAVED_LC_ALL} )
  66. endif()
  67. if( NOT BAZAAR_FOUND )
  68. if( NOT BAZAAR_FIND_QUIETLY )
  69. message( STATUS "BAZAAR version control command line client was not found." )
  70. else()
  71. if( BAZAAR_FIND_REQUIRED )
  72. message( FATAL_ERROR "BAZAAR version control command line client was not found." )
  73. endif()
  74. endif()
  75. endif()