On 2014-02-06 01:14, PCMan wrote:
We're migrating from gtk+ to Qt and autotools to CMake and encountered
some issues.
There are many small modules or components in our project.
Each of them has their own CMakeLists.txt and can be built separately.
However, it's hard to build so many projects manually.
So we'd like to create a toplevel CMakeLists.txt to build them all at once.
However, the small projects depend on each other.
For example, our project layout look like this:
libqtxdg - a base lib required by others
liblxqt - a library depends on libqtxdg
lxqt-config - a tool depends on liblxqt and libqtxdg.
To build lxqt-config, liblxqt and libqtxdg need to be "installed" first.
So simply adding them using add_subdirectoyy() won't work.
This sounds like a classic superbuild problem.
As an alternative, you could make sure that all of your sub-projects
build CMake package configuration files with modern exported targets¹,
and then conditionally do a find_package for your dependencies if not
being built from the "root build". Then each sub-project uses its
dependencies by target name, which in theory should make transparent
whether they're being built all from the same "root build" or
independently. (And you won't need to install each sub-project before
building the next.)
(¹ Even if you don't go with this overall solution, using
exported/imported targets is good practice that I would strongly
encourage you to pursue anyway, if you aren't already doing that.)
Even worse, two of our components are still automake-based.
The cmake ExternalProject_Add() command did not solve the problem that
some of them needs to be "installed" first before others can be
compiled.
For this you will need to use a superbuild, i.e. your dependee projects
must also be built via ExternalProject_Add(). If the dependency projects
aren't huge, it might be better to just port them to CMake.
--
Matthew
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake