git-svn-id: svn://db.shs.com.ru/libs@904 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2020-03-24 15:35:35 +00:00
parent 98689caf01
commit 1f339c91be

View File

@@ -1,8 +1,27 @@
# set_version(<target> [MAJOR <value>] [MINOR <value>] [REVISION <value>] [SUFFIX <value>] [BUILD <value>] [OUTPUT <file>])
#
# Set target version, optionally creates file
#
# Create variable <target>_VERSION with full version name
#
# If OUTPUT then generate header <file> with
# version defines - <target>_VERSION_<NAME>
# Also create define <target>_VERSION with full string version
#
#
#
#
# import_version(<target> <source_target>)
#
# Copy all version components from <source_target>
#
#
#
#
# set_deploy_property(<target> [SHARED | STATIC] NAME <value> [NAME <value> [...]])
#
# Set target deploy property, where NAME one of:
# * LABEL - application icon name
# * VERSION - version
# * FULLNAME - package name in format "*.*.*"
# * COMPANY - company name
# * ICON - icon file
@@ -54,13 +73,97 @@
if (POLICY CMP0057)
cmake_policy(SET CMP0057 NEW) # Support if() IN_LIST
endif()
set(__prop_names "LABEL;VERSION;FULLNAME;COMPANY;ICON;INFO")
set(__prop_names "LABEL;FULLNAME;COMPANY;ICON;INFO")
set(__version_names "MAJOR;MINOR;REVISION;BUILD;SUFFIX")
include(TargetArch)
if (NOT MY_ARCH)
target_architecture(MY_ARCH)
endif()
macro(set_version _T)
set(_name)
set(_is_name 1)
set(_is_out 0)
set(_out)
foreach(_i ${ARGN})
if (_is_out)
set(_is_out 0)
set(_out "${_i}")
elseif ("x${_i}" STREQUAL "xOUTPUT")
set(_is_out 1)
elseif(_is_name)
set(_is_name 0)
if (_i IN_LIST __version_names)
else()
message(FATAL_ERROR "Invalid version component \"${_i}\"!")
endif()
set(_name ${_i})
else()
set(_is_name 1)
set(${_T}_VERSION_${_name} ${_i})
endif()
endforeach()
set(${_T}_VERSION_FULLSUFFIX "${${_T}_VERSION_SUFFIX}")
if (NOT ("x${${_T}_VERSION_FULLSUFFIX}" STREQUAL "x"))
if(NOT ("${${_T}_VERSION_FULLSUFFIX}" MATCHES "_.*"))
set(${_T}_VERSION_FULLSUFFIX "_${${_T}_VERSION_FULLSUFFIX}")
endif()
endif()
if ("x${${_T}_VERSION_MAJOR}" STREQUAL "x")
set(${_T}_VERSION_MAJOR "0")
endif()
if ("x${${_T}_VERSION_MINOR}" STREQUAL "x")
set(${_T}_VERSION_MINOR "0")
endif()
if ("x${${_T}_VERSION_REVISION}" STREQUAL "x")
set(${_T}_VERSION_REVISION "0")
endif()
if ("x${${_T}_VERSION_BUILD}" STREQUAL "x")
set(${_T}_VERSION_BUILD "0")
endif()
set(${_T}_VERSION "${${_T}_VERSION_MAJOR}.${${_T}_VERSION_MINOR}.${${_T}_VERSION_REVISION}${${_T}_VERSION_FULLSUFFIX}")
set(_${_T}_VERSION_WB "${${_T}_VERSION}-${${_T}_VERSION_BUILD}")
if (_out)
set(_${_T}_VERSION_CHANGED 0)
if ((NOT _${_T}_CACHED_VERSION) OR (NOT ("x${_${_T}_CACHED_VERSION}" STREQUAL "x${_${_T}_VERSION_WB}")))
set(_${_T}_CACHED_VERSION "${_${_T}_VERSION_WB}" CACHE STRING "" FORCE)
set(_${_T}_VERSION_CHANGED 1)
endif()
if ((NOT EXISTS "${_out}") OR _${_T}_VERSION_CHANGED)
get_filename_component(_def "${_out}" NAME)
string(MAKE_C_IDENTIFIER "${_T}_${_def}" _def)
string(TOUPPER "${_def}" _def)
string(TOUPPER "${_T}" _TN)
file(WRITE "${_out}"
"// This file generated by CMake set_version()
#ifndef ${_def}
#define ${_def}
#define ${_TN}_VERSION_MAJOR ${${_T}_VERSION_MAJOR}
#define ${_TN}_VERSION_MINOR ${${_T}_VERSION_MINOR}
#define ${_TN}_VERSION_REVISION ${${_T}_VERSION_REVISION}
#define ${_TN}_VERSION_BUILD ${${_T}_VERSION_BUILD}
#define ${_TN}_VERSION_SUFFIX \"${${_T}_VERSION_SUFFIX}\"
#define ${_TN}_VERSION \"${${_T}_VERSION}\"
#endif // ${_def}
")
endif()
endif()
endmacro()
macro(import_version _T _F)
set(_names "${__version_names};FULLSUFFIX")
foreach(_i ${_names})
set(${_T}_VERSION_${_i} "${${_F}_VERSION_${_i}}")
endforeach()
set(${_T}_VERSION "${${_F}_VERSION}")
endmacro()
macro(set_deploy_property _T)
set(_name)
set(_is_name 1)
@@ -98,7 +201,7 @@ macro(make_rc _T _out)
endif()
get_filename_component(WINDOWS_RC_ICON "${${_T}_ICON}" REALPATH BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(_rc_file "${CMAKE_CURRENT_BINARY_DIR}/winres.rc")
file(WRITE ${_rc_file}
file(WRITE "${_rc_file}"
"# if defined(UNDER_CE)
# include <winbase.h>
# else