noloader / cryptopp-cmake

CMake files for Crypto++ project
BSD 3-Clause "New" or "Revised" License
92 stars 68 forks source link

For cmake >= 3.1.0 use CMP0054 NEW to remove warning due to comparison with "MSVC" #19

Closed abdes closed 6 years ago

abdes commented 6 years ago
CMake Warning (dev) at CMakeLists.txt:200 (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.
Call Stack (most recent call first):
  CMakeLists.txt:220 (DumpMachine)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at CMakeLists.txt:367 (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.
This warning is for project developers.  Use -Wno-dev to suppress it.

These warnings are because we set the minimum required version of cmake to 2.8.12 while on the build environment we may be using a much more recent version.

noloader commented 6 years ago

Be careful of this one. I tried to work it in the past. When I removed the quotes to comply with policy it broke Windows builds with spaces in the path. It was the event that caused me to remove Cmake from the official sources.

abdes commented 6 years ago

The fix I propose is not to remove the quotes.

  if (NOT ${CMAKE_VERSION} VERSION_LESS "3.1.0")
    cmake_policy(SET CMP0054 NEW)
  endif ()

Testing it right now on windows with VS 2017 and cmake 3.11.2 ...

abdes commented 6 years ago

Build passed - No warnings and MSVC flags were correctly set.