WriteBasicConfigVersionFile.cmake 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. WriteBasicConfigVersionFile
  5. ---------------------------
  6. .. deprecated:: 3.0
  7. Use the identical command :command:`write_basic_package_version_file()`
  8. from module :module:`CMakePackageConfigHelpers`.
  9. ::
  10. WRITE_BASIC_CONFIG_VERSION_FILE( filename
  11. [VERSION major.minor.patch]
  12. COMPATIBILITY (AnyNewerVersion|SameMajorVersion|SameMinorVersion|ExactVersion)
  13. [ARCH_INDEPENDENT]
  14. )
  15. #]=======================================================================]
  16. function(WRITE_BASIC_CONFIG_VERSION_FILE _filename)
  17. set(options ARCH_INDEPENDENT )
  18. set(oneValueArgs VERSION COMPATIBILITY )
  19. set(multiValueArgs )
  20. cmake_parse_arguments(CVF "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
  21. if(CVF_UNPARSED_ARGUMENTS)
  22. message(FATAL_ERROR "Unknown keywords given to WRITE_BASIC_CONFIG_VERSION_FILE(): \"${CVF_UNPARSED_ARGUMENTS}\"")
  23. endif()
  24. set(versionTemplateFile "${CMAKE_ROOT}/Modules/BasicConfigVersion-${CVF_COMPATIBILITY}.cmake.in")
  25. if(NOT EXISTS "${versionTemplateFile}")
  26. message(FATAL_ERROR "Bad COMPATIBILITY value used for WRITE_BASIC_CONFIG_VERSION_FILE(): \"${CVF_COMPATIBILITY}\"")
  27. endif()
  28. if("${CVF_VERSION}" STREQUAL "")
  29. if ("${PROJECT_VERSION}" STREQUAL "")
  30. message(FATAL_ERROR "No VERSION specified for WRITE_BASIC_CONFIG_VERSION_FILE()")
  31. else()
  32. set(CVF_VERSION "${PROJECT_VERSION}")
  33. endif()
  34. endif()
  35. configure_file("${versionTemplateFile}" "${_filename}" @ONLY)
  36. endfunction()