[CMake] 3.3.0-rc1 feedback - CMP0046 doens't obey policy push

Miller Henry MillerHenry at JohnDeere.com
Wed Jun 10 18:12:20 EDT 2015


I'm trying out my project on 3.3.0-rc1, but currently I'm using 2.8.11 and 2.8.12.  I got  a couple errors from CMP0046.  Most of them are correct: I've fixed a couple places where a non-existent dependency was used, and I want to set this policy to NEW so that more do not sneak in.

However there is a problem. I have a test that dynamically loads a bunch of .so's, as configured by a .xml file to ensure they are compatible.  Some of the .so's are in the same project and some are from a different project and installed into the system at build time.  We are running tests as part of the make all target, (easy to do with a few add_custom_command/add_custom_target).  The obvious problem is this test needs to have all the .so's built before the test runs, but it doesn't link them.  This was easy enough - I just parsed the .xml for the name of the .so and place that name into an add_dependencies. That works great in cmake 2.8.11.

In cmake 3.3.0-rc1 it doesn't work.  Some of the .so's are installed on the system and not built in the project.  Obviously no target exists for them. What I want to do to solve this is:

      cmake_policy(PUSH)
         if(POLICY CMP0046)
            CMAKE_POLICY(SET CMP0046 OLD)
          endif()
             add_dependencies(${MyTestRunTarget} ${XML_PARSED_DEPENDENCIES})
      cmake_policy(POP)

This does not work.  It appears that the policy is not actually checked until long after the add_dependencies line is done processing, and the fact that I want to suppress the policy for just these is not carried along.

Is there some way to achieve changing this policy for just a few select targets?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150610/957040fc/attachment.html>


More information about the CMake mailing list