aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2017-11-21 19:58:38 -0800
committerRobert Schumacher <roschuma@microsoft.com>2017-11-21 19:58:38 -0800
commit480f50a7b0e050885fa79eb6c2ffc85e0a4e7649 (patch)
treea1a96141366cedddf5edb9a436f61c94cfc0f6d7
parent8e410e9e450f8103a7df19f9f643f52ee7354b4d (diff)
downloadvcpkg-480f50a7b0e050885fa79eb6c2ffc85e0a4e7649.tar.gz
vcpkg-480f50a7b0e050885fa79eb6c2ffc85e0a4e7649.zip
[vcpkg] Improve cmake targets output
-rw-r--r--toolsrc/src/vcpkg/install.cpp51
1 files changed, 27 insertions, 24 deletions
diff --git a/toolsrc/src/vcpkg/install.cpp b/toolsrc/src/vcpkg/install.cpp
index f48b04d68..249e36e0f 100644
--- a/toolsrc/src/vcpkg/install.cpp
+++ b/toolsrc/src/vcpkg/install.cpp
@@ -579,15 +579,17 @@ namespace vcpkg::Install
auto files = fs.read_lines(paths.listfile_path(bpgh));
if (auto p_lines = files.get())
{
+ std::map<std::string, std::vector<std::string>> library_targets;
+
for (auto&& suffix : *p_lines)
{
- if (Strings::case_insensitive_ascii_find(suffix, "/share/") != suffix.end())
+ if (Strings::case_insensitive_ascii_find(suffix, "/share/") != suffix.end() &&
+ suffix.substr(suffix.size() - 6) == ".cmake")
{
- std::vector<std::string> library_targets;
-
// File is inside the share folder
auto path = paths.installed / suffix;
auto maybe_contents = fs.read_contents(path);
+ auto find_package_name = path.parent_path().filename().u8string();
if (auto p_contents = maybe_contents.get())
{
std::sregex_iterator next(p_contents->begin(), p_contents->end(), cmake_library_regex);
@@ -596,37 +598,40 @@ namespace vcpkg::Install
while (next != last)
{
auto match = *next;
- library_targets.push_back(match[1]);
+ library_targets[find_package_name].push_back(match[1]);
++next;
}
}
+ }
+ }
- if (library_targets.empty())
- {
- }
- else if (library_targets.size() <= 4)
+ if (library_targets.empty())
+ {
+ }
+ else
+ {
+ System::println("The package %s provides CMake targets:\n", bpgh.spec);
+
+ for (auto&& library_target_pair : library_targets)
+ {
+ if (library_target_pair.second.size() <= 4)
{
- System::println("The package %s provides CMake targets:\n"
- "\n"
- " find_package(%s REQUIRED)\n"
+ System::println(" find_package(%s REQUIRED)\n"
" target_link_libraries(main PRIVATE %s)\n",
- bpgh.spec,
- path.parent_path().filename().u8string(),
- Strings::join(" ", library_targets));
+ library_target_pair.first,
+ Strings::join(" ", library_target_pair.second));
}
else
{
- auto omitted = library_targets.size() - 4;
- library_targets.erase(library_targets.begin() + 4, library_targets.end());
- System::println("The package %s provides CMake targets:\n"
- "\n"
- " find_package(%s REQUIRED)\n"
+ auto omitted = library_target_pair.second.size() - 4;
+ library_target_pair.second.erase(library_target_pair.second.begin() + 4,
+ library_target_pair.second.end());
+ System::println(" find_package(%s REQUIRED)\n"
" # Note: %d targets were omitted\n"
" target_link_libraries(main PRIVATE %s)\n",
- bpgh.spec,
- path.parent_path().filename().u8string(),
+ library_target_pair.first,
omitted,
- Strings::join(" ", library_targets));
+ Strings::join(" ", library_target_pair.second));
}
}
}
@@ -730,8 +735,6 @@ namespace vcpkg::Install
summary.print();
}
- auto& fs = paths.get_filesystem();
-
for (auto&& result : summary.results)
{
if (!result.action) continue;