问题描述
我将改用柯南,希望这将简化用户安装我的软件包的过程.没关系,直到我开始将gtest添加到我的程序包中.
I am about to change to conan, in the hope that is will simplify installing my package by my users. It was OK, until I started to add gtest to my package.
在安装过程中,我收到消息
During install, I receive messages
gtest/1.8.1@bincrafters/stable: Package installed
conanfile.txt imports(): Copied 4 '.a' files: libgmockd.a, libgtestd.a, libgmock_maind.a, libgtest_maind.a
但是,在构建过程中,我收到:
However, during build I receive:
/usr/bin/ld: cannot find -lgmock_maind
/usr/bin/ld: cannot find -lgmockd
/usr/bin/ld: cannot find -lgtestd
我的CMakeLists.txt文件包含
My CMakeLists.txt file contains
target_link_libraries(
${PROJECT_NAME}_GTEST
Modules
${CONAN_LIBS}
)
缺少什么?我可以提供一些
What is missing? Shall I provide some
link_directories(?)
link_directories(?)
争论?
(与此同时,经过一番尝试,我成功了:不仅如此
(In the meantime, after some trials, I succeeded: Not only
link_directories(${CONAN_LIB_DIRS_GTEST})
是必需的,但还必须清除柯南的.data.)
is needed, but also conan's .data must be cleared.)
推荐答案
您使用的是什么生成器?
What generator are you using?
我在conanfile.txt中的要求"部分中有此
I have this in my conanfile.txt requires section
gtest/[~=1.8]@bincrafters/stable
这就是我在那部分中要给发电机的东西
This is what I have for generators in that section
cmake_find_package
cmake_paths
并在CMakeLists.txt
And in the CMakeLists.txt
include(${CMAKE_BINARY_DIR}/conan_paths.cmake)
find_package(gtest REQUIRED)
add_dependencies(something gtest::gtest)
target_link_libraries(something gtest::gtest)
请注意,FindGTest是一个内置模块,而Findgtest.cmake是conan在构建目录中生成的文件.
Note that FindGTest is a built in module, but Findgtest.cmake is a file generated by conan in the build directory.
这篇关于用柯南安装gtest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!