[CMake] problems with LINK_DIRECTORIES

Brad King brad.king at kitware.com
Tue Sep 20 08:34:30 EDT 2005


Darko Miletic wrote:
> Hi to all,
> 
> I started to use CMake since version 2.05 and it was working to my
> satisfaction quite good. However I encountered a problem with beta
> version 2.2 and 2.2.1 in conjunction with borland compiler.
> 
> If I have a program in main.cpp that links o a external lib file located
> in some other folder and I specify that folder with LINK_DIRECTORIES and
> place it after ADD_EXECUTABLE it will not add directory to the link
> search folder list.
> 
> PROJECT(Test)
> 
> ADD_EXECUTABLE(Main main.cpp)
> 
> LINK_DIRECTORIES(C:/external/lib)
> 	
> Above will produce incorrect makefile in that way that it will not
> include added link_directories folder for linker search.
> 
> If I change the sample script to be like this:
> PROJECT(Test)
> 
> LINK_DIRECTORIES(C:/external/lib)
> 
> ADD_EXECUTABLE(Main main.cpp)
> 
> Everything works fine. In prevoious versions 2.0x it was working fine
> both ways.
> 
> Is this a bug or feature?

It is a feature because many people considered the old behavior a bug. 
That was part of the "removing CMake 1.2 compatibility" changes 
mentioned in the change log for this release.  Now only the include/link 
directories and libraries in effect when a target is added are used.

This is consistent with the more intuitive forward-order processing 
behavior that we've been trying to move towards since version 1.4.  This 
change probably should have been made over two releases with a 
deprecation message in-between but it seems to have slipped through the 
cracks.

-Brad


More information about the CMake mailing list