[CMake] Cmake 2.6.0 release and _Util project on Visual studio 2003

Bill Hoffman bill.hoffman at kitware.com
Fri May 9 08:39:05 EDT 2008


Markus Israelsson wrote:
> Hello,
>  
> I am wondering if anyone can shed some light on where the 
> <ProjectName>_Util projects come from and why they are constructed for 
> visual studio 2003 when using the ADD_DEPENDENCIES property of CMake. 
> They do not show up when generating project for other versions of visual 
> studio and do not show up when using version 2.4.8 of CMake.
>  
> What I have done is basically this (pseudo-code, hope it is understandable):
>  
> PROJECT( FirstProject )
>  
> ADD_SUBDIRECTORY( SecondProject ) - adds a library called SecondProject.
> ADD_LIBRARY( FirstProject )
> 
> ADD_DEPENDENCIES( FirstProject SecondProject )
>  
> This will create a solution file with these project in visual studio 
> 2005 and 2008.
>  
> ALL_BUILD
> FirstProject
> SecondProject
> ZERO_CHECK
>  
> FirstProject depends on SecondProject when checking dependency setting 
> in visual studio.
>  
> However for visual studio 2003 the solution file will look like this.
>  
> ALL_BUILD
> FirstProject
> SecondProject
> SecondProject_UTIL
> ZERO_CHECK
>  
> FirstProject will depend on SecondProject_UTIL which depends on 
> SecondProject. This will of course give a lot of linking errors when 
> building. Firstly because the _UTIL project is empty, neither Pre-Build 
> Events nor Post-Build Events are set. Secondly because the _UTIL project 
> is never built by default.
>  
> In order to fix this I have to manually correct the dependencies for 
> visual studio 2003. Pretty irritating since when anything is changed in 
> the CMakeLists used for generating the solution file the dependencies 
> has to be fixed again.
>  
> Every project that some other project is dependent on generates this 
> extra _UTIL project.
>  
> Hope anyone can shed some light on the use of this or have encountered 
> the problem.
>  
> best regards, appreciate any help,
> Markus

HMMM....

This was done to avoid something you seem to have been depending on.  If 
you depend on a project directly with static libraries vs 2003 creates a 
combined library.  So, in your case FirstProject would have all the 
objects of FirstProject and SecondProject in it.  This does not happen 
on any other platform.  The only thing the add_dependencies is supposed 
to do is make sure that FirstProject is BUILT before SecondProject.  It 
is not supposed to combine them.  This was a bug in earlier versions of 
CMake.   Also, for VS 2008 this does not happen.  However, if this is a 
full CMake project then it should not be a problem since anything that 
links to FirstProject will automatically link to SecondProject.

-Bill


More information about the CMake mailing list