[CMake] CMP0054 and CMake Modules

Nils Gladitz nilsgladitz at gmail.com
Mon Sep 21 04:47:20 EDT 2015


On 09/21/2015 10:24 AM, thoni56 wrote:
> Aahh, I was looking at the trace and it only included "include":s so I
> thought that offending IF was in cmake's own files since it pointed there.
>
> But, you are saying that probably the culprit is a variable set before the
> first include, right? (It was definitely not by intention a variable was as
> having the empty name ;-).

The culprit is the empty named variable being set before the condition 
in that included module is evaluated, yes.

If you aren't the one setting it it might also be accidentally set 
somewhere in cmake code of course.

It probably isn't something as obvious as set("" foobar) but perhaps 
something like e.g. set("${MY_VAR_NAME}" foobar) (where MY_VAR_NAME is 
an unset variable e.g. due to typo or unexpected program logic).

>
> And if I look at
> /usr/share/cmake-3.3.1/Modules/CMakeParseImplicitLinkInfo.cmake:58 I should
> probably see the variable (or one that expands to include it)?

The condition in that line is:
	if("${cmd}" MATCHES "${linker_regex}")

So apparently ${cmd} expands empty (which may or may not be expected but 
is a distinct issue).

With old behavior cmake will therefor look for a variable with the empty 
name and in your case finds and expands it.

If you don't know where the empty named variable might come from I would 
expect cmake's new --trace-expand might be helpful.

I haven't tried it myself yet and you would have to use a nightly build 
though since it hasn't made it into a release yet.

Nils


More information about the CMake mailing list