Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何添加复杂开源组件 #2

Closed
skb666 opened this issue Dec 1, 2022 · 5 comments
Closed

如何添加复杂开源组件 #2

skb666 opened this issue Dec 1, 2022 · 5 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@skb666
Copy link
Contributor

skb666 commented Dec 1, 2022

如果想向 components 内添加其它开源组件
如 libevent、openssl 这种用 autoconfig 或者 make/cmake 自组织编译的复杂组件
应该如何与该项目配合编译呢

@Neutree
Copy link
Owner

Neutree commented Dec 1, 2022

目前这个项目里面比较少考虑直接引用系统的包,值得探讨下实现方式。

  • 一种是像opencv这种直接提供了 cmake文件的,直接引用是最好的,可以把源码放在component下,也可以直接引用系统的,这是在 cmake 世界里面比较通用的方法,常用的开源项目应该都有人写过,搜一下应该就能找到
set (OpenCV_DIR opencv/lib/cmake/opencv4)
find_package(OpenCV REQUIRED)
  • 另外比较原始的方法就是可以直接将源码拉进来在cmakelists.txt文件加源码搜索路径,或者添加搜索 .so 和 .h 文件路径

@Neutree Neutree added the help wanted Extra attention is needed label Dec 1, 2022
@skb666
Copy link
Contributor Author

skb666 commented Dec 15, 2022

若使用 find_package 引入包,find_package 要在 project() 命令之后,我尝试将 include(${SDK_PATH}/tools/cmake/compile.cmake) 放到 project 之后,发现 python project.py build 未报错,但未编译出任何目标

@Neutree
Copy link
Owner

Neutree commented Dec 15, 2022

在 component 里面 find吧,比如 examples/demo/main/CmakeLists.txt, 一般不需要编辑examples/demo/CmakeLists.txt

@skb666
Copy link
Contributor Author

skb666 commented Dec 15, 2022

在 component 里面 find吧,比如 examples/demo/main/CmakeLists.txt, 一般不需要编辑examples/demo/CmakeLists.txt

感谢,目前通过以下方法,已成功与 vcpkg 配合使用

  1. 在项目目录下 .config.mkconfig_defaults.mk 内配置 CONFIG_TOOLCHAIN_PATH="~/vcpkg/scripts/buildsystems/vcpkg.cmake"
  2. 新建组件目录 component/component_name
  3. 组件目录下 CMakeLists.txt 内引入包,如 curl
    find_package(CURL CONFIG REQUIRED)
    list(APPEND ADD_REQUIREMENTS CURL::libcurl)
    register_component()
  4. 项目目录下 main/CMakeLists.txtlist(APPEND ADD_REQUIREMENTS component_name)

@skb666 skb666 closed this as completed Dec 15, 2022
@Neutree Neutree added the good first issue Good for newcomers label Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants