FeatureSummary.cmake 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # - Macros for generating a summary of enabled/disabled features
  2. #
  3. # PRINT_ENABLED_FEATURES()
  4. # Print a summary of all enabled features. By default all successfull
  5. # FIND_PACKAGE() calls will appear here, except the ones which used the
  6. # QUIET keyword. Additional features can be added by appending an entry
  7. # to the global ENABLED_FEATURES property. If SET_FEATURE_INFO() is
  8. # used for that feature, the output will be much more informative.
  9. #
  10. # PRINT_DISABLED_FEATURES()
  11. # Same as PRINT_ENABLED_FEATURES(), but for disabled features. It can
  12. # be extended the same way by adding to the global property
  13. # DISABLED_FEATURES.
  14. #
  15. # SET_FEATURE_INFO(NAME DESCRIPTION [URL [COMMENT] ] )
  16. # Use this macro to set up information about the named feature, which will
  17. # then be displayed by PRINT_ENABLED/DISABLED_FEATURES().
  18. # Example: SET_FEATURE_INFO(LibXml2 "XML processing library."
  19. # "http://xmlsoft.org/")
  20. #
  21. #=============================================================================
  22. # Copyright 2007-2009 Kitware, Inc.
  23. #
  24. # Distributed under the OSI-approved BSD License (the "License");
  25. # see accompanying file Copyright.txt for details.
  26. #
  27. # This software is distributed WITHOUT ANY WARRANTY; without even the
  28. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  29. # See the License for more information.
  30. #=============================================================================
  31. # (To distribute this file outside of CMake, substitute the full
  32. # License text for the above reference.)
  33. FUNCTION(SET_FEATURE_INFO _name _desc)
  34. SET(_url "${ARGV2}")
  35. SET(_comment "${ARGV3}")
  36. SET_PROPERTY(GLOBAL PROPERTY ${_name}_DESCRIPTION "${_desc}" )
  37. IF(_url MATCHES ".+")
  38. SET_PROPERTY(GLOBAL PROPERTY ${_name}_URL "${_url}" )
  39. ENDIF(_url MATCHES ".+")
  40. IF(_comment MATCHES ".+")
  41. SET_PROPERTY(GLOBAL PROPERTY ${_name}_COMMENT "${_comment}" )
  42. ENDIF(_comment MATCHES ".+")
  43. ENDFUNCTION(SET_FEATURE_INFO)
  44. FUNCTION(_PRINT_FEATURES _property _text)
  45. SET(_currentFeatureText "${_text}")
  46. GET_PROPERTY(_EnabledFeatures GLOBAL PROPERTY ${_property})
  47. FOREACH(_currentFeature ${_EnabledFeatures})
  48. SET(_currentFeatureText "${_currentFeatureText}\n${_currentFeature}")
  49. GET_PROPERTY(_info GLOBAL PROPERTY ${_currentFeature}_DESCRIPTION)
  50. IF(_info)
  51. SET(_currentFeatureText "${_currentFeatureText} , ${_info}")
  52. ENDIF(_info)
  53. GET_PROPERTY(_info GLOBAL PROPERTY ${_currentFeature}_URL)
  54. IF(_info)
  55. SET(_currentFeatureText "${_currentFeatureText} , <${_info}>")
  56. ENDIF(_info)
  57. GET_PROPERTY(_info GLOBAL PROPERTY ${_currentFeature}_COMMENT)
  58. IF(_info)
  59. SET(_currentFeatureText "${_currentFeatureText} , ${_info}")
  60. ENDIF(_info)
  61. ENDFOREACH(_currentFeature)
  62. MESSAGE(STATUS "${_currentFeatureText}\n")
  63. ENDFUNCTION(_PRINT_FEATURES)
  64. FUNCTION(PRINT_ENABLED_FEATURES)
  65. _PRINT_FEATURES( ENABLED_FEATURES "Enabled features:")
  66. ENDFUNCTION(PRINT_ENABLED_FEATURES)
  67. FUNCTION(PRINT_DISABLED_FEATURES)
  68. _PRINT_FEATURES( DISABLED_FEATURES "Disabled features:")
  69. ENDFUNCTION(PRINT_DISABLED_FEATURES)