WriteBasicConfigVersionFile.cmake 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. )
  14. #]=======================================================================]
  15. function(WRITE_BASIC_CONFIG_VERSION_FILE _filename)
  16. set(options )
  17. set(oneValueArgs VERSION COMPATIBILITY )
  18. set(multiValueArgs )
  19. cmake_parse_arguments(CVF "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
  20. if(CVF_UNPARSED_ARGUMENTS)
  21. message(FATAL_ERROR "Unknown keywords given to WRITE_BASIC_CONFIG_VERSION_FILE(): \"${CVF_UNPARSED_ARGUMENTS}\"")
  22. endif()
  23. set(versionTemplateFile "${CMAKE_ROOT}/Modules/BasicConfigVersion-${CVF_COMPATIBILITY}.cmake.in")
  24. if(NOT EXISTS "${versionTemplateFile}")
  25. message(FATAL_ERROR "Bad COMPATIBILITY value used for WRITE_BASIC_CONFIG_VERSION_FILE(): \"${CVF_COMPATIBILITY}\"")
  26. endif()
  27. if("${CVF_VERSION}" STREQUAL "")
  28. if ("${PROJECT_VERSION}" STREQUAL "")
  29. message(FATAL_ERROR "No VERSION specified for WRITE_BASIC_CONFIG_VERSION_FILE()")
  30. else()
  31. set(CVF_VERSION "${PROJECT_VERSION}")
  32. endif()
  33. endif()
  34. configure_file("${versionTemplateFile}" "${_filename}" @ONLY)
  35. endfunction()