====== Conan ====== * [[https://conan.io/|conan.io]] - the C/C++ Package Manager, * 仓库:https://conan.io/center/ ==== Conan 2 笔记 ==== * 安装 conan2: sudo pip install conan conan profile detect --force 生成的默认配置文件在 ''~/.conan2/profiles/default '' * 更新sudo pip install conan --upgrade * 二进制包管理私有仓创建: * https://docs.conan.io/2/tutorial/conan_repositories/setting_up_conan_remotes.html * https://docs.conan.io/2/tutorial/conan_repositories/setting_up_conan_remotes/artifactory/artifactory_ce_cpp.html ==== Conan 1 笔记 ==== * 结合 [[https://jfrog.com/|JFrog]] 可构建私有C/C++二进制包管理 * 私有仓创建下载 [[https://conan.io/downloads.html]] * https://docs.conan.io/en/latest/uploading_packages/artifactory/artifactory_ce.html * conan 的[[https://docs.conan.io/en/latest/reference/generators/cmake.html|cmake 变量表]] * 关于打包[[https://docs.conan.io/en/latest/creating_packages/understand_packaging.html|understand_packaging]] * 添加 bincrafter 仓:https://bincrafters.readthedocs.io/en/latest/using_packages.html#adding-the-bincrafters-repository-as-a-conan-remote * 调整仓库顺序: conan remote clean conan remote add myconan conan remote add bincrafters https://bincrafters.jfrog.io/artifactory/api/conan/public-conan conan remote add conancenter https://center.conan.io # conan remote add conan-center https://conan.bintray.com # 此仓库已被官方废弃 * 更新conan: pip install conan --upgrade # Might need sudo or --user * vscode 整合 conan 头文件:在 ''c/c++'' 插件设置里 ''includePath'' 添加 ''~/.conan/data/**'' === Android NDK 交叉编译 === * 官方文档参考这个链接 https://docs.conan.io/en/latest/integrations/cross_platform/android.html, 而不是这个链接https://docs.conan.io/en/latest/systems_cross_building/cross_building.html, 后者的示例在 armv8 会错误编译成 armv7。 * 可直接使用官方[[https://docs.conan.io/en/latest/integrations/cross_platform/android.html|这个链接]]的第一种办法,即在 profile 里直接使用 ''android-ndk''包作为 tool_requires, 比如编译 armv8:include(default) [settings] arch=armv8 build_type=Release compiler=clang compiler.libcxx=libc++ compiler.version=11 os=Android os.api_level=21 [tool_requires] android-ndk/r22b [options] [env] 然后install 或 create 时指定跨平台编译 conan install .. --build=missing -pr:h android-armv8 -pr:b default * [[https://docs.conan.io/en/latest/systems_cross_building/cross_building.html|这个链接里android 示例]] 错误的原因是, Android 与 CMake 结合时, CMake 除了指定 android.toolchain.cmake, 还需要额外[[https://developer.android.com/ndk/guides/cmake#variables|指定变量]] ''ANDROID_ABI'' ''ANDROID_PLATFORM'' 才能正确编译出目标版本。 而 conan 并[[https://docs.conan.io/en/latest/reference/env_vars.html|没有办法在 profile 里直接设置]]这两个 cmake 变量, 所以就算你的工程的 CMakefile.txt 设置了这两变量,你的依赖包在cmake building 时也会默认选择了错误的arch。