[CMake] cmake 2.6 and find_library with MinGW generator

Bill Hoffman bill.hoffman at kitware.com
Wed May 21 10:44:49 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.
> 

OK, so you don't understand the warning.  Not your fault it is just hard 
to write as many others do not understand it.

Here is the problem:

We changed from -L/path/to -lA  to /path/to/library.  In some rare cases 
projects have something like this:

target_link_libraries(foo /path/to/libA.a B)

And B is actually in /path/to/libB.a

We have no easy way of telling the difference between the above and

target_link_libraries(foo /path/to/libA.a somesystemlib)

Where somesystemlib library can be found by the compiler.

So, we had two choices for 2.6:

1. Always add -L/path if there is at least one non-full path library 
linked in.  This makes extra long link lines.

2. Do not add -L/path and give no warning - we will break some projects 
with no warning, and the break will happen with a linker error during 
the build step.

So, what we did was do 1 by default, but give a warning.

So, to make a long story short, setting the policy to NEW is not 
"disabling" the warning, it is asking CMake to link libraries in the new 
better 2.6 way.  So, the correct fix is to set the policy to NEW, and if 
your stuff links then the warning was in error. If a project has 2.6 as 
the minimum require version there is no warning and things are always 
linked full path.

-Bill



More information about the CMake mailing list