[cmake-developers] Patch for new warning caused by CMP0054

Rolf Eike Beer eike at sf-mail.de
Wed Nov 19 01:29:31 EST 2014


Fraser Hutchison wrote:
> Hi there,
> 
> CMake 3.1 (both release candidates) now generate a CMP0054 warning when
> configuring the following CMakeLists.txt in a clean build folder with MSVC
> as the generator:
> 
> cmake_minimum_required(VERSION 2.8)
> enable_language(ASM_MASM)
> 
> The warning is:
> 
> CMake Warning (dev) at E:/Program Files (x86)/CMake
> 3/share/cmake-3.1/Modules/CMakeFindBinUtils.cmake:33 (if): Policy CMP0054
> is not set: Only interpret if() arguments as variables or keywords when
> unquoted.  Run "cmake --help-policy CMP0054" for policy details.  Use the
> cmake_policy command to set the policy and suppress this warning.
> 
>   Quoted variables like "MSVC" will no longer be dereferenced when the
> policy is set to NEW.  Since the policy is not set the OLD behavior will be
> used.
> 
> I can see the file in question has been updated (presumably since RC2) to
> not quote the left-hand variables:
> http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/CMakeFindBinUtils.
> cmake;h=50cb9721272f98bc2ffe73e95ae57c3156251188;hb=HEAD but even with these
> updates, the quoted "MSVC" args generate the warning.
> 
> I've attached a trivial patch removing all remaining instances of quoted
> "MSVC"s.

Nope, this is wrong. What you now do is to compare it to the variable MSVC, 
which is true or false (or undefined). This wants to be compared to the string 
MSVC, so this probably needs to be changed to

if ("x${foo}" STREQUAL "xMSVC")

Greetings,

Eike
-- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20141119/04b4b368/attachment-0001.sig>


More information about the cmake-developers mailing list