Files
CMake/Tests/RunCMake/ExportPackageInfo/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
945 B
CMake

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