[CMake] CMP0054 and CMake Modules

Nils Gladitz nilsgladitz at gmail.com
Mon Sep 21 04:10:40 EDT 2015


On 09/21/2015 09:37 AM, thoni56 wrote:
>    Quoted variables like "" will no longer be dereferenced when the policy is

You apparently have a variable whose name is the empty string.

With the old (pre CMP0054) behavior this will break comparisons with 
empty strings take e.g.

	set("" foobar)
	set(MYVAR foobar)

	if(MYVAR STREQUAL "")
		message("unexpectedly true")
	endif()

Where the if() comparison with old behavior will unexpectedly (for most 
authors of such conditions) evaluate true.

With CMP0054's new behavior the same condition will evaluate false.

Since most cmake provided modules have to work with both the old and new 
behavior a common work around is e.g.

	if("x${MYVAR}" STREQUAL "x")

This workaround however only works if by convention there are no 
variables starting with a lower case x in their name.

I think by that same reasoning you should avoid defining variables whose 
name is the empty string.

Nils


More information about the CMake mailing list