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 compiling under Linux & OSX and cl.exe to compile under Cygwin on windows. My current workflow consists of coding under OSX and then building on each individual platform to test code portability. This process is somewhat time consuming and I was wondering if it is possible to automatically build on all platforms in one step?
问题:
回答1:
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.
回答2:
This sounds like a job for CMake.
回答3:
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.