[cmake-developers] $LIST_LENGTH{} syntax
Ben Boeckel
ben.boeckel at kitware.com
Tue Jan 22 13:59:31 EST 2019
On Tue, Jan 22, 2019 at 19:31:43 +0100, Torsten at Robitzki.de wrote:
> Currently, the Code that evaluates the ${}-Syntax only evaluates the key, if the key is not an empty string:
>
> const char* cmCommandArgumentParserHelper::ExpandSpecialVariable(
> const char* key, const char* var)
> {
> if (!key) {
> return this->ExpandVariable(var);
> }
> if (!var) {
> return "";
> }
> if (strcmp(key, "ENV") == 0) {
> std::string str;
> if (cmSystemTools::GetEnv(var, str)) {
> if (this->EscapeQuotes) {
> return this->AddString(cmSystemTools::EscapeQuotes(str));
> }
> return this->AddString(str);
> }
> return "";
> }
> if (strcmp(key, „CACHE") == 0) {
>
> …
>
> so, there seems to be no risk to slow down the ExpandVariable()-Path (but of cause, I would measure the difference).
That's the old (pre-CMP0053) parser. The new code for handling the
`$XXX{` parse switching is in `Source/cmMakefile.cxx:2810` (or so). The
method is `cmMakefile::ExpandVariablesInStringNew`. It is very
performance sensitive (i.e., the old parser is so slow compared to the
new one that running the new one beside it doesn't really affect
performance much and is what allows for CMP0053 warning messages).
--Ben
More information about the cmake-developers
mailing list