Search code examples
c++cxcodebuild-systemfreetype2

Xcode preprocessor macros to include system style headers


I'm trying to manually add freetype 2.9.0 as a framework build target to my toy project in Xcode. Freetype uses preprocessor macros to include its headers with angled brackets (<freetype/config/xx.h>) which is confusing the Xcode build system and I get the error expected "FILENAME" or <FILENAME>, indicating that it can't find my system level includes. Instead of hardcoding the subfolder headers, how would I configure the Xcode build system to find these config files?

I tried this in another file

#define SOME_CONFIG <glfw/glfw3.h> /*this header is included as a system header in a subfolder <project/glfw/... , and works fine*/

#ifdef SOME_CONFIG
#include SOME_CONFIG
#endif

And it works perfectly. But when I try this with freetype it cannot find the expanded in the macros.

The freetype include structure looks like this:

include/ftbuild.h         -- points to include/freetype/config/ftheader.h
include/config/ftheader.h -- has all the #define macros to ->
include/config/...        -- a bunch of headers with options which Xcode refuse to see

Solution

  • Apparently it was actually working all along I just forgot to add the environment variable FT2_BUILD_LIBRARY to both debug and release build, and I had it set to debug, so the internal header macros was not being precompiled, and therefore not found. Works perfectly fine to do what I am trying to do in Xcode 9.

    Environment varialbes