[cmake] Fix handling of BUILD_SHARED_LIBS option #201
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.
BUILD_SHARED_LIBS option is declared conditionally on whether BUILD_SHARED_LIBS is defined itself. This is problematic as multiple invocations of a build runner such as ninja will cause builds to use different options. The first build will run as if BUILD_SHARED_LIBS is not defined (i.e. OFF option), the second time cmake will notice that BUILD_SHARED_LIBS was defined after all and now run build with BUILD_SHARED_LIBS set to ON. This is confusing and error prone.
To fix the problem, a top-level BUILD_SHARED_LIBS option has been added and BUILD_SHARED_LIBS option in applications subdirectory was changed to become active only if the project is standalone.