[CMake] cmake 2.6 and find_library with MinGW generator

Brad King brad.king at kitware.com
Wed May 21 10:32:44 EDT 2008


Christian Ehrlicher wrote:
> I understood the warning - I know that it is not mandatory. But how useful is a warning when the only way to get rid of them is to disable it? I either have to fix all places (including the system libs) or disable it and don't care at all. That's stupid.

Adding the code the warning suggests does *not* disable it.  It is
actually a *fix* for the condition that produces the warning.  CMake is
telling you that it is enabling some old (bad) behavior for
compatibility because it has not been told that it is safe to use the
new behavior and is unable to detect whether it is safe.  The suggested code

  cmake_policy(SET CMP0003 NEW)

tells CMake to use the new behavior...it will actually produce a
*different link line* for the target.  If the project was not depending
on the old behavior it will just work.  However, if the project was
depending on the old behavior it will not link and then the offending
code will have to be fixed (add a link directory or use a full path for
the lib that cannot be found).  In that case the author that is adding
the line above can update the code too.  The key to the policy design is
that in either case joe user doesn't have to do anything to get the
project to build without modification.

Another way to tell CMake to use the new behavior is to require CMake
2.6 (which will get rid of this problem completely in the future):

  cmake_minimum_required(VERSION 2.6)

This is all explained by documentation:

http://www.cmake.org/Wiki/CMake_Policies
http://www.cmake.org/HTML/cmake-2.6.html#policy:CMP0003
http://www.cmake.org/Wiki/CMake_2.6_Notes#Missing_Linker_Search_Directories
cmake --help-policy CMP0003
cmake --help-command cmake_policy
cmake --help-command cmake_minimum_required

-Brad


BTW, the code

  cmake_policy(SET CMP0003 OLD)  # note OLD, not NEW

or the command line option -Wno-dev would be disabling the warning
without changing behavior.


More information about the CMake mailing list