[cmake-developers] Unique compile definitions

Stephen Kelly steveire at gmail.com
Fri Aug 10 08:53:24 EDT 2012


Brad King wrote:

> On 08/10/2012 04:53 AM, Stephen Kelly wrote:
>> I've merged a branch into next to ensure that compiler definitions are
>> only added one time on the command line.
> 
> The "Preprocessor" test already has extensive coverage of
> COMPILE_DEFINITIONS. Can that test be extended for your cases instead of
> adding a new test?

Possibly. 

>From a quick look at that test I'm not sure if you're asking for something 
like git mv Tests/CompileDefinitions/* Tests/Preprocess and then modifying 
Tests/Preprocess/CMakeLists.txt to match, or do you mean something more 
'flat' where I would simply add more duplication of the compile definitions 
in Tests/Preprocess/CMakeLists.txt. 

The point of doing it in a separate test was to be more clearly able to see 
the duplication without it getting lost in a different test, and to be able 
to see which one sets which definition first (add_defintions or 
set_property(COMPILE_DEFINITONS)) to test that neither overwrites the other.

> 
> Also I think the test for uniqueness is better done in the original form
> using a local std::set<> to know whether each definition has been added.
> Searching for existing strings in the output is not robust.

I agree. I wanted to avoid changing the API to start the discussion, but 
this is the kind of feedback I was looking for. 

Many generators have to be touched to fix the API, but it should be do-able.

Thanks,

Steve.





More information about the cmake-developers mailing list