[CMake] 2 questions :)

Benoit Thomas benoit.thomas at gameloft.com
Thu Mar 11 14:26:45 EST 2010


Hi,

Thanks for the answer, I'll use target_link_libraries for my dependency 
problem.

For the multiple add_library, someone else had the same problem (and 
explain it better than I did), and his solution also worked for me :)

Ben.

On 2010-03-11 09:42, Matt McCormick wrote:
>    
>> add_subdirectory (/mylib/src /mylib/bin)
>>      
> I'm surprised this works, but for good practice, I would leave out the first
> slash since it usually used to indicate an absolute path, i.e. mylib/src instead
> of /mylib/src.
>
>    
>> Everything works like a charm, but when I add a dependency
>>
>> add_dependencies (myproject mylib)
>>
>> It doesn't work, saying mylib is an unknown target. However, the same
>> things works for other projects which libraries are not imported. Am I
>> doing something wrong ? Or dependency on imported target is not
>> supported ? I know I could simplify my life with target_link_libraries,
>> but I'm trying to build a solid framework which would scale correctly if
>> mylib is converted to a full cmake project one day.
>>      
> CMake automagically defines the usual dependencies for you, so in most cases you
> don't have to worry about using add_dependencies.  Just use
> target_link_libraries.
>    
>> Also, if I'm trying to make a project with both executable in it, with
>> something like:
>>
>> add_subdirectory (/myexe1/src /myexe1/bin)
>> add_subdirectory (/myexe2/srr /myexe2/bin)
>>
>> since both project try to add the same lib, I get an error saying the
>> binary directory is already used (when doing exe2). Is there any way
>> around this problem or do I have to handle this situation manually ?
>>
>>      
> Not sure what you mean here.  add_library should be called once.
>
>
>
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
>    


More information about the CMake mailing list