[CMake] 2 questions :)
Matt McCormick
matt at mmmccormick.com
Thu Mar 11 09:42:03 EST 2010
>
> 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.
More information about the CMake
mailing list