Conan——C++包管理工具——使用踩坑记录
使用conan所遇到的大部分问题都可以在conan官方文档中找到答案,
参考官方文档地址:
https://docs.conan.io/en/latest/
虽然大多数情况下,答案不是那么显然。
不过也正是如此,本文把那些可能有点绕的问题的解决办法和原理,尽可能详细的记录下来,
以便后人遇到相同问题时能节省一点定位的时间。
创建一个包的最简步骤
1. conan new 生成一个conanfile.py
2. 编辑conanfile.py
一般的,代码的版本控制不在conan中进行,也不推荐这么做,你有更好的选择:git
from conans import ConanFile, CMake, tools
class BgyArTopicConan(ConanFile):
name = "bgy_ar_topic"
version = "v1.0.0"
........some informations........
settings = "os", "compiler", "build_type", "arch"
requires = ["myjson/v1.0.0@ar/stable"]
def source(self):
self.run("git clone git@10.8.202.206:agricultural_robot/ros/common/bgy_ar_topic.git")
# This small hack might be useful to guarantee proper /MT /MD linkage
# in MSVC if the packaged project doesn't have variables to set it
# properly
tools.replace_in_file("bgy_ar_topic/CMakeLists.txt", "project(bgy_ar_topic)",
'''project(bgy_ar_topic)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_ba