[CMake] Several subprojects in subdirectories

Filipe Sousa filipe at ipb.pt
Wed Nov 9 05:12:20 EST 2005


On Wednesday 09 November 2005 08:06, Igor Polyakov wrote:
> Hello, cmake.
>
> I have a directory, where my project is located.
> I have three subprojects within subdirectories: "lib", "src" and
> "tests" and coresponding source files within each of these subdirectories.
>
> Subprojects have the following dependencies: src -> lib, tests -> lib.
>
> I want to have ability to build all of these subprojects at one time
> or build one of them or (more, if there are out-of-date dependencies
> between subprojects).
>
> How could I do this with CMake ?
>
> What I've done:
> I've written CMakeLists.txt within each of subdirectories, each of
> these files specifying, how to make one of subprojects. And I have
> written CMakeLists.txt in the top directory with only one line:
> SUBDIRS(lib src tests)
>
> What problems do I have:
> I don't know, how to specify, that subproject src is dependent from
> subproject lib, so it should be built only after library is created.
>
> I tried in src directory:
> 1.
> TARGET_LINK_LIBRARIES(${MyExe} ../lib/MyLib.lib)
> Doesn't work, because CMake requires absolute paths.

You don't need absolute or relative paths. 
Just TARGET_LINK_LIBRARIES(${MyExe} MyLib)

> 2.
> FIND_LIBRARY(MyLibPath NAMES MyLib PATHS ${MyExe_SOURCE_DIR}/../lib)
> TARGET_LINK_LIBRARIES(${MyExe} ${MyLibPath})
> Doesn't work when I build "src", when "lib" is not built - CMake could
> not find library with such name.
>
> What am I missing ? Please, help !

-- 
If your bread is stale, make toast.
--
Filipe Sousa
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/cmake/attachments/20051109/096b436d/attachment.pgp


More information about the CMake mailing list