Skip to content

Commit c7fc654

Browse files
committed
search: CPS_PATH is a prefix, not an absolute path
This means it does not work like pkg-config's `PKG_CONFIG_PATH`, but like CMake's `-DCMAKE_PREFIX_PATH`. See CPS issue: cps-org/cps#45
1 parent 76d15ec commit c7fc654

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

src/search.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,20 @@ namespace search {
7070
}
7171

7272
const std::vector<fs::path> search_paths() {
73-
std::vector<fs::path> paths;
73+
// TODO: Windows paths
74+
// TODO: MacOS paths
75+
std::vector<fs::path> roots;
7476
if (const char * env_c = std::getenv("CPS_PATH")) {
7577
auto && env = utils::split(env_c);
76-
paths.insert(paths.end(), env.begin(), env.end());
78+
roots.insert(roots.end(), env.begin(), env.end());
7779
}
78-
// TODO: lib need to be not hard coded
79-
paths.emplace_back(fs::path{"/usr"} / platform::libdir() / "cps");
80-
paths.emplace_back("/usr/share/cps");
81-
// TODO: Windows paths
82-
// TODO: MacOS paths
80+
roots.emplace_back("/usr");
8381

82+
std::vector<fs::path> paths;
83+
for (auto && root : roots) {
84+
paths.emplace_back(root / platform::libdir() / "cps");
85+
paths.emplace_back(root / "share/cps");
86+
}
8487
return paths;
8588
}
8689

@@ -100,12 +103,11 @@ namespace search {
100103
// dependency?
101104
auto && paths = search_paths();
102105
std::vector<fs::path> found{};
103-
for (auto && prefix : paths) {
106+
for (auto && dir : paths) {
104107
// TODO: <prefix>/<libdir>/cps/<name-like>/
105108
// TODO: <prefix>/share/cps/<name-like>/
106109
// TODO: <prefix>/share/cps/
107110

108-
const fs::path dir = prefix / platform::libdir() / "cps";
109111
if (fs::is_directory(dir)) {
110112
// TODO: <name-like>
111113
const fs::path file = dir / fmt::format("{}.cps", name);

0 commit comments

Comments
 (0)