View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015571CMakeModulespublic2015-05-16 16:182015-11-02 09:15
Reportergrahamb 
Assigned ToRolf Eike Beer 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product VersionCMake 3.2.2 
Target VersionCMake 3.3Fixed in VersionCMake 3.3 
Summary0015571: CheckTypeSize causes a CMP0054 warning
DescriptionUsing CheckTypeSize with CMake >= 3.1 causes a CMP0054 warning.

Setting the policy in the module to VERSION 3.1 fixes the issue. There may be other modules similarly afflicted.
Steps To ReproduceAny use of CheckTypeSize, e.g.

check_type_size(off64_t OFF64_T)
Additional InformationSample output:

CMake Warning (dev) at C:/ProgramData/Chocolatey/lib/cmake.3.1.3/content/cmake-3.1.3-win32-x86/share/cmake-3.1/Modules/CheckTypeSize.cmake:232 (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 "C" will no longer be dereferenced when the policy is
  set to NEW. Since the policy is not set the OLD behavior will be used.
Call Stack (most recent call first):
  C:/buildbot/wireshark/wireshark-master-32/Wireshark-win32-libs/zlib-1.2.8/CMakeLists.txt:43 (check_type_size)
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at C:/ProgramData/Chocolatey/lib/cmake.3.1.3/content/cmake-3.1.3-win32-x86/share/cmake-3.1/Modules/CheckTypeSize.cmake:115 (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 "C" will no longer be dereferenced when the policy is
  set to NEW. Since the policy is not set the OLD behavior will be used.
Call Stack (most recent call first):
  C:/ProgramData/Chocolatey/lib/cmake.3.1.3/content/cmake-3.1.3-win32-x86/share/cmake-3.1/Modules/CheckTypeSize.cmake:249 (__check_type_size_impl)
  C:/buildbot/wireshark/wireshark-master-32/Wireshark-win32-libs/zlib-1.2.8/CMakeLists.txt:43 (check_type_size)
This warning is for project developers. Use -Wno-dev to suppress it.
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0038751)
Rolf Eike Beer (developer)
2015-05-16 16:43

This should fix it:

 http://www.cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e9d726b1c5f584c0e475b86e09d433c5f22b5cac [^]

Please test and report back.
(0038752)
grahamb (reporter)
2015-05-16 17:39
edited on: 2015-05-16 17:39

Nope same warning. The problem seems to be the quoting of "C" rather than the language variable, as in the warning message.

(0038753)
Rolf Eike Beer (developer)
2015-05-17 04:13

Having a variable "C" will likely break a lot of stuff. Where does that come from?
(0038754)
grahamb (reporter)
2015-05-17 17:17

I think it's a false warning as there is no C variable.

However I want to get rid of the warning but can't as setting the policy in CMakeLists.txt does nothing due to the cmake_policy(VERSION 3.0) in the module.
(0038761)
Brad King (manager)
2015-05-18 10:09

Here is another approach:

 CheckTypeSize: Avoid if() auto-dereferene in quoted arguments
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=92146f3e [^]

A variable called "C" could be getting leaked from somewhere and does not necessarily have to be something your project sets. You can check with

 if(DEFINED C)
   message(...)
 endif()

just before the check_type_size call.
(0038762)
Rolf Eike Beer (developer)
2015-05-18 10:21

Since that module already uses policy push/pop I think it would be better to use my version and bump the required policy version. Those new policies were introduced for exactly that case, no?
(0038763)
Brad King (manager)
2015-05-18 10:28

Re 0015571:0038762: Fine with me. Please extend my topic for that and we'll squash it later.
(0038769)
grahamb (reporter)
2015-05-18 13:56

I have located the errant C variable within the main CMakeLists.txt, renaming it fixes the CMP0054 warnings. Sorry for the noise.

Shame CMake doesn't have "local" variables to prevent name clashes like this.
(0038770)
Brad King (manager)
2015-05-18 14:06

Re 0015571:0038769: Thanks, I'm glad you fixed it locally.

FYI, the purpose of CMP0054 is to reduce the cases where name clashes can occur.
(0038771)
Brad King (manager)
2015-05-18 14:13
edited on: 2015-05-19 13:04

Revised change with approach in 0015571:0038762:

 CheckTypeSize: Avoid if() auto-dereferene in quoted arguments
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6784f0a6 [^]

(0039815)
Robert Maynard (manager)
2015-11-02 09:15

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2015-05-16 16:18 grahamb New Issue
2015-05-16 16:43 Rolf Eike Beer Note Added: 0038751
2015-05-16 16:43 Rolf Eike Beer Assigned To => Rolf Eike Beer
2015-05-16 16:43 Rolf Eike Beer Status new => assigned
2015-05-16 16:43 Rolf Eike Beer Category CMake => Modules
2015-05-16 17:39 grahamb Note Added: 0038752
2015-05-16 17:39 grahamb Note Edited: 0038752
2015-05-17 04:13 Rolf Eike Beer Note Added: 0038753
2015-05-17 17:17 grahamb Note Added: 0038754
2015-05-18 10:09 Brad King Note Added: 0038761
2015-05-18 10:10 Brad King Status assigned => resolved
2015-05-18 10:10 Brad King Resolution open => fixed
2015-05-18 10:10 Brad King Fixed in Version => CMake 3.3
2015-05-18 10:10 Brad King Target Version => CMake 3.3
2015-05-18 10:21 Rolf Eike Beer Note Added: 0038762
2015-05-18 10:28 Brad King Note Added: 0038763
2015-05-18 13:56 grahamb Note Added: 0038769
2015-05-18 14:06 Brad King Note Added: 0038770
2015-05-18 14:13 Brad King Note Added: 0038771
2015-05-19 13:04 Brad King Note Edited: 0038771
2015-11-02 09:15 Robert Maynard Note Added: 0039815
2015-11-02 09:15 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team