×ばつ 两个工具链,在一台装了系统 Catch2 v3 的机器上: llvm gcc catch2 ok ok catch2-main ok ok catch2-v2 ok ok catch2-v2-main ok ok ← 此前 llvm 下是 FAIL 80 个描述符 mcpp xpkg parse + lint 全过。 关于 mcpp#290 #183 的描述里我把这条列为"要等 per-version build blocks(mcpp#290)才能修" —— 那个判断下早了。要的不是"知道自己是哪个版本",只是一个系统装不出来的探针。 mcpp#290 仍然是更干净的答案:它让这个问题整个消失,而不是换一个探针。这里的探针有它的脆弱面,已写进描述符注释:如果上游哪天改成在树内直接生成而不再发 .in,或某个发行版开始安装模板,就得另找源码专属标记。 顺带一提 CI 抓不到这个:GitHub runner 不装 catch2,-idirafter / __has_include 都没有东西可输。#184 那条 llvm 腿即使装了 libav*-dev,也只覆盖 ffmpeg 这一族。这一类"宿主机装了同名包"的问题,目前只能靠开发机发现。">
Skip to content

Navigation Menu

Sign in
Sign up

fix(pkg): catch2 的 v2/v3 判别不能问系统目录 #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Sunrisepeak merged 1 commit into main from fix/catch2-version-probe-ignores-system
Aug 8, 2026
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions pkgs/c/compat.catch2.lua
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@
--
-- Features (sources-only gate):
-- `main` — compiles a GENERATED TU supplying a default entry point. It
-- branches on __has_include(<catch2/catch_all.hpp>), which exists only in
-- v3, to pick the v3 (Catch::Session) or v2 (CATCH_CONFIG_MAIN) spelling.
-- Excluded by default; request `features = ["main"]`.
-- branches on __has_include(<catch2/catch_user_config.hpp.in>) — upstream's
-- CMake template, present only in v3's SOURCE tree and never installed — to
-- pick the v3 (Catch::Session) or v2 (CATCH_CONFIG_MAIN) spelling. The probe
-- has to be source-only because __has_include searches the system dirs too;
-- see the note above the generated TU. Excluded by default; request
-- `features = ["main"]`.
--
-- It deliberately does NOT point at upstream's
-- src/catch2/internal/catch_main.cpp. That file is matched by the sources
Expand Down Expand Up @@ -148,7 +151,7 @@ package = {
-- and can never be used to detect v2. (On v3 it would be found
-- and then fail in #include_next, since there is no upstream
-- catch.hpp behind it — but __has_include never gets that far.)
-- The existing discriminator probes catch_all.hpp instead, which
-- The discriminator probes catch_user_config.hpp.in instead, which
-- is unaffected. See the header comment for why per-version
-- blocks (mcpp#290) are the real answer here.
["mcpp_generated/catch2/catch.hpp"] = [==[
Expand Down Expand Up @@ -187,8 +190,27 @@ int mcpp_compat_catch2_anchor(void) { return 0; }
]==],
-- The `main` feature's TU. See the header comment for why this is
-- generated rather than upstream's catch_main.cpp.
-- The discriminator probes a file upstream ships as a CMake
-- TEMPLATE and never installs: `catch_user_config.hpp.in`. It has
-- to be something a SYSTEM Catch2 cannot supply, because
-- __has_include searches the system dirs too — and the obvious
-- probe, catch_all.hpp, is installed by every distro's catch2
-- package. On a box with system Catch2 v3 present, a v2 consumer
-- was answered "v3", compiled the Catch::Session entry point and
-- died at link time on undefined Catch::Session::Session().
--
-- Verified on clang 22.1.8 and gcc 16.1.0, all three cases:
-- vendored v3 on -I -> v3 (both probes agree)
-- vendored v2 on -I -> v2 (catch_all.hpp says v3: the bug)
-- only system v3 -> v2 (catch_all.hpp says v3)
--
-- Re-check when bumping v3: if upstream ever materialises this
-- file in-tree instead of shipping the .in, or a distro starts
-- installing the template, the probe needs another source-only
-- marker. mcpp#290's per-version build blocks retire the whole
-- question by naming the major outright.
["mcpp_generated/catch2_main.cpp"] = [==[
#if __has_include(<catch2/catch_all.hpp>)
#if __has_include(<catch2/catch_user_config.hpp.in>)
// Catch2 v3: the library is compiled in; just drive a session.
# include <catch2/catch_session.hpp>
int main(int argc, char* argv[]) { return Catch::Session().run(argc, argv); }
Expand Down
Loading

AltStyle によって変換されたページ (->オリジナル) /