[CMake] Visual Studio problem with many/long additional library paths

Brad King brad.king at kitware.com
Thu Apr 20 15:39:13 EDT 2006


Karr, David A (Titan) @ TITAN wrote:
>>From: Kristian Nielsen <knielsen at mysql.com>
>>This generates the following long line in mysqld.vcproj:
> I have not yet encountered the line length limit in Visual Studio, but I
> have found the length of the directory list makes it hard sometimes to
> debug problems with missing/wrong libraries in the path.  I have noticed
> that for every library you name in a TARGET_LINK_LIBRARIES command, two
> directory names are generated: one of them ends with the name of the
> library, for example "...\myisam\", and the other ends with OutDir, for
> example "...\myisam\$(OutDir)".  In my own projects, as far as I can
> tell, the OutDir directories never exist, so listing them effectively
> more than doubles the length of the list without adding any benefit.
> 
> It would be helpful (at least in my case) to be able to turn off the
> production of the "OutDir" directories in this list, I just haven't
> gotten around to figuring out how.  Is there a simple way to control
> this?

Both directories are always added.  This is hard-coded in the VS7 
generator.  The reason is that it is not known when the user specifies a 
link directory in CMake code whether that directory points directly at a 
library or points to another CMake build tree in which there are 
per-configuration subdirectories.  With the information about link 
libraries and directories currently available from CMakeLists.txt files 
it is not possible to compute which path is needed.

We do have plans to add a way to provide the extra information needed to 
compute the proper link directories exactly but this requires a few 
major changes and will not be done soon.

> My own lists of libraries tend to be bloated by the repetition of some
> directories (i.e. the exact same directory at different points in the
> string), but I think this has something to do with the fact that I am
> naming libraries in TARGET_LINK_LIBRARIES that are themselves built by
> CMake and they have their own TARGET_LINK_LIBRARIES commands.  Sometimes
> a project depends on libraries X and Y where X also depends on Y, and I
> think this makes Y show up twice.  But that seems like a harder problem
> to solve, and I don't really expect there to be a fix for it.

CMake in CVS removes duplicate directories automatically.  It also 
computes a safe order for the link directories to make sure the proper 
libraries are found by the linker.  I've just modified the VS7 generator 
to use for each link directory either a relative path or a full path, 
whichever is shorter.  This should minimize the string length.  These 
changes will be included in the upcoming 2.4 release.

-Brad


More information about the CMake mailing list