如何在conanfile.txt中要求gtest

huangapple go评论48阅读模式
英文:

How to require gtest in a conanfile.txt

问题

在conanfile.txt中放置gtest应该放在哪里?在conanfile.py中建议使用test_requires("gtest/1.12.1@")。然而,在conanfile.txt中没有[test_requires]部分。

我认为它应该作为库的一部分,因此应该放在[requires]部分。还有没有将其放在[tool_requires]下的理由吗?

英文:

Where to put gtest in a conanfile.txt? In a conanfile.py it is suggested to use test_requires("gtest/1.12.1@"). However, there is no [test_requires] section in conanfile.txt.

I assume it is part of the library and should therefore be in the [requires] section. Or are there any reasons to put it under [tool_requires]?

答案1

得分: 2

conanfile.txt中有一个[test_requires]部分,请查看此链接

无论如何,test要求旨在在host上下文中链接库,如gtest、catch2或类似的库。它不应该被定义为[tool_requires],如果有的话,应该是常规的[requires]。在conanfile.txt的情况下,因为它是最终的消费者,不会有进一步的下游消费者,实际上没有requirestest_requires之间的区别,主要区别是test_requires是私有的,不会向下传播。

英文:

There is a [test_requires] section in the conanfile.txt, please check this link

In any case, a "test" requirement is intended for linking a library in the "host" context, like gtest, catch2, or similar. It shouldn't be defined as a [tool_requires], if anything, it should be a regular [requires]. In the case of a conanfile.txt, as it is the end-consumer and there will be no further downstream consumers, there is no distinction in practice between a requires and a test_requires, as the main difference is that test_requires are private and not propagated down the graph.

huangapple
  • 本文由 发表于 2023年6月25日 18:39:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76549986.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定