1
0
Fork 0
mirror of https://github.com/TheLartians/ModernCppStarter.git synced 2025-08-30 13:41:13 +02:00

add paragraph about the evilness of conditional includes (#9)

This commit is contained in:
Lars Melchior 2020-04-14 17:15:51 +02:00 committed by GitHub
parent 6808aaf01c
commit a2a6674101
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -87,6 +87,12 @@ See [Format.cmake](https://github.com/TheLartians/Format.cmake) for more options
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?
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 this to a separate repository and list a specific version or commit of the main project.
- You recommend to add external dependencies using CPM.cmake. Will this force users of my library to use CPM as well?
[CPM.cmake](https://github.com/TheLartians/CPM.cmake) should be invisible to library users as it's a self-contained CMake Script.