简体   繁体   English

将CMake项目集成到Buck的最佳方法是什么?

[英]What is the best way to integrate a CMake project into Buck?

I am using Buck for my own C++ project, but I depend on a third-party library that is built using CMake. 我正在使用Buck作为我自己的C ++项目,但我依赖于使用CMake构建的第三方库。 The CMake file is complex, so I do not think it is practical to recreate their CMake file in Buck. CMake文件很复杂,所以我认为在Buck中重新创建他们的CMake文件是不切实际的。 Instead, I would like to call CMake from Buck. 相反,我想打电话给巴克的CMake。

What is the best way to call CMake from Buck? 从巴克打电话给CMake的最佳方式是什么?

How should I structure my project to minimise headaches? 我应该如何构建我的项目以减少头痛?

My suggestion is using genrule and prebuilt_cxx_library. 我的建议是使用genrule和prebuilt_cxx_library。

This is my Buck study project using Google Test : https://github.com/ar90n/lab/tree/master/sandbox/buck-study/gtest 这是我使用Google Test的 Buck研究项目: https//github.com/ar90n/lab/tree/master/sandbox/buck-study/gtest

This project contains two Buck files. 该项目包含两个Buck文件。 The one ( ./gtest/BUCK ) is for fetching and building Google Test. 一个( ./gtest/BUCK )用于获取和构建Google Test。 The another ( ./BUCK ) is for building and running test programs. 另一个( ./BUCK )用于构建和运行测试程序。

If you want to build and run this project, please execute the following commands, 如果要构建和运行此项目,请执行以下命令,

$ buck fetch //gtest:googletest-src
$ buck build :sample1
$ buck run :sample1

Calling CMake will break reproducibility, so it isn't the best approach. 调用CMake会破坏可重复性,因此它不是最好的方法。 Instead, try the following: 相反,请尝试以下方法:

  1. Fork the project that builds with CMake. 分叉使用CMake构建的项目。
  2. Call CMake to generate any header files. 调用CMake生成任何头文件。
  3. Save the header files somewhere in the project (eg /cmake-generated ). 将头文件保存在项目中的某个位置(例如/cmake-generated )。
  4. Create a header-only library of the header files generated by CMake. 创建由CMake生成的头文件的仅标头库。
  5. Build the rest of the project with Buck, depending on the CMake library. 使用Buck构建项目的其余部分,具体取决于CMake库。
  6. Commit everything to Git. 把一切都交给Git。
  7. Repeat step 2 for every target that you require. 对您需要的每个目标重复步骤2。

This is not as good as a true port to Buck, but you get most of the benefits for a one-time manual step. 这不如Buck的真正端口好,但是您可以获得一次性手动步骤的大部分好处。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将 assimp 添加到 CMake 项目的最佳方法是什么? - What is the best way to add assimp to a CMake project? 在中型项目中CMake的最佳方法是什么? - What is the best way of CMake in a Middle-sized Project? 将Google Analytics(分析)集成到C ++ OpenFrameworks桌面项目中的最佳方法是什么? - What is the best way to integrate Google Analytics into a C++ OpenFrameworks desktop project? 确定clang和cmake定义的宏的最佳方法 - Best way to determine what macros are defined by clang and cmake 在更现代的 cmake 中使用箭头拼花的最佳方法是什么? - What is the best way of using arrow parquet in more modern cmake? 导出具有外部依赖项的 cmake 项目的既定方法是什么? - What is the established way to export a cmake project with external dependencies? 在cmake c ++项目中包含库的首选方法是什么? - What's the preferred way to include a library in a cmake c++ project? 如何使用CMake将QtMultimedia组件集成到项目中? - How to integrate QtMultimedia component into a project using CMake? 让不同的文件在 CMake 中使用不同的预编译头文件的最佳方法是什么? - What is the best way to have different files use different precompiled headers in CMake? 使用 vcpkg 与朋友分享您的项目的最佳方式是什么 - What is the best way to use vcpkg to share your project with a friend
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM