[cmake-developers] Semi-colons in COMPILE_DEFINITIONS
Brad King
brad.king at kitware.com
Wed Jul 10 09:04:44 EDT 2013
On 07/10/2013 08:52 AM, Stephen Kelly wrote:
> The problem is revealed because I changed GetCompileDefinitions to populate
> an out-vector instead of returning a string, which the VS generator used to
> use directly. The use of ExpandListArguments does not handle the 'escaped'
> semicolon. Should it be taught to?
The problem is that now you're calling ExpandListArguments twice.
The old code did:
- targetOptions.AddDefines(target.GetCompileDefinitions(configName).c_str());
and the implementation of AddDefines calls ExpandListArguments.
The new code does:
+ target.GetCompileDefinitions(targetDefines, configName);
which runs ExpandListArguments internally too. Then you re-compose
a ;-list without re-escaping the semicolons and pass it to
+ targetOptions.AddDefines(targetDefinesString.c_str());
which does ExpandListArguments again.
BTW, the get-then-append pattern used in hunks like this:
+ std::vector<std::string> targetDefines;
+ target.GetCompileDefinitions(targetDefines,
+ this->ConfigurationName.c_str());
+ this->AppendDefines(defines, targetDefines);
should be refactored to use a helper rather than duplicated.
For example, I was able to reduce a lot of code recently:
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d221eac8
Thanks,
-Brad
More information about the cmake-developers
mailing list