vcpkg/scripts/cmake/vcpkg_minimum_required.cmake
nicole mazzuca 0e1dc12185
[rollup] Rollup PR 2021-07-16 (#19001)
* [rollup:2021-07-16 1/7] PR #18201 (@JackBoosY)

[vcpkg-cmake] Add check for unused cmake variables

* [rollup:2021-07-16 2/7] PR #18397 (@strega-nil)

[vcpkg_list] add new function

* [rollup:2021-07-16 3/7] PR #18782 (@strega-nil)

[scripts-audit] vcpkg_build_ninja

* [rollup:2021-07-16 4/7] PR #18784 (@strega-nil)

[scripts-audit] vcpkg_minimum_required

* [rollup:2021-07-16 5/7] PR #18785 (@strega-nil)

[scripts-audit] vcpkg_replace_string

* [rollup:2021-07-16 6/7] PR #18786 (@strega-nil)

[scripts-audit] windows scripts

* [rollup:2021-07-16 7/7] PR #18945 (@strega-nil)

[many ports] remove deprecated vcpkg_check_features call [1/5]

Co-authored-by: nicole mazzuca <mazzucan@outlook.com>
Co-authored-by: PhoebeHui <20694052+PhoebeHui@users.noreply.github.com>
2021-07-20 10:24:58 -07:00

50 lines
1.7 KiB
CMake

#[===[.md:
# vcpkg_minimum_required
Asserts that the version of the vcpkg program being used to build a port is later than the supplied date, inclusive.
## Usage
```cmake
vcpkg_minimum_required(VERSION 2021-01-13)
```
## Parameters
### VERSION
The date-version to check against.
#]===]
function(vcpkg_minimum_required)
cmake_parse_arguments(PARSE_ARGV 0 arg "" "VERSION" "")
if (NOT DEFINED VCPKG_BASE_VERSION)
message(FATAL_ERROR
"Your vcpkg executable is outdated and is not compatible with the current CMake scripts. "
"Please re-acquire vcpkg by running bootstrap-vcpkg."
)
endif()
set(vcpkg_date_regex "^[12][0-9][0-9][0-9]-[01][0-9]-[0-3][0-9]$")
if (NOT VCPKG_BASE_VERSION MATCHES "${vcpkg_date_regex}")
message(FATAL_ERROR
"vcpkg internal failure; VCPKG_BASE_VERSION (${VCPKG_BASE_VERSION}) was not a valid date."
)
endif()
if (NOT arg_VERSION MATCHES "${vcpkg_date_regex}")
message(FATAL_ERROR
"VERSION parameter to vcpkg_minimum_required was not a valid date. "
"Comparing with vcpkg tool version ${VCPKG_BASE_VERSION}"
)
endif()
string(REPLACE "-" "." VCPKG_BASE_VERSION_as_dotted "${VCPKG_BASE_VERSION}")
string(REPLACE "-" "." arg_VERSION_as_dotted "${arg_VERSION}")
if (VCPKG_BASE_VERSION_as_dotted VERSION_LESS vcpkg_VERSION_as_dotted)
message(FATAL_ERROR
"Your vcpkg executable is from ${VCPKG_BASE_VERSION} which is older than required by the caller "
"of vcpkg_minimum_required(VERSION ${arg_VERSION}). "
"Please re-acquire vcpkg by running bootstrap-vcpkg."
)
endif()
endfunction()