Search code examples
haskellbuild-processcmakecabal

Is it possible to use cmake for Haskell projects?


I am planning a project written in Haskell, maybe there are some parts in C as well. For the buildsystem I decided against the common choice for Haskell programs cabal, mainly because I want to learn how building programs in other languages works.

I heard about CMake and I think it is a pretty cool product. Although I have no knowledge in how to use it, I want to use CMake for that project, just to find out how it works. Googleing did not reveal any facts about how to use cmake with haskell, and all tutorials I read were rather confusing. Is it possible, and if yes, how is it possible, to compile a project written in Haskell using CMake?


Solution

  • You can certainly use CMake to build Haskell applications and libraries. To do so, you will need to duplicate much of what Cabal does, which will be instructive, but also time consuming.

    I'd recommend using cabal build -v to see the commands emitted by Cabal, and then transcribing them into CMake form.

    Or, use CMake to call cabal on the Haskell code -- that's likely to be less annoying.