code: Fix errors hidden by parent scope leaking into function
The variable scope in CMake is unlike other languages, and simply prevents functions from unintentionally polluting the parent scope. Unfortunately this also means that we need to take extra measurements to guarantee a good default state, and that 'DEFINED' is a useless keyword. Therefore by using a random prefix, we can prevent unintentional pollution of the function scope by the caller.
This commit is contained in:
+181
-133
@@ -89,10 +89,13 @@ Compares the version ``<a>`` against ``<b>`` and stores the result in ``<out-var
|
||||
#]=======================================================================]
|
||||
|
||||
function(version)
|
||||
unset(${OUT_VAR} PARENT_SCOPE)
|
||||
unset(${OUT_VAR}_ERROR PARENT_SCOPE)
|
||||
# CMake functions do not have their own proper scope, they act more
|
||||
|
||||
set(OUT_VAR "${ARGV1}")
|
||||
set(_ "")
|
||||
|
||||
# Force clean parent elements.
|
||||
set(${OUT_VAR} "" PARENT_SCOPE)
|
||||
set(${OUT_VAR}_ERROR "" PARENT_SCOPE)
|
||||
|
||||
string(TOUPPER "${ARGV0}" ARGV0)
|
||||
if(ARGV0 STREQUAL "PARSE")
|
||||
@@ -114,14 +117,14 @@ function(version)
|
||||
string(SUBSTRING "${CMAKE_MATCH_3}" 1 -1 _TMP)
|
||||
set(${OUT_VAR}_PATCH "${_TMP}" PARENT_SCOPE)
|
||||
else()
|
||||
unset(${OUT_VAR}_PATCH PARENT_SCOPE)
|
||||
set(${OUT_VAR}_PATCH "" PARENT_SCOPE)
|
||||
endif()
|
||||
# {4} = Tweak
|
||||
if(CMAKE_MATCH_4)
|
||||
string(SUBSTRING "${CMAKE_MATCH_4}" 1 -1 _TMP)
|
||||
set(${OUT_VAR}_TWEAK "${_TMP}" PARENT_SCOPE)
|
||||
else()
|
||||
unset(${OUT_VAR}_TWEAK PARENT_SCOPE)
|
||||
set(${OUT_VAR}_TWEAK "" PARENT_SCOPE)
|
||||
endif()
|
||||
# {5} = PreRelease
|
||||
if(CMAKE_MATCH_5)
|
||||
@@ -134,7 +137,7 @@ function(version)
|
||||
set(${OUT_VAR}_PRERELEASE "${CMAKE_MATCH_5}" PARENT_SCOPE)
|
||||
endif()
|
||||
else()
|
||||
unset(${OUT_VAR}_PRERELEASE PARENT_SCOPE)
|
||||
set(${OUT_VAR}_PRERELEASE "" PARENT_SCOPE)
|
||||
endif()
|
||||
# {6} = Build
|
||||
if(CMAKE_MATCH_6)
|
||||
@@ -142,122 +145,139 @@ function(version)
|
||||
string(SUBSTRING "${CMAKE_MATCH_6}" 1 -1 CMAKE_MATCH_6)
|
||||
set(${OUT_VAR}_BUILD "${CMAKE_MATCH_6}" PARENT_SCOPE)
|
||||
else()
|
||||
unset(${OUT_VAR}_BUILD PARENT_SCOPE)
|
||||
set(${OUT_VAR}_BUILD "" PARENT_SCOPE)
|
||||
endif()
|
||||
elseif(ARGV0 STREQUAL "GENERATE")
|
||||
set(_feeb1eff "")
|
||||
set(_32070faa "")
|
||||
set(_32070faa_MAJOR "")
|
||||
set(_32070faa_MINOR "")
|
||||
set(_32070faa_PATCH "")
|
||||
set(_32070faa_TWEAK "")
|
||||
set(_32070faa_PRERELEASE "")
|
||||
set(_32070faa_BUILD "")
|
||||
set(_32070faa_ERROR "")
|
||||
cmake_parse_arguments(
|
||||
PARSE_ARGV 2
|
||||
_ARGS
|
||||
_32070faa
|
||||
"COMPRESS"
|
||||
"MAJOR;MINOR;PATCH;TWEAK;PRERELEASE;BUILD"
|
||||
""
|
||||
)
|
||||
|
||||
# Do we have the major component, and is it valid?
|
||||
if(DEFINED _ARGS_MAJOR)
|
||||
string(STRIP "${_ARGS_MAJOR}" _ARGS_MAJOR)
|
||||
if(_ARGS_MAJOR STREQUAL "")
|
||||
set(_ARGS_MAJOR 0)
|
||||
elseif(NOT (_ARGS_MAJOR MATCHES [[^[0-9]+$]]))
|
||||
set(${OUT_VAR}_ERROR "MAJOR component must be a numeric identifier, but is: '${_ARGS_MAJOR}'" PARENT_SCOPE)
|
||||
if(_32070faa_MAJOR)
|
||||
string(STRIP "${_32070faa_MAJOR}" _32070faa_MAJOR)
|
||||
if(_32070faa_MAJOR STREQUAL "")
|
||||
set(_32070faa_MAJOR 0)
|
||||
elseif(NOT (_32070faa_MAJOR MATCHES [[^[0-9]+$]]))
|
||||
set(${OUT_VAR}_ERROR "MAJOR component must be a numeric identifier, but is: '${_32070faa_MAJOR}'" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
else()
|
||||
set(_ARGS_MAJOR 0)
|
||||
set(_32070faa_MAJOR 0)
|
||||
endif()
|
||||
set(_ "${_}${_ARGS_MAJOR}")
|
||||
set(_feeb1eff "${_feeb1eff}${_32070faa_MAJOR}")
|
||||
|
||||
# Do we have the minor component, and is it valid?
|
||||
if(DEFINED _ARGS_MINOR)
|
||||
string(STRIP "${_ARGS_MINOR}" _ARGS_MINOR)
|
||||
if(_ARGS_MINOR STREQUAL "")
|
||||
set(_ARGS_MINOR 0)
|
||||
elseif(NOT (_ARGS_MINOR MATCHES [[^[0-9]+$]]))
|
||||
set(${OUT_VAR}_ERROR "MINOR component must be a numeric identifier, but is: '${_ARGS_MINOR}'" PARENT_SCOPE)
|
||||
if(_32070faa_MINOR)
|
||||
string(STRIP "${_32070faa_MINOR}" _32070faa_MINOR)
|
||||
if(_32070faa_MINOR STREQUAL "")
|
||||
set(_32070faa_MINOR 0)
|
||||
elseif(NOT (_32070faa_MINOR MATCHES [[^[0-9]+$]]))
|
||||
set(${OUT_VAR}_ERROR "MINOR component must be a numeric identifier, but is: '${_32070faa_MINOR}'" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
else()
|
||||
set(_ARGS_MINOR 0)
|
||||
set(_32070faa_MINOR 0)
|
||||
endif()
|
||||
set(_ "${_}.${_ARGS_MINOR}")
|
||||
set(_feeb1eff "${_feeb1eff}.${_32070faa_MINOR}")
|
||||
|
||||
# Do we have the patch component, and is it valid?
|
||||
if(DEFINED _ARGS_PATCH)
|
||||
string(STRIP "${_ARGS_PATCH}" _ARGS_PATCH)
|
||||
if(_ARGS_PATCH STREQUAL "")
|
||||
unset(_ARGS_PATCH)
|
||||
elseif(_ARGS_PATCH MATCHES [[^[0-9]+$]])
|
||||
set(_ "${_}.${_ARGS_PATCH}")
|
||||
if(_32070faa_PATCH)
|
||||
string(STRIP "${_32070faa_PATCH}" _32070faa_PATCH)
|
||||
if(_32070faa_PATCH STREQUAL "")
|
||||
unset(_32070faa_PATCH)
|
||||
elseif(_32070faa_PATCH MATCHES [[^[0-9]+$]])
|
||||
set(_feeb1eff "${_feeb1eff}.${_32070faa_PATCH}")
|
||||
else()
|
||||
set(${OUT_VAR}_ERROR "PATCH component must be a numeric identifier, but is: '${_ARGS_PATCH}'" PARENT_SCOPE)
|
||||
set(${OUT_VAR}_ERROR "PATCH component must be a numeric identifier, but is: '${_32070faa_PATCH}'" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Do we have the tweak component, and is it valid?
|
||||
if(DEFINED _ARGS_TWEAK)
|
||||
string(STRIP "${_ARGS_TWEAK}" _ARGS_TWEAK)
|
||||
if(_ARGS_TWEAK STREQUAL "")
|
||||
unset(_ARGS_TWEAK)
|
||||
elseif(_ARGS_TWEAK MATCHES [[^[0-9]+$]])
|
||||
if(NOT DEFINED _ARGS_PATCH)
|
||||
set(_ "${_}.0")
|
||||
if(_32070faa_TWEAK)
|
||||
string(STRIP "${_32070faa_TWEAK}" _32070faa_TWEAK)
|
||||
if(_32070faa_TWEAK STREQUAL "")
|
||||
unset(_32070faa_TWEAK)
|
||||
elseif(_32070faa_TWEAK MATCHES [[^[0-9]+$]])
|
||||
if(NOT _32070faa_PATCH)
|
||||
set(_feeb1eff "${_feeb1eff}.0")
|
||||
endif()
|
||||
set(_ "${_}.${_ARGS_TWEAK}")
|
||||
set(_feeb1eff "${_feeb1eff}.${_32070faa_TWEAK}")
|
||||
else()
|
||||
set(${OUT_VAR}_ERROR "TWEAK component must be a numeric identifier, but is: '${_ARGS_TWEAK}'" PARENT_SCOPE)
|
||||
set(${OUT_VAR}_ERROR "TWEAK component must be a numeric identifier, but is: '${_32070faa_TWEAK}'" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Do we have the pre-release component, and is it valid?
|
||||
if(DEFINED _ARGS_PRERELEASE)
|
||||
string(STRIP "${_ARGS_PRERELEASE}" _ARGS_PRERELEASE)
|
||||
list(JOIN _ARGS_PRERELEASE "." _ARGS_PRERELEASE)
|
||||
if(_ARGS_PRERELEASE STREQUAL "")
|
||||
unset(_ARGS_PRERELEASE)
|
||||
elseif(_ARGS_PRERELEASE MATCHES [[^[a-zA-Z0-9]+[a-zA-Z0-9\-\.]*$]])
|
||||
if(_ARGS_COMPRESS AND (_ARGS_PRERELEASE MATCHES [[[a-zA-Z]+[a-zA-Z0-9\-\.]*$]]))
|
||||
set(_ "${_}${_ARGS_PRERELEASE}")
|
||||
if(_32070faa_PRERELEASE)
|
||||
string(STRIP "${_32070faa_PRERELEASE}" _32070faa_PRERELEASE)
|
||||
list(JOIN _32070faa_PRERELEASE "." _32070faa_PRERELEASE)
|
||||
if(_32070faa_PRERELEASE STREQUAL "")
|
||||
unset(_32070faa_PRERELEASE)
|
||||
elseif(_32070faa_PRERELEASE MATCHES [[^[a-zA-Z0-9]+[a-zA-Z0-9\-\.]*$]])
|
||||
if(_32070faa_COMPRESS AND (_32070faa_PRERELEASE MATCHES [[[a-zA-Z]+[a-zA-Z0-9\-\.]*$]]))
|
||||
set(_feeb1eff "${_feeb1eff}${_32070faa_PRERELEASE}")
|
||||
else()
|
||||
set(_ "${_}-${_ARGS_PRERELEASE}")
|
||||
set(_feeb1eff "${_feeb1eff}-${_32070faa_PRERELEASE}")
|
||||
endif()
|
||||
else()
|
||||
set(${OUT_VAR}_ERROR "PRERELEASE component must be an alphanumeric identifier, but is: '${_ARGS_PRERELEASE}'" PARENT_SCOPE)
|
||||
set(${OUT_VAR}_ERROR "PRERELEASE component must be an alphanumeric identifier, but is: '${_32070faa_PRERELEASE}'" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Do we have the build component, and is it valid?
|
||||
if(DEFINED _ARGS_BUILD)
|
||||
string(STRIP "${_ARGS_BUILD}" _ARGS_PRERELEASE)
|
||||
list(JOIN _ARGS_BUILD "." _ARGS_BUILD)
|
||||
if(_ARGS_BUILD STREQUAL "")
|
||||
unset(_ARGS_BUILD)
|
||||
elseif(_ARGS_BUILD MATCHES [[^[a-zA-Z0-9]+[a-zA-Z0-9\-\.]*$]])
|
||||
set(_ "${_}+${_ARGS_BUILD}")
|
||||
if(_32070faa_BUILD)
|
||||
string(STRIP "${_32070faa_BUILD}" _32070faa_PRERELEASE)
|
||||
list(JOIN _32070faa_BUILD "." _32070faa_BUILD)
|
||||
if(_32070faa_BUILD STREQUAL "")
|
||||
unset(_32070faa_BUILD)
|
||||
elseif(_32070faa_BUILD MATCHES [[^[a-zA-Z0-9]+[a-zA-Z0-9\-\.]*$]])
|
||||
set(_feeb1eff "${_feeb1eff}+${_32070faa_BUILD}")
|
||||
else()
|
||||
set(${OUT_VAR}_ERROR "BUILD component must be an alphanumeric identifier, but is: '${_ARGS_BUILD}'" PARENT_SCOPE)
|
||||
set(${OUT_VAR}_ERROR "BUILD component must be an alphanumeric identifier, but is: '${_32070faa_BUILD}'" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(${OUT_VAR} "${_}" PARENT_SCOPE)
|
||||
set(${OUT_VAR} "${_feeb1eff}" PARENT_SCOPE)
|
||||
elseif(ARGV0 STREQUAL "MODIFY")
|
||||
# Requires PARSE and GENERATE.
|
||||
set(_fe7bcddd "")
|
||||
set(_fe7bcddd_MAJOR "")
|
||||
set(_fe7bcddd_MINOR "")
|
||||
set(_fe7bcddd_PATCH "")
|
||||
set(_fe7bcddd_TWEAK "")
|
||||
set(_fe7bcddd_PRERELEASE "")
|
||||
set(_fe7bcddd_BUILD "")
|
||||
set(_fe7bcddd_ERROR "")
|
||||
cmake_parse_arguments(
|
||||
PARSE_ARGV 3
|
||||
_ARGS
|
||||
_fe7bcddd
|
||||
"COMPRESS"
|
||||
"MAJOR;MINOR;PATCH;BUILD;PRERELEASE;COMMIT"
|
||||
"MAJOR;MINOR;PATCH;TWEAK;PRERELEASE;BUILD"
|
||||
""
|
||||
)
|
||||
|
||||
# Helpers
|
||||
macro(modify_version_number)
|
||||
if(DEFINED ${ARGV1})
|
||||
if(${ARGV1})
|
||||
if(${ARGV1} MATCHES "^(\\+|\\-)([0-9]+)$")
|
||||
if(DEFINED ${ARGV0})
|
||||
if(${ARGV0})
|
||||
math(EXPR ${ARGV0} "${${ARGV0}} ${CMAKE_MATCH_1} ${CMAKE_MATCH_2}")
|
||||
else()
|
||||
math(EXPR ${ARGV0} "0 ${CMAKE_MATCH_1} ${CMAKE_MATCH_2}")
|
||||
@@ -269,145 +289,173 @@ function(version)
|
||||
endmacro()
|
||||
|
||||
# Parse the given version.
|
||||
version(PARSE _TEMP "${ARGV2}")
|
||||
if(DEFINED _TEMP_ERROR)
|
||||
set(${OUT_VAR}_ERROR ${_TEMP_ERROR} PARENT_SCOPE)
|
||||
set(_df8abcce "")
|
||||
set(_df8abcce_MAJOR "")
|
||||
set(_df8abcce_MINOR "")
|
||||
set(_df8abcce_PATCH "")
|
||||
set(_df8abcce_TWEAK "")
|
||||
set(_df8abcce_PRERELEASE "")
|
||||
set(_df8abcce_BUILD "")
|
||||
set(_df8abcce_ERROR "")
|
||||
version(PARSE _df8abcce "${ARGV2}")
|
||||
if(_df8abcce_ERROR)
|
||||
set(${OUT_VAR}_ERROR ${_df8abcce_ERROR} PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Modify core version components
|
||||
modify_version_number(_TEMP_MAJOR _ARGS_MAJOR)
|
||||
modify_version_number(_TEMP_MINOR _ARGS_MINOR)
|
||||
modify_version_number(_TEMP_PATCH _ARGS_PATCH)
|
||||
modify_version_number(_TEMP_TWEAK _ARGS_TWEAK)
|
||||
modify_version_number(_df8abcce_MAJOR _fe7bcddd_MAJOR)
|
||||
modify_version_number(_df8abcce_MINOR _fe7bcddd_MINOR)
|
||||
modify_version_number(_df8abcce_PATCH _fe7bcddd_PATCH)
|
||||
modify_version_number(_df8abcce_TWEAK _fe7bcddd_TWEAK)
|
||||
|
||||
# Replace other components if defined.
|
||||
if(DEFINED _ARGS_PRERELEASE)
|
||||
set(_TEMP_PRERELEASE "${_ARGS_PRERELEASE}")
|
||||
if(_fe7bcddd_PRERELEASE)
|
||||
set(_df8abcce_PRERELEASE "${_fe7bcddd_PRERELEASE}")
|
||||
endif()
|
||||
if(DEFINED _ARGS_BUILD)
|
||||
set(_TEMP_BUILD "${_ARGS_BUILD}")
|
||||
if(_fe7bcddd_BUILD)
|
||||
set(_df8abcce_BUILD "${_fe7bcddd_BUILD}")
|
||||
endif()
|
||||
|
||||
# Generate a new version.
|
||||
set(_ARGS "")
|
||||
if(DEFINED _TEMP_MAJOR AND (NOT _TEMP_MAJOR STREQUAL ""))
|
||||
set(_ARGS "${_ARGS} MAJOR \"${_TEMP_MAJOR}\"")
|
||||
set(_fe7bcddd_GEN "")
|
||||
if(_df8abcce_MAJOR AND (NOT _df8abcce_MAJOR STREQUAL ""))
|
||||
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} MAJOR \"${_df8abcce_MAJOR}\"")
|
||||
endif()
|
||||
if(DEFINED _TEMP_MINOR AND (NOT _TEMP_MINOR STREQUAL ""))
|
||||
set(_ARGS "${_ARGS} MINOR \"${_TEMP_MINOR}\"")
|
||||
if(_df8abcce_MINOR AND (NOT _df8abcce_MINOR STREQUAL ""))
|
||||
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} MINOR \"${_df8abcce_MINOR}\"")
|
||||
endif()
|
||||
if(DEFINED _TEMP_PATCH AND (NOT _TEMP_PATCH STREQUAL ""))
|
||||
set(_ARGS "${_ARGS} PATCH \"${_TEMP_PATCH}\"")
|
||||
if(_df8abcce_PATCH AND (NOT _df8abcce_PATCH STREQUAL ""))
|
||||
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} PATCH \"${_df8abcce_PATCH}\"")
|
||||
endif()
|
||||
if(DEFINED _TEMP_TWEAK AND (NOT _TEMP_TWEAK STREQUAL ""))
|
||||
set(_ARGS "${_ARGS} TWEAK \"${_TEMP_TWEAK}\"")
|
||||
if(_df8abcce_TWEAK AND (NOT _df8abcce_TWEAK STREQUAL ""))
|
||||
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} TWEAK \"${_df8abcce_TWEAK}\"")
|
||||
endif()
|
||||
if(DEFINED _TEMP_PRERELEASE AND (NOT _TEMP_PRERELEASE STREQUAL ""))
|
||||
set(_ARGS "${_ARGS} PRERELEASE \"${_TEMP_PRERELEASE}\"")
|
||||
if(_df8abcce_PRERELEASE AND (NOT _df8abcce_PRERELEASE STREQUAL ""))
|
||||
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} PRERELEASE \"${_df8abcce_PRERELEASE}\"")
|
||||
endif()
|
||||
if(DEFINED _TEMP_BUILD AND (NOT _TEMP_BUILD STREQUAL ""))
|
||||
set(_ARGS "${_ARGS} BUILD \"${_TEMP_BUILD}\"")
|
||||
if(_df8abcce_BUILD AND (NOT _df8abcce_BUILD STREQUAL ""))
|
||||
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} BUILD \"${_df8abcce_BUILD}\"")
|
||||
endif()
|
||||
if(DEFINED _ARGS_COMPRESS)
|
||||
set(_ARGS "${_ARGS} COMPRESS")
|
||||
if(_fe7bcddd_COMPRESS)
|
||||
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} COMPRESS")
|
||||
endif()
|
||||
cmake_language(EVAL CODE "version(GENERATE _TEMP ${_ARGS})")
|
||||
if(DEFINED _TEMP_ERROR)
|
||||
set(${OUT_VAR}_ERROR ${_TEMP_ERROR} PARENT_SCOPE)
|
||||
cmake_language(EVAL CODE "version(GENERATE _df8abcce ${_fe7bcddd_GEN})")
|
||||
if(_df8abcce_ERROR)
|
||||
set(${OUT_VAR}_ERROR ${_df8abcce_ERROR} PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
set(${OUT_VAR} "${_TEMP}" PARENT_SCOPE)
|
||||
set(${OUT_VAR} "${_df8abcce}" PARENT_SCOPE)
|
||||
elseif(ARGV0 STREQUAL "COMPARE")
|
||||
# Requires PARSE.
|
||||
|
||||
# Parse first version
|
||||
version(PARSE _A "${ARGV2}")
|
||||
if(DEFINED _A_ERROR)
|
||||
set(${OUT_VAR}_ERROR ${_A_ERROR} PARENT_SCOPE)
|
||||
set(_00fdeadb "")
|
||||
set(_00fdeadb_MAJOR "")
|
||||
set(_00fdeadb_MINOR "")
|
||||
set(_00fdeadb_PATCH "")
|
||||
set(_00fdeadb_TWEAK "")
|
||||
set(_00fdeadb_PRERELEASE "")
|
||||
set(_00fdeadb_BUILD "")
|
||||
set(_00fdeadb_ERROR "")
|
||||
version(PARSE _00fdeadb "${ARGV2}")
|
||||
if(_00fdeadb_ERROR)
|
||||
set(${OUT_VAR}_ERROR ${_00fdeadb_ERROR} PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Parse second version
|
||||
version(PARSE _B "${ARGV3}")
|
||||
if(DEFINED _B_ERROR)
|
||||
set(${OUT_VAR}_ERROR ${_B_ERROR} PARENT_SCOPE)
|
||||
set(_ca75feel "")
|
||||
set(_ca75feel_MAJOR "")
|
||||
set(_ca75feel_MINOR "")
|
||||
set(_ca75feel_PATCH "")
|
||||
set(_ca75feel_TWEAK "")
|
||||
set(_ca75feel_PRERELEASE "")
|
||||
set(_ca75feel_BUILD "")
|
||||
set(_ca75feel_ERROR "")
|
||||
version(PARSE _ca75feel "${ARGV3}")
|
||||
if(_ca75feel_ERROR)
|
||||
set(${OUT_VAR}_ERROR ${_ca75feel_ERROR} PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Major
|
||||
if(_A_MAJOR GREATER _B_MAJOR)
|
||||
if(_00fdeadb_MAJOR GREATER _ca75feel_MAJOR)
|
||||
set(${OUT_VAR} ">MAJOR" PARENT_SCOPE)
|
||||
return()
|
||||
elseif(_A_MAJOR LESS _B_MAJOR)
|
||||
elseif(_00fdeadb_MAJOR LESS _ca75feel_MAJOR)
|
||||
set(${OUT_VAR} "<MAJOR" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Minor
|
||||
if(_A_MINOR GREATER _B_MINOR)
|
||||
if(_00fdeadb_MINOR GREATER _ca75feel_MINOR)
|
||||
set(${OUT_VAR} ">MINOR" PARENT_SCOPE)
|
||||
return()
|
||||
elseif(_A_MINOR LESS _B_MINOR)
|
||||
elseif(_00fdeadb_MINOR LESS _ca75feel_MINOR)
|
||||
set(${OUT_VAR} "<MINOR" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Patch
|
||||
if((DEFINED _A_PATCH OR DEFINED _B_PATCH) AND ((NOT DEFINED _A_PATCH) OR (NOT DEFINED _B_PATCH)))
|
||||
if(DEFINED _A_PATCH)
|
||||
set(${OUT_VAR} "+PATCH" PARENT_SCOPE)
|
||||
else()
|
||||
set(${OUT_VAR} "-PATCH" PARENT_SCOPE)
|
||||
endif()
|
||||
return()
|
||||
elseif(_A_PATCH GREATER _B_PATCH)
|
||||
if(_00fdeadb_PATCH GREATER _ca75feel_PATCH)
|
||||
set(${OUT_VAR} ">PATCH" PARENT_SCOPE)
|
||||
return()
|
||||
elseif(_A_PATCH LESS _B_PATCH)
|
||||
elseif(_00fdeadb_PATCH LESS _ca75feel_PATCH)
|
||||
set(${OUT_VAR} "<PATCH" PARENT_SCOPE)
|
||||
return()
|
||||
elseif((_00fdeadb_PATCH STREQUAL "") OR (_ca75feel_PATCH STREQUAL ""))
|
||||
if(_00fdeadb_PATCH)
|
||||
set(${OUT_VAR} "+PATCH" PARENT_SCOPE)
|
||||
return()
|
||||
elseif(_ca75feel_PATCH)
|
||||
set(${OUT_VAR} "-PATCH" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Tweak
|
||||
if((DEFINED _A_TWEAK OR DEFINED _B_TWEAK) AND ((NOT DEFINED _A_TWEAK) OR (NOT DEFINED _B_TWEAK)))
|
||||
if(DEFINED _A_TWEAK)
|
||||
set(${OUT_VAR} "+TWEAK" PARENT_SCOPE)
|
||||
else()
|
||||
set(${OUT_VAR} "-TWEAK" PARENT_SCOPE)
|
||||
endif()
|
||||
return()
|
||||
elseif(_A_TWEAK GREATER _B_TWEAK)
|
||||
if(_00fdeadb_TWEAK GREATER _ca75feel_TWEAK)
|
||||
set(${OUT_VAR} ">TWEAK" PARENT_SCOPE)
|
||||
return()
|
||||
elseif(_A_TWEAK LESS _B_TWEAK)
|
||||
elseif(_00fdeadb_TWEAK LESS _ca75feel_TWEAK)
|
||||
set(${OUT_VAR} "<TWEAK" PARENT_SCOPE)
|
||||
return()
|
||||
elseif((_00fdeadb_TWEAK STREQUAL "") OR (_ca75feel_TWEAK STREQUAL ""))
|
||||
if(_00fdeadb_TWEAK)
|
||||
set(${OUT_VAR} "+TWEAK" PARENT_SCOPE)
|
||||
return()
|
||||
elseif(_ca75feel_TWEAK)
|
||||
set(${OUT_VAR} "-TWEAK" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Pre-Release
|
||||
if((DEFINED _A_PRERELEASE) AND (DEFINED _B_PRERELEASE) AND (NOT (_A_PRERELEASE STREQUAL _B_PRERELEASE)))
|
||||
set(${OUT_VAR} "PRERELEASE" PARENT_SCOPE)
|
||||
return()
|
||||
elseif((DEFINED _A_PRERELEASE OR DEFINED _B_PRERELEASE) AND ((NOT DEFINED _A_PRERELEASE) OR (NOT DEFINED _B_PRERELEASE)))
|
||||
if(DEFINED _A_PRERELEASE)
|
||||
if((_00fdeadb_PRERELEASE STREQUAL "") OR (_ca75feel_PRERELEASE STREQUAL ""))
|
||||
if(_00fdeadb_PRERELEASE)
|
||||
set(${OUT_VAR} "+PRERELEASE" PARENT_SCOPE)
|
||||
else()
|
||||
return()
|
||||
elseif(_ca75feel_PRERELEASE)
|
||||
set(${OUT_VAR} "-PRERELEASE" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
elseif(NOT (_00fdeadb_PRERELEASE STREQUAL _ca75feel_PRERELEASE))
|
||||
set(${OUT_VAR} "PRERELEASE" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Build
|
||||
if((DEFINED _A_BUILD) AND (DEFINED _B_BUILD) AND (NOT (_A_BUILD STREQUAL _B_BUILD)))
|
||||
set(${OUT_VAR} "BUILD" PARENT_SCOPE)
|
||||
return()
|
||||
elseif((DEFINED _A_BUILD OR DEFINED _B_BUILD) AND ((NOT DEFINED _A_BUILD) OR (NOT DEFINED _B_BUILD)))
|
||||
if(DEFINED _A_BUILD)
|
||||
if((_00fdeadb_BUILD STREQUAL "") OR (_ca75feel_BUILD STREQUAL ""))
|
||||
if(_00fdeadb_BUILD)
|
||||
set(${OUT_VAR} "+BUILD" PARENT_SCOPE)
|
||||
else()
|
||||
return()
|
||||
elseif(_ca75feel_BUILD)
|
||||
set(${OUT_VAR} "-BUILD" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
elseif(NOT (_00fdeadb_BUILD STREQUAL _ca75feel_BUILD))
|
||||
set(${OUT_VAR} "BUILD" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user