FetchContent and multiple CMake projects

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

FetchContent and multiple CMake projects

Saad Khattak
Hi,

I have many independent CMake projects and most projects have external dependencies. Most of the projects have the same dependency e.g. Catch testing library. 

Each library uses FetchContent so that it can be built independently by simply cloning its github repository, configuring and generating through CMake and then building. However, I would also like the ability for these projects to share the same dependency to save disk space (and compile time) if they detect that another project already has done FetchContent on a particular dependency. 

Again, note that all projects are independent where their own repositories. 

------------------------------------------ EXAMPLE ----------------------------------------------
To illustrate the setup: I have LibA, LibB, LibC, LibD, LibE etc. where each may have a dependency that is found to be the same. So, when LibA is the only one that is cloned, it uses FetchContent to clone the dependencies, build them, install them and the test executable linked to the dependencies properly.

Now LibB is cloned and it has some dependencies that LibA doesn't have but other dependencies that LibA 'does' use. Assuming LibA is already built successfully, I would like LibB to rely on LibA's dependencies, if found, otherwise LibB clones, generates and builds its own dependencies.

It is also possible that LibA was never cloned/built and thus LibB must clone/generate/build all dependencies.
------------------------------------------ END EXAMPLE ----------------------------------------------

To solve this issue, I am using a combination of find_package(...) and FetchContent, however the whole setup is starting to show cracks, is fragile and difficult to test and maintain. So now I am wondering whether there is a better way to about solving the issue.

Thank you,
Saad

--

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
Reply | Threaded
Open this post in threaded view
|

Re: [Digital Signature Failure] FetchContent and multiple CMake projects

Dvir Yitzchaki

Check out Hunter package manager: https://github.com/ruslo/hunter

 

Regards,

Dvir

 

From: CMake <[hidden email]> On Behalf Of Saad Khattak
Sent: Friday, April 13, 2018 02:06
To: Cmake Mailing List <[hidden email]>
Subject: [Digital Signature Failure] [CMake] FetchContent and multiple CMake projects

 

Hi,

 

I have many independent CMake projects and most projects have external dependencies. Most of the projects have the same dependency e.g. Catch testing library. 

 

Each library uses FetchContent so that it can be built independently by simply cloning its github repository, configuring and generating through CMake and then building. However, I would also like the ability for these projects to share the same dependency to save disk space (and compile time) if they detect that another project already has done FetchContent on a particular dependency. 

 

Again, note that all projects are independent where their own repositories. 

 

------------------------------------------ EXAMPLE ----------------------------------------------

To illustrate the setup: I have LibA, LibB, LibC, LibD, LibE etc. where each may have a dependency that is found to be the same. So, when LibA is the only one that is cloned, it uses FetchContent to clone the dependencies, build them, install them and the test executable linked to the dependencies properly.

 

Now LibB is cloned and it has some dependencies that LibA doesn't have but other dependencies that LibA 'does' use. Assuming LibA is already built successfully, I would like LibB to rely on LibA's dependencies, if found, otherwise LibB clones, generates and builds its own dependencies.

 

It is also possible that LibA was never cloned/built and thus LibB must clone/generate/build all dependencies.

------------------------------------------ END EXAMPLE ----------------------------------------------

 

To solve this issue, I am using a combination of find_package(...) and FetchContent, however the whole setup is starting to show cracks, is fragile and difficult to test and maintain. So now I am wondering whether there is a better way to about solving the issue.

 

Thank you,

Saad


--

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