CMP0054 and CMake Modules

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

CMP0054 and CMake Modules

Jörg Kreuzberger
Updated to cmake 3.2.1 from 3.0.0 and got several hints due to POLICY CMP0054 (handling of quoted variables)

i set the policy to new and changed my local cmake files.

But i also got a warning from CMake Modules like FindMFC.cmake (Line 39).

do i make something wrong or is this an Error in FindMFC which i have to report?

Can i assume that ALL Modules provided with normal cmake install support this policy with NEW?
Currently i get no warning from other modules if policy is unset.
i also assume i can change the policy during cmake processing?

(e.g. set the behaviour to old, include FindMFC.cmake, set the behaviour to new and do the rest of my CMakeLists.txt)

Thanks for any support,
Joerg

--

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
Reply | Threaded
Open this post in threaded view
|

Re: CMP0054 and CMake Modules

Domen Vrankar
> do i make something wrong or is this an Error in FindMFC which i have to report?

ATM each CMake provided module has to set its own policies otherwise
policies from CMakeLists.txt minimum required version setting are
used.
Please file a bug report.

Thanks,
Domen
--

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
Reply | Threaded
Open this post in threaded view
|

Re: CMP0054 and CMake Modules

thoni56
I can't find a bug report on this. Is there one?

Surely Cmake distributed modules should not generate this type of warnings. Or am I misinterpreting the messages?

I'm encountering numerous such problems/warnings in Cmake distributed modules:

CMake Warning (dev) at /usr/share/cmake-3.3.1/Modules/CMakeParseImplicitLinkInfo.cmake:58 (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 "" 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):
  /usr/share/cmake-3.3.1/Modules/CMakeDetermineCompilerABI.cmake:80 (CMAKE_PARSE_IMPLICIT_LINK_INFO)
  /usr/share/cmake-3.3.1/Modules/CMakeTestCXXCompiler.cmake:68 (CMAKE_DETERMINE_COMPILER_ABI)
  src/CMakeLists.txt:2 (project)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at /usr/share/cmake-3.3.1/Modules/CMakeParseImplicitLinkInfo.cmake:39 (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 "" 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):
  /usr/share/cmake-3.3.1/Modules/CMakeDetermineCompilerABI.cmake:80 (CMAKE_PARSE_IMPLICIT_LINK_INFO)
  /usr/share/cmake-3.3.1/Modules/CMakeTestCXXCompiler.cmake:68 (CMAKE_DETERMINE_COMPILER_ABI)
  src/CMakeLists.txt:2 (project)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at /usr/share/cmake-3.3.1/Modules/CMakeParseImplicitLinkInfo.cmake:100 (elseif):
  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 "" 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):
  /usr/share/cmake-3.3.1/Modules/CMakeDetermineCompilerABI.cmake:80 (CMAKE_PARSE_IMPLICIT_LINK_INFO)
  /usr/share/cmake-3.3.1/Modules/CMakeTestCXXCompiler.cmake:68 (CMAKE_DETERMINE_COMPILER_ABI)
  src/CMakeLists.txt:2 (project)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning (dev) at /usr/share/cmake-3.3.1/Modules/CTest.cmake:96 (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 "" 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):
  /usr/share/cmake-3.3.1/Modules/CTest.cmake:106 (SET_IF_SET_AND_NOT_SET)
  cmake/Modules/MacroAddUnitTest.cmake:10 (include)
  CMakeLists.txt:64 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at /usr/share/cmake-3.3.1/Modules/CTest.cmake:251 (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 "" 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):
  cmake/Modules/MacroAddUnitTest.cmake:10 (include)
  CMakeLists.txt:64 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.
Reply | Threaded
Open this post in threaded view
|

Re: CMP0054 and CMake Modules

thoni56
Sorry, this turned out kind of brief, it was posted in context in Nabble.

I'm seeing this on Cygwin.

/Thomas

21 september 2015 09:37
I can't find a bug report on this. Is there one?

Surely Cmake distributed modules should not generate this type of warnings.
Or am I misinterpreting the messages?

I'm encountering numerous such problems/warnings in Cmake distributed
modules:

CMake Warning (dev) at
/usr/share/cmake-3.3.1/Modules/CMakeParseImplicitLinkInfo.cmake:58 (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 "" 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):
/usr/share/cmake-3.3.1/Modules/CMakeDetermineCompilerABI.cmake:80
(CMAKE_PARSE_IMPLICIT_LINK_INFO)
/usr/share/cmake-3.3.1/Modules/CMakeTestCXXCompiler.cmake:68
(CMAKE_DETERMINE_COMPILER_ABI)
src/CMakeLists.txt:2 (project)
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at
/usr/share/cmake-3.3.1/Modules/CMakeParseImplicitLinkInfo.cmake:39 (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 "" 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):
/usr/share/cmake-3.3.1/Modules/CMakeDetermineCompilerABI.cmake:80
(CMAKE_PARSE_IMPLICIT_LINK_INFO)
/usr/share/cmake-3.3.1/Modules/CMakeTestCXXCompiler.cmake:68
(CMAKE_DETERMINE_COMPILER_ABI)
src/CMakeLists.txt:2 (project)
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at
/usr/share/cmake-3.3.1/Modules/CMakeParseImplicitLinkInfo.cmake:100
(elseif):
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 "" 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):
/usr/share/cmake-3.3.1/Modules/CMakeDetermineCompilerABI.cmake:80
(CMAKE_PARSE_IMPLICIT_LINK_INFO)
/usr/share/cmake-3.3.1/Modules/CMakeTestCXXCompiler.cmake:68
(CMAKE_DETERMINE_COMPILER_ABI)
src/CMakeLists.txt:2 (project)
This warning is for project developers. Use -Wno-dev to suppress it.

-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning (dev) at /usr/share/cmake-3.3.1/Modules/CTest.cmake:96 (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 "" 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):
/usr/share/cmake-3.3.1/Modules/CTest.cmake:106 (SET_IF_SET_AND_NOT_SET)
cmake/Modules/MacroAddUnitTest.cmake:10 (include)
CMakeLists.txt:64 (include)
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at /usr/share/cmake-3.3.1/Modules/CTest.cmake:251 (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 "" 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):
cmake/Modules/MacroAddUnitTest.cmake:10 (include)
CMakeLists.txt:64 (include)
This warning is for project developers. Use -Wno-dev to suppress it.



--
View this message in context: http://cmake.3232098.n2.nabble.com/CMP0054-and-CMake-Modules-tp7590137p7591577.html
Sent from the CMake mailing list archive at Nabble.com.
26 mars 2015 10:48

ATM each CMake provided module has to set its own policies otherwise
policies from CMakeLists.txt minimum required version setting are
used.
Please file a bug report.

Thanks,
Domen
26 mars 2015 10:29
Updated to cmake 3.2.1 from 3.0.0 and got several hints due to POLICY CMP0054 (handling of quoted variables)

i set the policy to new and changed my local cmake files.

But i also got a warning from CMake Modules like FindMFC.cmake (Line 39).

do i make something wrong or is this an Error in FindMFC which i have to report?

Can i assume that ALL Modules provided with normal cmake install support this policy with NEW?
Currently i get no warning from other modules if policy is unset.
i also assume i can change the policy during cmake processing?

(e.g. set the behaviour to old, include FindMFC.cmake, set the behaviour to new and do the rest of my CMakeLists.txt)

Thanks for any support,
Joerg



--

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
Reply | Threaded
Open this post in threaded view
|

Re: CMP0054 and CMake Modules

Nils Gladitz-2
In reply to this post by thoni56
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
--

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
Reply | Threaded
Open this post in threaded view
|

Re: CMP0054 and CMake Modules

thoni56
Aahh, I was looking at the trace and it only included "include":s so I thought that offending IF was in cmake's own files since it pointed there.

But, you are saying that probably the culprit is a variable set before the first include, right? (It was definitely not by intention a variable was as having the empty name ;-).

And if I look at /usr/share/cmake-3.3.1/Modules/CMakeParseImplicitLinkInfo.cmake:58 I should probably see the variable (or one that expands to include it)?

/Thomas

Nils Gladitz-2 wrote
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.

...

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
--

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
Reply | Threaded
Open this post in threaded view
|

Re: CMP0054 and CMake Modules

thoni56
Also, this does not happen on MacOSX with Macports cmake. But does on Cygwin.
thoni56 wrote
Nils Gladitz-2 wrote
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.

...

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
--

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
Reply | Threaded
Open this post in threaded view
|

Re: CMP0054 and CMake Modules

Nils Gladitz-2
In reply to this post by thoni56
On 09/21/2015 10:24 AM, thoni56 wrote:
> Aahh, I was looking at the trace and it only included "include":s so I
> thought that offending IF was in cmake's own files since it pointed there.
>
> But, you are saying that probably the culprit is a variable set before the
> first include, right? (It was definitely not by intention a variable was as
> having the empty name ;-).

The culprit is the empty named variable being set before the condition
in that included module is evaluated, yes.

If you aren't the one setting it it might also be accidentally set
somewhere in cmake code of course.

It probably isn't something as obvious as set("" foobar) but perhaps
something like e.g. set("${MY_VAR_NAME}" foobar) (where MY_VAR_NAME is
an unset variable e.g. due to typo or unexpected program logic).

>
> And if I look at
> /usr/share/cmake-3.3.1/Modules/CMakeParseImplicitLinkInfo.cmake:58 I should
> probably see the variable (or one that expands to include it)?

The condition in that line is:
        if("${cmd}" MATCHES "${linker_regex}")

So apparently ${cmd} expands empty (which may or may not be expected but
is a distinct issue).

With old behavior cmake will therefor look for a variable with the empty
name and in your case finds and expands it.

If you don't know where the empty named variable might come from I would
expect cmake's new --trace-expand might be helpful.

I haven't tried it myself yet and you would have to use a nightly build
though since it hasn't made it into a release yet.

Nils
--

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
Reply | Threaded
Open this post in threaded view
|

Re: CMP0054 and CMake Modules

thoni56
Any idea why this only happens on Cygwin? Not on Linux or MacOSX. Is this a clue to something? How can I use this information to debug the issue further?

/Thomas
Reply | Threaded
Open this post in threaded view
|

Re: CMP0054 and CMake Modules

Nils Gladitz-2
On 09/25/2015 11:03 AM, thoni56 wrote:
> Any idea why this only happens on Cygwin? Not on Linux or MacOSX. Is this a
> clue to something? How can I use this information to debug the issue
> further?

There are platform and compiler specific cmake modules which may only
get processed when using cygwin.

Your project might use conditionals that only evaluate true on cygwin
like e.g. the obvious if(CYGWIN) ... endif().

Beyond the aforementioned --trace-expand you could also try inserting
something like the following snippet to the very top (before anything
else) of your root-CMakeLists.txt:

        function(my_watch)
            message("-----------------")
            foreach(ARG ${ARGN})
                message("[${ARG}]")
            endforeach()
        endfunction()

        variable_watch("" my_watch)

If you do not have an explicit project() call in your
root-CMakeLists.txt yet add one; otherwise the implicit project() call
that cmake injects will be evaluated before the rest of your CMakeLists.txt.

It should print out locations (sadly apparently without line numbers)
where the empty named variable is accessed.

That way you might be able to find the first file that modifies the
empty named variable at least (probably the first with "MODIFIED_ACCESS").

Nils
--

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