From e1c632bf78e9394069a0e19b81d9dccabe01bbf4 Mon Sep 17 00:00:00 2001 From: Lars Melchior Date: Mon, 20 Apr 2020 09:33:16 +0200 Subject: [PATCH] update section on including additional projects (#22) --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index dadf00f..c5cf04d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![codecov](https://codecov.io/gh/TheLartians/ModernCppStarter/branch/master/graph/badge.svg)](https://codecov.io/gh/TheLartians/ModernCppStarter)

- +

# ModernCppStarter @@ -18,7 +18,7 @@ This template is the result of learnings from many previous projects and should - [Modern CMake practices](https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/) - Suited for single header libraries and projects of any scale -- Separation into library and executable code +- Clean separation of library and executable code - Integrated test suite - Continuous integration via [GitHub Actions](https://help.github.com/en/actions/) - Code coverage via [codecov](https://codecov.io) @@ -104,11 +104,11 @@ Simply remove the standalone directory and github workflow file. Glob is considered bad because any changes to the source file structure [might not be automatically caught](https://cmake.org/cmake/help/latest/command/file.html#filesystem) by CMake's builders and you will need to manually invoke CMake on changes. I personally prefer the `GLOB` solution for its simplicity, but feel free to change it to explicitly listing sources. -> I want to add additional targets to my project. Should I modify the main CMakeLists to conditionally include them? +> I want create additional targets that depend on my library. Should I modify the main CMakeLists to include them? -If possible, avoid adding conditional includes to the CMakeLists (even though it is a common sight in the C++ world), as it makes the build system convoluted and hard to reason about. -Instead, create a new directory with a CMakeLists that adds the main project as a dependency (e.g. just copy the [standalone](standalone) directory). -Depending on the complexity of the project it might make sense move the components into separate repositories and use CPM.cmake to add them as dependencies. +Always avoid including derived projects from the from the libraries CMakeLists (even though it is a common sight in the C++ world), as this effectively inverts the dependency tree and makes the build system hard to reason about. +Instead, create a new directory or project with a CMakeLists that adds the library as a dependency (e.g. like the [standalone](standalone/CMakeLists.txt) directory). +Depending type it might make sense move these components into a separate repositories and reference a specific commit or version of the library. This has the advantage that individual libraries and components can be improved and updated independently. > You recommend to add external dependencies using CPM.cmake. Will this force users of my library to use CPM as well?