Hi, we’re working on a project that contains platform-specific implementation of a class. The Linux variant needs some extra .c
library source files to be compiled, but not the others.
Including these .c
source files in the Projucer project, we can compile the code fine on a Linux machine. But these files don’t compile on other platforms, so we really can’t just do it this way.
A few posts here mention this or something similar:
Exclude files per-platform with Projucer?
Different cpp/h for platform in introjucer
(There is actually another link, see comments)
From what I can gather there are three “solutions” here:
- Inlcuding the
.c
files in the main project, and manually disable compiling of these files per platform.- This is very inconvenient, since we want to keep the Projucer project file version-controlled with the project.
- Editing each
.c
file and wrapping them with#ifdef
statements.- Again, inconvenient, since it involves editing all the library source files.
- Creating a special
.h
file, include the.c
files, and wrap them with#ifdef
. Then include this file in an appropriate place in the project.- Not really a fan of this, since this means we’re compiling those
.c
files withg++
, which in most cases is fine, but can sometimes be a pain, and is not recommended.
- Not really a fan of this, since this means we’re compiling those
What I’d like to be able to do, is to add sources in the Linux part of the Config tab in Projucer. This would include compilation of the platform-specific source files in the Makefile, but not to XCode and VS project files.
For reference, our project structure looks something like this:
Project folder
Builds
MacOSX
XCode project files
Platform-specific source code (.h and .mm files)
LinuxMakefile
Makefile
Platform-specific source code (.h and .c files)
Source
Common source files (.h and .cpp files)
JUCE project file (.jucer)