[CMake] Visual Studio - dependencies

Bill Hoffman bill.hoffman at kitware.com
Thu Apr 19 15:25:27 EDT 2007


Vitor Vasconcelos Araujo Silva wrote:
>
>
>
>>> [...]So, the question: Is it possible to control this kind of 
>>> dependecies/behavior from CMakeLists files?
>>
>> Yes.  Look up ADD_DEPENDENCIES at 
>> http://cmake.org/HTML/Documentation.html.
>>
>> Alan
>
>     Thanks Alan, but it doesn't help. If I use it, I cannot build the 
> Visual Studio project, because the dependence is a library that I 
> intend to build inside my project.
>     Well, maybe I'm doing something wrong, but I almost sure I cannot 
> add a library as a dependence before have it built. So, my problem 
> continues...
>     Thanks a lot,
You are doing something wrong, but with out some more examples it is 
hard to tell what.   add_dependency should not be required.

> I'm guessing CMake bets on directory flow to set those dependencies.
That would be a bad bet.   CMake does not do that, and you were just 
lucky on UNIX.  I would be that make -j N would not work for your 
project for N > 1.   Since I can not see your cmake files, I can only 
guess.   My guess is that you are not using target_link_libraries correctly.

You should have something like this:

add_library(foo ...)
add_exectuable(bar ...)
target_link_libraries(bar foo)

I am guessing you have something like this:
target_link_libraries(bar /some/path/to/foo) 
So, cmake is not treating foo as a target that it knows how to build, 
but rather an external library that is assumed to exist.

-Bill




More information about the CMake mailing list