Imported Upstream version 2.8.10.2
[platform/upstream/cmake.git] / Modules / WriteBasicConfigVersionFile.cmake
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 #=============================================================================
6 # Copyright 2008-2011 Alexander Neundorf, <neundorf@kde.org>
7 # Copyright 2004-2009 Kitware, Inc.
8 #
9 # Distributed under the OSI-approved BSD License (the "License");
10 # see accompanying file Copyright.txt for details.
11 #
12 # This software is distributed WITHOUT ANY WARRANTY; without even the
13 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 # See the License for more information.
15 #=============================================================================
16 # (To distribute this file outside of CMake, substitute the full
17 #  License text for the above reference.)
18
19 include(CMakeParseArguments)
20
21 function(WRITE_BASIC_CONFIG_VERSION_FILE _filename)
22
23   set(options )
24   set(oneValueArgs VERSION COMPATIBILITY )
25   set(multiValueArgs )
26
27   cmake_parse_arguments(CVF "${options}" "${oneValueArgs}" "${multiValueArgs}"  ${ARGN})
28
29   if(CVF_UNPARSED_ARGUMENTS)
30     message(FATAL_ERROR "Unknown keywords given to WRITE_BASIC_CONFIG_VERSION_FILE(): \"${CVF_UNPARSED_ARGUMENTS}\"")
31   endif()
32
33   set(versionTemplateFile "${CMAKE_ROOT}/Modules/BasicConfigVersion-${CVF_COMPATIBILITY}.cmake.in")
34   if(NOT EXISTS "${versionTemplateFile}")
35     message(FATAL_ERROR "Bad COMPATIBILITY value used for WRITE_BASIC_CONFIG_VERSION_FILE(): \"${CVF_COMPATIBILITY}\"")
36   endif()
37
38   if("${CVF_VERSION}" STREQUAL "")
39     message(FATAL_ERROR "No VERSION specified for WRITE_BASIC_CONFIG_VERSION_FILE()")
40   endif()
41
42   configure_file("${versionTemplateFile}" "${_filename}" @ONLY)
43
44 endfunction()