fix: adjust dynamic linking for cmake builds #1454
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes the building for dynamic libraries. After #1438 CMake was always building our internal library
canary_lib
as a static library, regardless of the building type. Canary_lib for now is just a way of centralizing all our code to use on tests, executable and others, so it has basically everything on it (external deps, multiple internal modules, pre-compiler headers, etc).Because of that, linking is now very slow, since it always need to link a huge static lib.
We want to allow flexibility, so if you wanna go static you can still use
BUILD_STATIC_LIBRARY
bo build everything statically. However, for tests and dynamic local development, it's quite handy that we provide a dynamic library as well.Change
When adding the library to CMake, we now define its state based on `BUILD_STATIC_LIBRARY``.
Context
Dynamic Libraries
Static Libraries
Choosing between them?
If you want a single, beefy file with no external dependencies, go static.
If you're cool with external files and like sharing code between apps, go dynamic.
Bonus
We're breaking down target_source into smaller chunks to improve visibility.