On 06/10/2015 10:11 AM, Arunava Nag wrote:
> cmake_minimum_required(VERSION 2.8)
[snip]
> if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
[snip]
> CMake Warning (dev) at CMakeLists.txt:6 (if):
>   Policy CMP0054 is not set: Only interpret if() arguments as variables or

The policy is documented here:

 http://www.cmake.org/cmake/help/v3.3/policy/CMP0054.html

In this case CMAKE_CXX_COMPILER_ID is "MSVC" so

 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")

after expansion of variable references becomes:

 if ("MSVC" STREQUAL "Clang")

but there is also a variable named "MSVC" set to "1" meant
for code to be able to do if(MSVC) to check for that compiler
(left from before we had CMAKE_<LANG>_COMPILER_ID).  The
if() command expands that variable so it becomes

 if ("1" STREQUAL "Clang")

This is not the check that was intended by the above code but
happens to get the right answer by accident.  For this reason
CMP0054 was introduced to get rid of the if() command's
auto-dereference behavior in quoted arguments.

You can either change your cmake_minimum_required call to

 cmake_minimum_required(VERSION 3.1)

or add the lines

 if (POLICY CMP0054)
   cmake_policy(SET CMP0054 NEW)
 endif()

to fix evaluation of the conditional.  Or you can change the
conditional to another form that does not hit this case at all:

 if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")

-Brad

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to