我如何通过克隆其存储库并将其 src 复制到我的项目来使用 catch2?

How do I use catch2 just by cloning its repository and copying its src to my project?

我正在尝试为准系统项目获取 catch2 运行ning 只是为了熟悉它,但到目前为止我未能以任何可能的方式安装它。 catch2-git 存储库要么指向您将它与 cmake 一起安装(通过 vcpkg(我不能使用 MSVC,此时不想),要么指向一些 Ubuntu 解决方案。)

我想我应该直接下载 catch2 文件并将其放在本地某处,然后 运行 我的代码并直接包含 .hpp:

#include "../../Catch2/src/catch2/catch_all.hpp"

现在编译器(我使用 gcc 和代码块 ide)会找到 catch_all.hpp 但告诉我它不能包含链接在 catch_all.hpp 中的头文件(首先包含尝试包括 catch_benchmark_all.hpp):

...\Catch2\src\catch2\catch_all.hpp|25|fatal error: catch2/benchmark/catch_benchmark_all.hpp: No such file or directory|

catch_all.hpp 中的 #include 语句如下所示:

#include <catch2/benchmark/catch_benchmark_all.hpp>

现在我假设我的问题的一个答案是使 catch2 中的所有包含路径 inside 成为相对路径,但这真的是他们希望我在这里做的吗?一定有更好的方法,不是吗?

GitHub 页面显示:

Catch2 v3 is being developed!

You are on the devel branch, where the next major version, v3, of Catch2 is being developed. As it is a significant rework, you will find that parts of this documentation are likely still stuck on v2.

For stable (and documentation-matching) version of Catch2, go to the v2.x branch.

v2.x 页面上有一个 link 到一个独立的头文件:

The latest version of the single header can be downloaded directly using this link