Files
CMake/Tests/RunCMake/InstallPackageInfo/VersionCheck.cmake
Matthew Woehlke cc508826b4 CPS: Validate package version
Add version validation to cmExportPackageInfoGenerator. Specifically, if
a package uses the "simple" version schema (which is the default if no
schema is specified), validate that the specified version actually
conforms to the schema and issue an error if it does not. Also, issue a
warning if the schema is not recognized.
2025-11-26 17:04:26 -05:00

39 lines
952 B
CMake

add_library(foo INTERFACE)
install(TARGETS foo EXPORT foo DESTINATION .)
# Try exporting a 'properly' simple version.
install(PACKAGE_INFO foo1 EXPORT foo VERSION 1.2.3)
# Try exporting a version with many components.
install(PACKAGE_INFO foo2 EXPORT foo VERSION 1.21.23.33.37.42.9.0.12)
# Try exporting a version with a label.
install(PACKAGE_INFO foo3 EXPORT foo VERSION "1.2.3+git1234abcd")
# Try exporting a version with a different label.
install(PACKAGE_INFO foo4 EXPORT foo VERSION "1.2.3-0.example")
# Try exporting with the schema explicitly specified.
install(
PACKAGE_INFO foo5
EXPORT foo
VERSION "1.2.3-0.example"
VERSION_SCHEMA "simple"
)
# Try exporting with a custom-schema version.
install(
PACKAGE_INFO foo6
EXPORT foo
VERSION "foo!test"
VERSION_SCHEMA "custom"
)
# Try exporting with a recognized but not-checked schema.
install(
PACKAGE_INFO foo7
EXPORT foo
VERSION "invalid"
VERSION_SCHEMA "pep440"
)