c++buildcmakebuck

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. The CMake file is complex, so I do not think it is practical to recreate their CMake file in Buck. Instead, I would like to call CMake from Buck.

What is the best way to call CMake from Buck?

How should I structure my project to minimise headaches?


Solution

  • My suggestion is using genrule and prebuilt_cxx_library.

    This is my Buck study project using Google Test: https://github.com/ar90n/lab/tree/master/sandbox/buck-study/gtest

    This project contains two Buck files. The one (./gtest/BUCK) is for fetching and building Google Test. The another (./BUCK) is for building and running test programs.

    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