On MSVC and APPLE, build_thrift will handle thrift's flex and bison dependencies: https://github.com/apache/arrow/blob/f578521/cpp/cmake_modules/ThirdpartyToolchain.cmake#L1052-L1097
But you're on your own on linux. In
ARROW-6793, I wrote 100 lines of R code to do this for my needs: https://github.com/apache/arrow/pull/6068/files#diff-3875fa5e75833c426b36487b25892bd8R204-R309
We should translate this to CMake so it's generally available.