[sldev] Re: CMake 2.4.8 vs 2.6 (Re: Missing cares, apr in Mac build)

Bill Hoffman bill.hoffman at kitware.com
Fri Jul 18 13:55:44 PDT 2008


Bryan O'Sullivan wrote:
> On Fri, Jul 18, 2008 at 12:21 PM, Bill Hoffman <bill.hoffman at kitware.com> wrote:
> 
>> Sure, that is a warning, does the build still work?
> 
> No. It assumes that the libraries that it can't find are .obj instead
> of .lib (on Windows), and so fails at link time.
> 
OK, that is a different issue, and is related to policy CMP0003, but can 
only be fixed by changing the cmake code.   I think this happens when 
you do something like this:

target_link_libraries(myexe c:/path/to/foo)


In 2.4 that would be:

-LIBPATHc:/path/to/  foo.lib

(the correct code would be target_link_libraries(myexe c:/path/to/foo.lib)

However, if you used nmake or makefiles it would have with 2.4 since it 
would have put a depend into the makefile like this: c:/path/to/foo 
which would never exist and cause make to complain.  This should only 
happen if you give cmake a full path to a file that is not actually a 
library it can link to.   Is that the case you have, or is it something 
different?

> I'd rather fix the problem in a 2.6-compatible way, instead of
> suppressing some warning, but I've been out for a few weeks and it's
> not an especially high priority.
> 
OK, the fix is to set the policy to new.  Doing that is not suppressing 
the warning, it is changing the way cmake behaves.  We give the warning 
because there MIGHT be a problem at link time and we can't tell, so to 
be on the safe side we add extra -L stuff just to make sure things still 
work like the used to.  So, the 2.6 compatible way to fix this issue is 
to add this code:

if(COMMAND cmake_policy)
       cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)


By doing that it tells CMake, that you do not want/need the extra -L 
paths.  If a project had cmake_minimum_required(VERSION 2.6) at the top 
of it, you would not need to set that policy at all, as the default for 
2.6 is  CMP0003 = NEW.

Sorry that this is so confusing, I wish we could have gotten away 
without this confusing policy.   You are not the first to think that the 
above code is just doing a suppression of a warning message, and I am 
sure you won't be the last....   :)

-Bill


More information about the SLDev mailing list