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?
3 Answers
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.

- 27,321
- 5
- 74
- 91
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.

- 5,961
- 5
- 39
- 63
-
6Just for the record for folks making the choice between Jenkins or Hudson - they're basically the same thing except, Jenkins is the original developer fork that occurred when Oracle took over Hudson, Hudson support petered off under Oracle's control and Jenkins was the stronger of the two. However, Oracle has recently gifted the Apache project with Hudson - so it is yet to be seen who will be the stronger seed, but right now Jenkins is the strongest. – synthesizerpatel Jul 05 '11 at 07:04
-
1"there is no way you can do those builds in one step on one platform" As of 2016, this is wrong. Using a Linux server, you can produce native macOS binaries with the clang cross compiler with help from this project https://github.com/tpoechtrager/osxcross and Windows binaries with MinGW. You can automate this with simple Makefiles or CMake or premake, with a flag determining the architecture you wish to build. – Vortico Nov 13 '16 at 08:56
This sounds like a job for CMake.

- 52,720
- 19
- 113
- 137
-
10-1 How exactly is CMake going to build on all platforms in one step? AFAIK, `cl.exe` is not available on Linux or OSX! – André Caron Jul 01 '11 at 20:42
-
2CMake is designed to use the tools of the platform to build the project. Even if the OP wanted a true one-stop-build there is this article to go off of (http://www.cmake.org/Wiki/CMake_Cross_Compiling). – Andrew White Jul 01 '11 at 21:37
-
@Kerrek: True, cmake is really convenient - but when you want to e.g. release your app the Apple Appstore, you run into some seriously inconvenient missing features ( can't set the capabilities, scheme's not supported, can't add "link with binary - framework" which is needed for capabilities to work correctly, can't correctly add multi-language support, so it appear in "project-info/localizations",). Most of it can be worked around with some effort (or by ignoring what xcode displays in the project-properties), but I do hope that will get some attention in the future. – kalmiya Dec 01 '15 at 09:27