Add a source file for just one platform

Sorry, I'm sure this is out there, but I wasn't able to find it by searching:

In the Introjucer, how can I set a source file to only be included for one platform's build. For example, I have a file I needed compiled in my Visual Studio project, but not my XCode project. I can't figure out how to do that.

Thanks,

Mike

Look to the JUCE source… for example:

You add the file(s) to IJ, but use JUCE_WINDOWS if you’re targeting Windows…

Rail

I was hoping there might be another approach. Something to keep the files out of the XCode project in the first place.

These are some third-party open source files, and while I can add such code to them, I'd rather keep them as-is from the third-party and not have to re-add some platform-testing macros each time I update the version of the library I'm using.

Sometimes I have a source file that looks like: 

#ifdef XYZ

#include "abc.cpp"

#endif

To avoid modifying a file ... it depends how many of them you have how annoying this would be ;) 

Yeah, I thought of that too. I suppose I could include all the .c files from the third-party library in one big wrapper file. Seems kind of ugly, and could be awkard to debug, but that may be the way it is.

You could build them as a library maybe?

Make a module with your code? In your juce_module_info you can include or not a file according to the target.

This would be a very nice feature. I use this feature with CMake for years and I need it now with projucer for a library that has different source files for Windows and OS X as well.

1 Like