cmExportPackageInfoGenerator: Fix version properties
Fix a small bug in cmExportPackageInfoGenerator that caused extended version properties ("compat_version", "version_schema")) to be emitted when empty. Add a test to ensure this is working as intended. Fixes: #26264
This commit is contained in:
parent
773eff6d8e
commit
f04dd93c47
@ -106,10 +106,10 @@ Json::Value cmExportPackageInfoGenerator::GeneratePackageInfo() const
|
||||
|
||||
if (!this->PackageVersion.empty()) {
|
||||
package["version"] = this->PackageVersion;
|
||||
if (!this->PackageVersion.empty()) {
|
||||
if (!this->PackageVersionCompat.empty()) {
|
||||
package["compat_version"] = this->PackageVersionCompat;
|
||||
}
|
||||
if (!this->PackageVersion.empty()) {
|
||||
if (!this->PackageVersionSchema.empty()) {
|
||||
package["version_schema"] = this->PackageVersionSchema;
|
||||
}
|
||||
}
|
||||
|
21
Tests/RunCMake/PackageInfo/MinimalVersion-check.cmake
Normal file
21
Tests/RunCMake/PackageInfo/MinimalVersion-check.cmake
Normal file
@ -0,0 +1,21 @@
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/Assertions.cmake)
|
||||
|
||||
set(out_dir "${RunCMake_BINARY_DIR}/MinimalVersion-build/CMakeFiles/Export/510c5684a4a8a792eadfb55bc9744983")
|
||||
|
||||
file(READ "${out_dir}/foo1.cps" content)
|
||||
expect_value("${content}" "foo1" "name")
|
||||
expect_value("${content}" "1.0" "version")
|
||||
expect_missing("${content}" "compat_version")
|
||||
expect_missing("${content}" "version_schema")
|
||||
|
||||
file(READ "${out_dir}/foo2.cps" content)
|
||||
expect_value("${content}" "foo2" "name")
|
||||
expect_value("${content}" "1.5" "version")
|
||||
expect_value("${content}" "1.0" "compat_version")
|
||||
expect_missing("${content}" "version_schema")
|
||||
|
||||
file(READ "${out_dir}/foo3.cps" content)
|
||||
expect_value("${content}" "foo3" "name")
|
||||
expect_value("${content}" "1.0" "version")
|
||||
expect_missing("${content}" "compat_version")
|
||||
expect_value("${content}" "simple" "version_schema")
|
19
Tests/RunCMake/PackageInfo/MinimalVersion.cmake
Normal file
19
Tests/RunCMake/PackageInfo/MinimalVersion.cmake
Normal file
@ -0,0 +1,19 @@
|
||||
add_library(foo INTERFACE)
|
||||
install(TARGETS foo EXPORT foo DESTINATION .)
|
||||
|
||||
install(PACKAGE_INFO foo1
|
||||
EXPORT foo
|
||||
VERSION 1.0
|
||||
DESTINATION cps)
|
||||
|
||||
install(PACKAGE_INFO foo2
|
||||
EXPORT foo
|
||||
VERSION 1.5
|
||||
COMPAT_VERSION 1.0
|
||||
DESTINATION cps)
|
||||
|
||||
install(PACKAGE_INFO foo3
|
||||
EXPORT foo
|
||||
VERSION 1.0
|
||||
VERSION_SCHEMA simple
|
||||
DESTINATION cps)
|
@ -27,6 +27,7 @@ run_cmake(Appendix)
|
||||
run_cmake(InterfaceProperties)
|
||||
run_cmake(Metadata)
|
||||
run_cmake(Minimal)
|
||||
run_cmake(MinimalVersion)
|
||||
run_cmake(LowerCaseFile)
|
||||
run_cmake(Requirements)
|
||||
run_cmake(TargetTypes)
|
||||
|
Loading…
Reference in New Issue
Block a user