building everything with a set of specific preprocessor token(s)/definition(s)?

René J. V. Bertin rjvbertin at gmail.com
Sat Mar 19 09:34:35 UTC 2016


Boudhayan Gupta wrote:

Sorry, I've been overlooking this thread completely (been going through a bit of 
a rough patch in life).

> 
> CC="gcc -DWHATEVER_DEFINE" cmake ...
> 
> It really should be as simple as that.

Yeah, except that this would very likely apply too:

> There's also an interaction with the build system I'm targeting; not really 
relevant on here but it does make it less trivial to rely on settings passed 
through the environment.

I've also done this kind of thing in the past when using CFLAGS or CXXFLAGS 
didn't have the intended effect. YMMV, and I cannot recall if I ever tried this 
with cmake, but I've learned to avoid this approach (or use a wrapper that adds 
the desired options) because I've seen a bit too many cases where something 
would fail during the initial compiler tests.

That build system I'm targeting (indeed, MacPorts) would apply the setting in 
one of its "header files" that provide the basic settings for any number of so-
called "ports" for packages that are to be built with those settings. I won't be 
the only one developing such ports, so I'm looking for something that's as 
robust as possible against operator oversight.

I realise this probably doesn't make much sense for most of you. Suffice it to 
say that things would have been really easier if cmake had a way to add elements 
to its variables via the command line.

R.



More information about the Kde-frameworks-devel mailing list