Discussion:
[cmake-developers] Using CMake to build big projects with cross-dependencies
Kinga Kasa
2018-05-17 09:56:25 UTC
Permalink
Dear CMake Developers Team,

I have a question regarding CMake. We are currently working on a rather big project and we would like to build it with CMake.
The structure of the project looks like the following: we have a root directory where we have 50+ subdirectories with projects in them with their own CMakeLists.txt files.
These subprojects are successfully built with cmake on their own. What we would like to do now is building the whole project together. It would be really easy (with add_subdirectories or include or ExternalProject_Add, we tried all of these) but the problem is that these subprojects are depending on each other and building the whole project with these will result in the cmake running for hours and hours (stuck at saying Configuring done, eventually it will finish, but it runs for hours).
We implemented in these cmake files our own logic to not to generate and build the same subprojects multiple times (using a property, which is a list, where we store the already included targets name and every time we try to add a new target it checks whether its already included or not).
We would be glad if you could help us out with some advice on how to accomplish building the whole big project without building some targets multiple times but building it effectively without having to wait hours for the cmake to run.

Thank you in advance,
Kinga Kása
Brad King
2018-05-17 15:46:56 UTC
Permalink
Post by Kinga Kasa
cmake running for hours and hours (stuck at saying Configuring done,
eventually it will finish, but it runs for hours).
That's not expected. Even on projects with tens of thousands of
source files and thousands of libraries and executables it typically
takes only a few minutes. You could try breaking in the debugger
locally during generation to see what it's doing. Or, you could
try bisecting your project's content to get a smaller example that
reproduces the long generation time.
Post by Kinga Kasa
ExternalProject_Add
We typically use this on very large projects to avoid any individual
build taking too long.

-Brad
--
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:
https://cmake.org/mailman/listinfo/cmake-developers
Bill Hoffman
2018-05-17 17:59:36 UTC
Permalink
Post by Brad King
Post by Kinga Kasa
cmake running for hours and hours (stuck at saying Configuring done,
eventually it will finish, but it runs for hours).
That's not expected. Even on projects with tens of thousands of
source files and thousands of libraries and executables it typically
takes only a few minutes. You could try breaking in the debugger
locally during generation to see what it's doing. Or, you could
try bisecting your project's content to get a smaller example that
reproduces the long generation time.
Another quick way to see what is going on is to run cmake with the
--trace option:
cmake . --trace

It will produce a lot of output but you should be able to see if it is
repeating something or getting stuck on some operation.

-Bill
--
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:
https://cmake.org/mailman/listinfo/cmake-developers
Loading...