Do not prepend SDK path to CMAKE_FIND_ROOT_PATH #102
Closed
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.
Prepending to
CMAKE_FIND_ROOT_PATH
is harmful [1], because if a library exists in both the SDK and in the user's path (via e.g. the Conan Package Manager), the SDK's library is used. Linking against the wrong library (e.g. libprotobuf on iOS) may crash the app or get it rejected from the store.Compared to the NDK issue I references we can just drop modification of
CMAKE_FIND_ROOT_PATH
completely because CMake searches in the customCMAKE_OSX_SYSROOT
anyway.This pull request implements the suggested change and fixes
find_host_package
to properly restore the user's find root settings.[1] android/ndk#912
Here is a test case to confirm that libraries available in the iOS SDK are still found after this patch:
CMakeLists.txt: