CMake generator on macOS?

To build an App on macOS with CMake (juce_add_gui_app) is it possible to use the default Makefile generator? Is the result the same that using XCode generator? What do you use?

On Mac, we use cmake -G Xcode

1 Like

Thanks.

I would like to avoid to mess the build command with single-config and multi-config stuff (i.e. use CMAKE_BUILD_TYPE=Release for all platforms). Don’t know if it is usual/possible to build macOS App with Makefile only. :thinking:

I’ll probably just go trial-and-error engineering.

Instead of a makefile you could use Ninja as the generator.

1 Like

CMake theoretically supports building everything the same way with any generator. As far as I know, any generator/compiler can generate a MacOS application bundle, but when not using Xcode, obviously you don’t get any xcode-provided features like code signing.

1 Like

With the Projucer i codesign with a post build script. Thanks.

I use the makefile generator pretty much all the time. I only use -G Xcode for when I want to open the project in Xcode for some reason (like run in Instruments).

1 Like

When not using Xcode, I highly recommend Ninja instead of Makefiles. It will likely be faster in incremental rebuilds.

2 Likes

Ninja’s always my go-to - it’s definitely the fastest, especially combined with sccache, unity builds, etc.

I made a tool a few months ago to profile Ninja builds to help identify areas that are particularly slow to compile. Helped save some CI costs by significantly reducing build times.

3 Likes

Nice tool! Never gave much thought to Makefile vs. Ninja and just used the default. Will give it a try, thanks guys!

With non-caching CI it probably won’t make a huge difference; make & ninja perform about the same to do a full rebuild from scratch. But where Ninja will give you huge improvement is on incremental rebuilds: after you’ve built everything once, you change 1 file, then build again.

We are also using ninja for all builds on all platforms.

Even that isn’t necessary, I regularly profile Ninja-based builds with Instruments. You can just launch the Instruments app out of the Xcode bundle on it’s own, you just need to be sure to have configured a symbolicated release build, which is at least the default setting for our non-deployment release builds.

2 Likes

What do folks use instead of Xcode? VS Code, CLion, something else? Do you use the debugger in that tool too?

I’ve been using CLion on all platforms for years now, with macOS being my main development environment. Tbh, I think I haven’t interacted with Xcode for years now. Debugging through CLion works great, but it’s also possible with e.g. VS Code etc.

I mean, in the end just like the compiler, the debugger is just a command line tool that can be used directly without any UI. In case of an apple clang toolchain as bundled with Xcode, the debugger happens to be LLDB, the choice of your IDE is only the choice of which nice UI wrapper you use to interact with that LLDB. And that’s the case for basically all other components the toolchain, you can always inkoke them alternatively, although that’s not always as straightforward as it is with just using Xcode or CLion which already comes with a lot of preconfigured stuff.

2 Likes

I use VS Code with the CMake extension and use the built-in debugging tools (with LLDB).

VS Code’s far from perfect but I have a lot of projects with a mix of languages (C++, Python, HTML/CSS/JS, etc.) and so I like having one IDE that works for all of them. It’s very much a Jack of All Trades, Master of None!

Also, who could live without the pets extension?!

1 Like