[CMake] Project dependencies

Benjamin Eikel cmake at eikel.org
Fri Apr 16 05:32:39 EDT 2010


Hello,

maybe my first post was not clear enough.
I created a minimal example to demonstrate what I mean (see attached files).
That example contains a library called MyLib and a binary called MyBin. The 
enclosed shell script can be used to build the binary on Linux. At first the 
library will be configured such that the file "MyLibConfig.cmake" will be 
created. After that the binary will be configured and a build will be started. 
The build will fail because the library was intentionally not build before. 
After that another way of including the library is used. The second 
"CMakeLists.txt" file uses add_subdirectory to reference the library. When 
issuing a make command now, the library will be built automatically.
My question is if it is possible to achieve this behavior when using the 
approach mentioned first. This would make things easier in our projects when 
there are multiple dependencies to different libraries which will be changed 
often and a build of the binary should be triggered automatically.

Kind regards,
Benjamin

Am Mittwoch, 14. April 2010 11:49:01 schrieb Benjamin Eikel:
> Hello,
> 
> we are using CMake to build different binaries which depend on some
>  libraries, that we develop ourselves. At the moment we export the settings
>  from the build directories of the libraries using export(...
>  lib-build.cmake ...). The CMakeLists.txt of a binary uses an own CMake
>  module using find_package(), in which we check for the "lib-build.cmake"
>  file. If it exists, it is included and the library variable is set to the
>  imported TARGET. Otherwise the library is searched with find_library and
>  used as dependency.
> The build works without problems if the libraries are built first and the
> binary afterwards. I am wondering if it is possible to trigger an automatic
> build of the libraries when building the binary. For example the libraries
> should be built if they have not been built yet or there have been changes
>  to the source files.
> I think, if the library projects were integrated into the build using
> add_subdirectory(), this will work.
> Because we additionally let CMake generate Eclipse projects, it would be
>  nice if the library projects which are exported and imported by the binary
>  project, will be marked as references of the binary project (Project ->
>  Properties -> Project References).
> For the record: We are using CMake in version 1.8.1 under GNU/Linux and
> Windows.
> 
> Kind regards,
> Benjamin
> _______________________________________________
> 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
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmake_example.tar.gz
Type: application/x-compressed-tar
Size: 957 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100416/1ddab83d/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmake_example.sh
Type: application/x-shellscript
Size: 617 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100416/1ddab83d/attachment-0001.bin>


More information about the CMake mailing list