Looking for complete examples of cross platform projects

Me and my colleagues are using CMake 3.20 to build cross platform projects. We can make it build and deploy on Windows, with some manual effort. We can’t get it to build on the other platforms without breaking the Windows build.

We have been trying to find a good example of a project that is cross platform. We can find library examples, but not executable examples. The examples we have found also fail to include resources such as graphic, sounds, fonts, or icons.

We haven’t even gotten to working with CPack as the library examples don’t need it.

We do development on Windows, Linux, and Mac. We want to deploy to all 5 platforms.
Can someone provide an example that works on Windows, Linux, Mac, iOS, and Android?


Can someone provide an example that just uses iOS and Android?

What about Windows, Linux, and Mac?

if you want your code to work cross platform, by far the best framework out there is JUCE. It provides an OS-agnostic abstraction layer, and also some CMake helper utilities, so that you can write your code once and it should “just work” on Mac, Windows, Linux, iOS, and Android.

The Github repo is here: GitHub - juce-framework/JUCE: JUCE is an open-source cross-platform C++ application framework for desktop and mobile applications, including VST, VST3, AU, AUv3, RTAS and AAX audio plug-ins.

What is breaking concretely? Please give some examples and we can help you fix them in a cross-platform way.

Thank you for your comment. The problem isn’t writing code that is cross platform. The problem is using CMake “out of the box” to create the projects. I looked at JUCE and found that it makes the same assumptions that every other example makes. Even the example projects are too simple for what we are looking for. Have you used JUCE to make a real project that works on all the platforms?

I was hoping to provide others with better examples of CMake in the real world by asking this question. I will eventually post details of the problems we are having when we are closer to being done with other aspects of the project. Until then, do you have any examples?

I don’t understand what the problem is. What assumptions does JUCE make?

I have used JUCE with CMake to compile code for Mac, Linux, Windows and iOS (no Android support in JUCE’s CMake API yet).

“Compile code”? So nothing about releasing it. We have no problems compiling code cross platform. Our problems are with creating releasable projects.
No Android support. So not iOS and Android. If we’re going to release on iOS, we also have to release on Android. That’s our rule.
“JUCE’s CMake API”? So not CMake “OOTB (Out Of The Box)”. So we have to use a third party extension to CMake to make a releasable project? Then why are we using CMake at all? Oh right. Everyone says it is the best cross platform project specifier and when we look at the others we can see why.

I was unclear as to what breaks when we try to modify CMake for other platforms. Ultimately this is all about releasing apps on all platforms. We can, with some manual effort, release on Windows. When we try to modify our CMake file to make other platforms releasable we end up breaking the Windows release without making it releasable on the other platforms. While we may be able to separate the issues needed to make other platforms releasable, we haven’t been able to find an example that even hints as to how to do it, much less actually has a useable CMake file.
When I say release on a platform I mean a folder containing the executable and all support files needed for the app to run on any computer the folder is copied too. We can make projects that can build on all platforms, but the created folders cannot be used on other computers. There are multiple issues involved.

As I said before, I will eventually ask about the specific issues, but I still can’t find a real example that actually works on all the platforms.

Thank you for trying to answer my question, but JUCE is not it.

Sorry, I was confused because you said this in your initial post.

You can use CMake to write install rules, which can also be platform dependent if you need, like so:

if (APPLE)
    if (IOS)
        # iOS version of your install rules
        # MacOS version of your install rules
elseif (WIN32)
    # Windows version of your install rules
    if (ANDROID)
        # Android version of your install rules
         # Linux version of your install rules

If you just want to have a folder containing the executable and all resource/support files, I don’t see why creating that folder would change depending on the platform. You can copy all the resource files to this folder at configure time, and add a post-build rule to your executable to copy it into that folder.

For actual deployment to end-users, though, I would imagine you’ll want to create installers for the desktop platforms…

Please get your story straight. We’re happy to answer and help you as best as we can, but we can’t divine what the truth is.


So do you have an example of using install to give the executable an icon?
What about resource files such as sounds?
I ask because while I know something about the required folder structure on some of the platforms, I am using CMake because I am not an expert in all the platforms.
While I recognize the platform dependent nature of code signing, none of the examples we could find include it. Do you have an example that does?
Again I am asking for a good example of real world use. Not because I have a specific problem, but because I have lots of problems that should be easy to solve using CMake because everyone has these same problems.

No, I don’t believe it’s possible to do this using only “pure” CMake. Using JUCE makes it trivial to add icons for apps, though.

If all you need is to copy them to a destination folder, then you can use the install(FILES) signature of the install command.

Did I make a mistake by posting this in Code instead of Usage?

Am I right in thinking that even the CMake project itself is not a good example of how to use CMake?

This is not a direct answer to your question but an example of the same type of question for Prolog,

Where can I find quality code examples?

for which the Prolog answer is

Useful Prolog references - Wiki - SWI-Prolog

which list hand selected GitHub repositories for the exceptional quality of the Prolog code.

Yesterday I spent some time trying to find GitHub repositories with quality CMake code and files and learned that GitHub really is not a good way for finding code related to CMake just to many hits that have to be manually searched.

If this site has a similar list it would be nice know where. If not perhaps someone can start the list. :slightly_smiling_face:


If you want a Windows/Linux/macOS example (I also occasionally test on BSDs, too), I wrote a couple of examples that I use for tutoring. The readme probably needs to be updated, and there are still a few things that need to be figured out, but at the very least, the command-line program and library build on all three systems, and there’s a platform-specific GUI program for each OS, too.


Thank you for providing me with a “good” example, good being a relative term. On cursory viewing it seems to handle the issues I was encountering and does it for most of the platforms I was targeting. Unfortunately I have already moved on to another solution and am not using CMake anymore.

I explain how to setup a basic iOS + Objective-C project here: Building Objective-C iOS apps with CMake - Juan Cruz Viotti