mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
CPS: Add package requirements for per-config link dependencies
Fixes: #27987
This commit is contained in:
@@ -117,14 +117,9 @@ bool cmExportInstallPackageInfoGenerator::GenerateMainFile(std::ostream& os)
|
||||
}
|
||||
}
|
||||
|
||||
this->GeneratePackageRequires(root);
|
||||
|
||||
// Write the primary packing information file.
|
||||
this->WritePackageInfo(root, os);
|
||||
|
||||
// Generate per-configuration files before the main file so that
|
||||
// processing link-dependent targets populates package requirements.
|
||||
bool result = true;
|
||||
|
||||
// Generate an import file for each configuration.
|
||||
if (this->RequiresConfigFiles) {
|
||||
for (std::string const& c : this->Configurations) {
|
||||
if (!this->GenerateImportFileConfig(c)) {
|
||||
@@ -133,6 +128,11 @@ bool cmExportInstallPackageInfoGenerator::GenerateMainFile(std::ostream& os)
|
||||
}
|
||||
}
|
||||
|
||||
this->GeneratePackageRequires(root);
|
||||
|
||||
// Write the primary packing information file.
|
||||
this->WritePackageInfo(root, os);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/Assertions.cmake)
|
||||
|
||||
set(out_dir "${RunCMake_BINARY_DIR}/PrivateLinkDependency-build")
|
||||
|
||||
file(READ "${out_dir}/cps/mylib/mylib.cps" content)
|
||||
|
||||
# Private link dependency must appear in package requires
|
||||
expect_array("${content}" 1 "requires" "libdep" "components")
|
||||
expect_value("${content}" "libdep" "requires" "libdep" "components" 0)
|
||||
|
||||
# And in per-config dyld_requires
|
||||
expect_array("${content}" 1
|
||||
"components" "mylib" "configurations" "generic" "dyld_requires")
|
||||
expect_value("${content}" "libdep:libdep"
|
||||
"components" "mylib" "configurations" "generic" "dyld_requires" 0)
|
||||
@@ -0,0 +1,20 @@
|
||||
project(PrivateLinkDependency CXX)
|
||||
|
||||
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
if(_isMultiConfig)
|
||||
set(CMAKE_CONFIGURATION_TYPES "generic" CACHE STRING "" FORCE)
|
||||
else()
|
||||
set(CMAKE_BUILD_TYPE "generic" CACHE STRING "" FORCE)
|
||||
endif()
|
||||
|
||||
find_package(
|
||||
libdep REQUIRED CONFIG
|
||||
NO_DEFAULT_PATH
|
||||
PATHS ${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
add_library(mylib SHARED foo.cxx)
|
||||
target_link_libraries(mylib PRIVATE libdep::libdep)
|
||||
|
||||
install(TARGETS mylib EXPORT mylib DESTINATION .)
|
||||
export(PACKAGE_INFO mylib EXPORT mylib)
|
||||
@@ -29,6 +29,7 @@ run_cmake(MinimalVersion)
|
||||
run_cmake(LowerCaseFile)
|
||||
run_cmake(Requirements)
|
||||
run_cmake(LinkDependentLibraries)
|
||||
run_cmake(PrivateLinkDependency)
|
||||
run_cmake(ExportSymbolicComponent)
|
||||
run_cmake(TargetTypes)
|
||||
run_cmake(DependsMultiple)
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"components" :
|
||||
{
|
||||
"libdep" :
|
||||
{
|
||||
"type" : "dylib"
|
||||
}
|
||||
},
|
||||
"cps_path" : "@prefix@/cps/libdep",
|
||||
"cps_version" : "0.14.1",
|
||||
"name" : "libdep"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"components" :
|
||||
{
|
||||
"libdep" :
|
||||
{
|
||||
"link_location" : "@prefix@/libdep.lib",
|
||||
"location" : "@prefix@/libdep.dll"
|
||||
}
|
||||
},
|
||||
"configuration" : "generic",
|
||||
"name" : "libdep"
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/Assertions.cmake)
|
||||
|
||||
set(out_dir "${RunCMake_BINARY_DIR}/PrivateLinkDependency-build/CMakeFiles/Export/510c5684a4a8a792eadfb55bc9744983")
|
||||
|
||||
file(READ "${out_dir}/mylib.cps" content)
|
||||
|
||||
# Private link dependency must appear in package requires
|
||||
expect_array("${content}" 1 "requires" "libdep" "components")
|
||||
expect_value("${content}" "libdep" "requires" "libdep" "components" 0)
|
||||
|
||||
# And in per-config dyld_requires
|
||||
file(READ "${out_dir}/mylib@generic.cps" content)
|
||||
expect_array("${content}" 1 "components" "mylib" "dyld_requires")
|
||||
expect_value("${content}" "libdep:libdep" "components" "mylib" "dyld_requires" 0)
|
||||
@@ -0,0 +1,20 @@
|
||||
project(PrivateLinkDependency CXX)
|
||||
|
||||
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
if(_isMultiConfig)
|
||||
set(CMAKE_CONFIGURATION_TYPES "generic" CACHE STRING "" FORCE)
|
||||
else()
|
||||
set(CMAKE_BUILD_TYPE "generic" CACHE STRING "" FORCE)
|
||||
endif()
|
||||
|
||||
find_package(
|
||||
libdep REQUIRED CONFIG
|
||||
NO_DEFAULT_PATH
|
||||
PATHS ${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
add_library(mylib SHARED foo.cxx)
|
||||
target_link_libraries(mylib PRIVATE libdep::libdep)
|
||||
|
||||
install(TARGETS mylib EXPORT mylib DESTINATION .)
|
||||
install(PACKAGE_INFO mylib DESTINATION cps EXPORT mylib)
|
||||
@@ -38,6 +38,7 @@ run_cmake(Minimal)
|
||||
run_cmake(MinimalVersion)
|
||||
run_cmake(LowerCaseFile)
|
||||
run_cmake(Requirements)
|
||||
run_cmake(PrivateLinkDependency)
|
||||
run_cmake(TargetTypes)
|
||||
run_cmake(DependsMultiple)
|
||||
run_cmake(DependsMultipleNotInstalled)
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"components" :
|
||||
{
|
||||
"libdep" :
|
||||
{
|
||||
"type" : "dylib"
|
||||
}
|
||||
},
|
||||
"cps_path" : "@prefix@/cps/libdep",
|
||||
"cps_version" : "0.14.1",
|
||||
"name" : "libdep"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"components" :
|
||||
{
|
||||
"libdep" :
|
||||
{
|
||||
"link_location" : "@prefix@/libdep.lib",
|
||||
"location" : "@prefix@/libdep.dll"
|
||||
}
|
||||
},
|
||||
"configuration" : "generic",
|
||||
"name" : "libdep"
|
||||
}
|
||||
Reference in New Issue
Block a user