Chaining instead of overriding Compiler Arguments with Config files

I have created some config files for my project. Each config files specify the header/library dependencies.


like


sdk1.xcconfig

===================================

HEADER_SEARCH_PATHS = $(inherited) $(SDKROOT)/SDK1/include

LIBRARY_SEARCH_PATHS=$(inherited) $(SDKROOT)/SDK1/Lib/$(CONFIGURATION)

===================================


sdk2.xcconfig

===================================

HEADER_SEARCH_PATHS = $(inherited) $(SDKROOT)/SDK2/include

LIBRARY_SEARCH_PATHS=$(inherited) $(SDKROOT)/SDK2/Lib/$(CONFIGURATION)

===================================


Target.xcconfig

===================================

#include "sdk1.xcconfig"

#include "sdk2.xcconfig"

HEADER_SEARCH_PATHS = $(inherited) /myownpaths/


===================================



when this is getting resolved it looks like the variables in target.xcconfig is overriding everything else in stead of chaining.

I tried


HEADER_SEARCH_PATHS = $(HEADER_SEARCH_PATHS) /mypaths/


it didnt work either.


Can someone please point what I am missing here. Thanks in advance

Because that is what is happening! You are re-defining HEADER_SEARCH_PATHS in each config file. You need to do something like:


in sdk1.xcconfig:


SDK1_SEARCH_PATHS = ....


in sdk2.xcconfig:


SDK2_SEARCH_PATHS = ...


in Target.xcconfig:


HEADER_SEARCH_PATHS = $(inherited) $(SDK1_SEARCH_PATHS) $(SDK2_SEARCH_PATHS) /mypaths/

That makes sense but defining a new variable for each path and ensuring the target to include all the include path could be buggy. It would be nice if the config file supports a different assignment operator (~=for instance)

like


HEADER_SEARCH_PATHS ~= $(inherited) /myownpaths/ (for append in the end) or HEADER_SEARCH_PATHS =~ $(inherited) /myownpaths/ (for preappend)


so the values are appended instead of overwriting.



For now will try defining the variables and using that in the target.

Chaining instead of overriding Compiler Arguments with Config files
 
 
Q