[CMake] 2 questions :)

Benoit Thomas benoit.thomas at gameloft.com
Wed Mar 10 17:53:13 EST 2010


Hello,

I have 3 projects, one library and 2 executables. Both executables 
depends on the library.

The library is legacy stuff, and I don't need to fully convert it to 
cmake so the cmakelists. txt looks something like this:

add_library(mylib STATIC IMPORTED)
set_target_properties(mylib PROPERTIES IMPORTED_LOCATION /someloc/mylib.lib)

My executables are full cmake projects and they have the following lines 
in order to "include" the library:

add_subdirectory (/mylib/src /mylib/bin)

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.

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 ?

Thanks a lot for all the help,
Ben.


More information about the CMake mailing list