英文:
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
的情况下,因为它是最终的消费者,不会有进一步的下游消费者,实际上没有requires
和test_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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论