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