WriteBasicConfigVersionFile.cmake 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # WRITE_BASIC_CONFIG_VERSION_FILE( filename VERSION major.minor.patch COMPATIBILITY (AnyNewerVersion|SameMajorVersion) )
  2. #
  3. # Deprecated, see WRITE_BASIC_PACKAGE_VERSION_FILE(), it is identical.
  4. #=============================================================================
  5. # Copyright 2008-2011 Alexander Neundorf, <[email protected]>
  6. # Copyright 2004-2009 Kitware, Inc.
  7. #
  8. # Distributed under the OSI-approved BSD License (the "License");
  9. # see accompanying file Copyright.txt for details.
  10. #
  11. # This software is distributed WITHOUT ANY WARRANTY; without even the
  12. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. # See the License for more information.
  14. #=============================================================================
  15. # (To distribute this file outside of CMake, substitute the full
  16. # License text for the above reference.)
  17. include(CMakeParseArguments)
  18. function(WRITE_BASIC_CONFIG_VERSION_FILE _filename)
  19. set(options )
  20. set(oneValueArgs VERSION COMPATIBILITY )
  21. set(multiValueArgs )
  22. cmake_parse_arguments(CVF "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
  23. if(CVF_UNPARSED_ARGUMENTS)
  24. message(FATAL_ERROR "Unknown keywords given to WRITE_BASIC_CONFIG_VERSION_FILE(): \"${CVF_UNPARSED_ARGUMENTS}\"")
  25. endif(CVF_UNPARSED_ARGUMENTS)
  26. set(versionTemplateFile "${CMAKE_ROOT}/Modules/BasicConfigVersion-${CVF_COMPATIBILITY}.cmake.in")
  27. if(NOT EXISTS "${versionTemplateFile}")
  28. message(FATAL_ERROR "Bad COMPATIBILITY value used for WRITE_BASIC_CONFIG_VERSION_FILE(): \"${CVF_COMPATIBILITY}\"")
  29. endif()
  30. if("${CVF_VERSION}" STREQUAL "")
  31. message(FATAL_ERROR "No VERSION specified for WRITE_BASIC_CONFIG_VERSION_FILE()")
  32. endif()
  33. configure_file("${versionTemplateFile}" "${_filename}" @ONLY)
  34. endfunction(WRITE_BASIC_CONFIG_VERSION_FILE)