C++ cross platform build automation

前端 未结 3 1463
心在旅途
心在旅途 2021-02-05 09:42

I have a cross platform C++ project that targets and successfully compiles on Linux, OSX and Windows. I\'m using GNU Make to handle the building on all platforms, gcc for compil

相关标签:
3条回答
  • 2021-02-05 10:18

    If I understand the OP correctly, the question isn't about replacing make but how to launch the build on each platform?

    I'd suggest using http://jenkins-ci.org/ - it's java and can be run on Windows, Linux, OSX, etc. It can be configured to launch build jobs concurrently so that any time you want to do a build each platform could be launched simultaneously.

    The learning curve for jenkins isn't terrible but it probably will take about 3-4 hours to get working right, once you do however it's smooth sailing.

    If you want to be pro, you can have it poll your source repo and it'll launch builds automatically after commits.

    0 讨论(0)
  • 2021-02-05 10:21

    This sounds like a job for CMake.

    0 讨论(0)
  • 2021-02-05 10:25

    Good question. First of all, there is no way you can do those builds in one step on one platform. What you can do however is to look for is a build system which makes it easy to do cross-platform building and a tool to automate things for you. This gives you a solution which takes you out from doing manual building and you can fully focus on developing the code.

    CMake (as already mentioned) provides a good solution for cross-platform building. In short, through CMake you get e.g. Visual Studio solutions/projects, makefiles or such for the target platform, which you then use to build on that specific platform. Your job is to maintain the CMake build files and CMake takes care of generating the specific build files for the platforms you build on.

    You mention to have builds built in "one step" - this needs to be addressed slightly differently through build automation. That is, using a Continuous Integration (CI) system like the mentioned Jenkins, Hudson or CruiseControl. In your case you need to do builds on three different platforms (Windows, Linux and OSX), which means you need to have a CI running on each platform. These systems when set up will check for changes in the source code repository and when changes are found, the source is fetched, then using CMake it will generate platform specific build files for the platform the CI is running on, then build, test and finally report the result how the build went.

    0 讨论(0)
提交回复
热议问题