Introjucer: Specify Compile option based on platform


#1

It seems there is no way to indicate whether or not a file should be compiled based on the platform. For example, I have .cpp files that I want compiled only for Visual Studio targets and not Macintosh:

[attachment=0]IntrojucerFileOptions.png[/attachment]

I would like the .cpp to be compiled only for non OS X / iOS targets, and the .mm to be compiled only for OS X / iOS targets.


#2

It’d be a logistical nightmare to have exporter-specific settings like that for every file, and to maintain them all when exporters are added/removed.

What I normally do is something like:

foo.mm:

#define JUCE_IS_INSIDE_MM 1 #include "foo.cpp"

foo.cpp:

#if JUCE_IS_INSIDE_MM || defined (_WIN32) ...the code..


#3

Yeah I ended up doing this as a workaround to prevent the amalgamated .cpp from causing compile errors in the Macintosh project:

.cpp

#if !defined(__APPLE__) || defined(__OBJC__)
//...