2021-01-21 04:07:41 +08:00
|
|
|
#[===[.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)
|
2021-07-21 01:24:58 +08:00
|
|
|
cmake_parse_arguments(PARSE_ARGV 0 arg "" "VERSION" "")
|
2021-07-31 03:57:07 +08:00
|
|
|
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."
|
2021-01-21 04:07:41 +08:00
|
|
|
)
|
|
|
|
endif()
|
2021-07-31 03:57:07 +08:00
|
|
|
if(NOT DEFINED arg_VERSION)
|
|
|
|
message(FATAL_ERROR "VERSION must be specified")
|
|
|
|
endif()
|
2021-01-21 04:07:41 +08:00
|
|
|
|
2021-07-21 01:24:58 +08:00
|
|
|
set(vcpkg_date_regex "^[12][0-9][0-9][0-9]-[01][0-9]-[0-3][0-9]$")
|
2021-07-31 03:57:07 +08:00
|
|
|
if(NOT "${VCPKG_BASE_VERSION}" MATCHES "${vcpkg_date_regex}")
|
2021-01-21 04:07:41 +08:00
|
|
|
message(FATAL_ERROR
|
2021-07-21 01:24:58 +08:00
|
|
|
"vcpkg internal failure; VCPKG_BASE_VERSION (${VCPKG_BASE_VERSION}) was not a valid date."
|
2021-07-31 03:57:07 +08:00
|
|
|
)
|
2021-01-21 04:07:41 +08:00
|
|
|
endif()
|
|
|
|
|
2021-07-31 03:57:07 +08:00
|
|
|
if(NOT "${arg_VERSION}" MATCHES "${vcpkg_date_regex}")
|
2021-01-21 04:07:41 +08:00
|
|
|
message(FATAL_ERROR
|
2021-07-31 03:57:07 +08:00
|
|
|
"VERSION (${arg_VERSION}) was not a valid date - expected something of the form 'YYYY-MM-DD'"
|
|
|
|
)
|
2021-01-21 04:07:41 +08:00
|
|
|
endif()
|
|
|
|
|
2021-07-21 01:24:58 +08:00
|
|
|
string(REPLACE "-" "." VCPKG_BASE_VERSION_as_dotted "${VCPKG_BASE_VERSION}")
|
|
|
|
string(REPLACE "-" "." arg_VERSION_as_dotted "${arg_VERSION}")
|
2021-01-21 04:07:41 +08:00
|
|
|
|
2021-07-31 03:57:07 +08:00
|
|
|
if("${VCPKG_BASE_VERSION_as_dotted}" VERSION_LESS "${arg_VERSION_as_dotted}")
|
2021-01-21 04:07:41 +08:00
|
|
|
message(FATAL_ERROR
|
|
|
|
"Your vcpkg executable is from ${VCPKG_BASE_VERSION} which is older than required by the caller "
|
2021-07-21 01:24:58 +08:00
|
|
|
"of vcpkg_minimum_required(VERSION ${arg_VERSION}). "
|
2021-01-21 04:07:41 +08:00
|
|
|
"Please re-acquire vcpkg by running bootstrap-vcpkg."
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endfunction()
|