2
votes

In my whole code I never use LINK_INTERFACE_LIBRARIES or something similar. All install, export and link_* command are used without.The only somewhat similar occurrence I was able to grep was in the build directory in the file lib/CMakeFiles/Export/lib/cmake/mylib-targets-noconfig.cmake:

IMPORTED_LINK_INTERFACE_LANGUAGES_NOCONFIG "CXX" IMPORTED_LINK_INTERFACE_LIBRARIES_NOCONFIG

Still, I get a CMP0022 warning:

CMake Warning (dev) in lib/CMakeLists.txt: Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link interface. Run "cmake --help-policy CMP0022" for policy details. Use the cmake_policy command to set the policy and suppress this warning.

Target "mylib" has an INTERFACE_LINK_LIBRARIES property. This should be preferred as the source of the link interface for this library but because CMP0022 is not set CMake is ignoring the property and using the link implementation as the link interface instead.

INTERFACE_LINK_LIBRARIES:

This happens when I link an external library to mylib. When I use CMake 2.8.12.1 which improved the handling of CMP0022 compared to 2.8.12 the number of warnings is massively reduced and I get only one warning per external library.

What causes the warning? From the documentation I don't get it.
What should I do to get rid of this warning? Is this compatible to older versions?

3

3 Answers

2
votes

CMake 2.8.12.1 was released to address this issue. Please try that version.

2
votes

In the meantime there was a similar question posted to the CMake mailing list. Stephen Kelly answered there are three options. [1, 2] The one I liked most uses LINK_PRIVATE and LINK_PUBLIC. But it is only backwards compatible to CMake 2.8.9.

-4
votes

Try putting this block:

IF(COMMAND CMAKE_POLICY)

  CMAKE_POLICY(SET ???? OLD)

  CMAKE_POLICY(SET ???? OLD)

ENDIF(COMMAND CMAKE_POLICY)

WHERE ???? is the name of the offending policy

I haven't read much about this yet, but I think is because they added a mechanism to set the target properties to avoid ambiguities when dealing with different targets, in any case, if a new version of CMake warns you about some policy you can set that policy to an old behavior.

https://cmake.org/cmake/help/v3.0/policy/CMP0022.html