[M5+] generalize nix_cmake_scan config picker
This commit is contained in:
@@ -136,6 +136,69 @@ TEST_CASE("nix_cmake_scan ignores Config files with no IMPORTED targets",
|
||||
REQUIRE(r.error().code == ErrorCode::ResolutionUnknownPackage);
|
||||
}
|
||||
|
||||
TEST_CASE("nix_cmake_scan strips a leading lib prefix when scoring",
|
||||
"[resolver][nix_cmake_scan]") {
|
||||
// Real layout for nixpkgs `libllvm.dev`. `libllvm` should match
|
||||
// `LLVMConfig.cmake`'s parent dir (`llvm`) after lib-stripping
|
||||
// and beat `polly/PollyConfig.cmake`.
|
||||
auto store = fresh_store();
|
||||
touch_config(store, "llvm/LLVMConfig.cmake",
|
||||
R"(add_library(LLVM SHARED IMPORTED))");
|
||||
touch_config(store, "polly/PollyConfig.cmake",
|
||||
R"(add_library(Polly SHARED IMPORTED))");
|
||||
|
||||
auto r = nix_cmake_scan(store, "libllvm");
|
||||
REQUIRE(r.has_value());
|
||||
REQUIRE(r->find_package == "LLVM CONFIG REQUIRED");
|
||||
REQUIRE(r->config_file.filename() == "LLVMConfig.cmake");
|
||||
}
|
||||
|
||||
TEST_CASE("nix_cmake_scan picks the canonical config from a versioned dir",
|
||||
"[resolver][nix_cmake_scan]") {
|
||||
// Boost ships a top-level `Boost-1.89.0/BoostConfig.cmake` plus
|
||||
// 47 modular component configs at sibling versioned dirs.
|
||||
// After version-suffix stripping the top-level Boost should win.
|
||||
auto store = fresh_store();
|
||||
touch_config(store, "Boost-1.89.0/BoostConfig.cmake",
|
||||
R"(add_library(Boost::headers INTERFACE IMPORTED))");
|
||||
touch_config(store, "boost_atomic-1.89.0/boost_atomic-config.cmake",
|
||||
R"(add_library(Boost::atomic SHARED IMPORTED))");
|
||||
touch_config(store, "boost_filesystem-1.89.0/boost_filesystem-config.cmake",
|
||||
R"(add_library(Boost::filesystem SHARED IMPORTED))");
|
||||
|
||||
auto r = nix_cmake_scan(store, "boost");
|
||||
REQUIRE(r.has_value());
|
||||
REQUIRE(r->find_package == "Boost CONFIG REQUIRED");
|
||||
REQUIRE(r->config_file.filename() == "BoostConfig.cmake");
|
||||
}
|
||||
|
||||
TEST_CASE("nix_cmake_scan ignores satellite configs in multi-config stores",
|
||||
"[resolver][nix_cmake_scan]") {
|
||||
// Mirrors `protobuf` which ships protobuf-config.cmake plus an
|
||||
// unrelated utf8_range-config.cmake under the same prefix tree.
|
||||
auto store = fresh_store();
|
||||
touch_config(store, "protobuf/protobuf-config.cmake",
|
||||
R"(add_library(protobuf::libprotobuf SHARED IMPORTED))");
|
||||
touch_config(store, "utf8_range/utf8_range-config.cmake",
|
||||
R"(add_library(utf8_range::utf8_range SHARED IMPORTED))");
|
||||
|
||||
auto r = nix_cmake_scan(store, "protobuf");
|
||||
REQUIRE(r.has_value());
|
||||
REQUIRE(r->find_package == "protobuf CONFIG REQUIRED");
|
||||
}
|
||||
|
||||
TEST_CASE("nix_cmake_scan normalizes case for spelling variants",
|
||||
"[resolver][nix_cmake_scan]") {
|
||||
// grpc ships `gRPCConfig.cmake` under `lib/cmake/grpc/`.
|
||||
auto store = fresh_store();
|
||||
touch_config(store, "grpc/gRPCConfig.cmake",
|
||||
R"(add_library(gRPC::grpc++ SHARED IMPORTED))");
|
||||
|
||||
auto r = nix_cmake_scan(store, "grpc");
|
||||
REQUIRE(r.has_value());
|
||||
REQUIRE(r->find_package == "gRPC CONFIG REQUIRED");
|
||||
}
|
||||
|
||||
TEST_CASE("nix_cmake_scan scans sibling *-targets.cmake files",
|
||||
"[resolver][nix_cmake_scan]") {
|
||||
// Mirrors fmt's real on-disk layout: the *-config.cmake is empty of
|
||||
|
||||
Reference in New Issue
Block a user