-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] CMake finding & linking host libraries #890
Comments
Hi @mattvchandler I am facing the same issue with the NDKr19. |
Checked both the SDK's older version of CMake (3.6) and r18. CMake version doesn't make a difference, but this works with r18. These sorts of issues are usually just a missing setting in the toolchain file. Looking into it now. |
Looks like it's because CMake will search the host system even when https://android-review.googlesource.com/c/platform/ndk/+/880977 |
I just tried adding |
The candidate directories for searching are generated by joining roots and prefixes. Roots include I think it's better to set diff --git a/android.toolchain.cmake b/android.toolchain.cmake
index e58ff05..3da882a 100644
--- a/android.toolchain.cmake
+++ b/android.toolchain.cmake
@@ -387,8 +387,9 @@ set(ANDROID_TOOLCHAIN_PREFIX
# (https://cmake.org/cmake/help/v3.6/variable/CMAKE_SYSTEM_LIBRARY_PATH.html)
# instead.
set(ANDROID_SYSROOT "${ANDROID_TOOLCHAIN_ROOT}/sysroot")
+set(CMAKE_SYSROOT ${ANDROID_SYSROOT})
list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
- "${ANDROID_SYSROOT}/usr/lib/${ANDROID_TOOLCHAIN_NAME}/${ANDROID_PLATFORM_LEVEL}")
+ "/usr/lib/${ANDROID_TOOLCHAIN_NAME}/${ANDROID_PLATFORM_LEVEL}")
set(ANDROID_HOST_PREBUILTS "${ANDROID_NDK}/prebuilt/${ANDROID_HOST_TAG}")
|
I just tested that change on my app, and it also builds successfully. |
I've merged a fix for this into r19 for r19b (will probably ship this in a couple of weeks; I'm still waiting a bit in case more bugs are filed). @huangqinjin: I think you're probably right. For r19b I'm going to stick with my patch because I'd rather we revert to the previous behavior which didn't seem to cause any problems, but I'll leave this open to look into that for r20. |
Actually I've filed it as a new bug (#902) because I want to keep this one associated with r19b for tracking reasons. |
Even though this shouldn't end up being used, it needs to be set so that `CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY` works as intended. Test: Tried to build freetype, it didn't find harfbuzz on my system Bug: android/ndk#890 Change-Id: If4ea8cd1266261a001e20af79f35da52f2a5380e (cherry picked from commit 5be007d)
`cmake` 3.10 is the current version of the tool in the Android SDK, an update from the much older 3.6. This update brings it closer to the host `cmake` versions (currently mostly 3.12.*) Bump NDK to release [19b][0] (a.k.a. 19.1), with the following changes: * [Issue 855][1]: ndk-build automatically disables multithreaded linking for LLD on Windows, where it may hang. It is not possible for the NDK to detect this situation for CMake, so CMake users and custom build systems must pass `-Wl,--no-threads` when linking with LLD on Windows. * [Issue 849][2]: Fixed unused command line argument warning when using standalone toolchains to compile C code. * [Issue 890][3]: Fixed CMAKE_FIND_ROOT_PATH. CMake projects will no longer search the host's sysroot for headers and libraries. * [Issue 907][4]: Fixed find_path for NDK headers in CMake. [0]: https://github.com/android-ndk/ndk/wiki/Changelog-r19#r19b [1]: android/ndk#855 [2]: android/ndk#849 [3]: android/ndk#890 [4]: android/ndk#907
`cmake` 3.10 is the current version of the tool in the Android SDK, an update from the much older 3.6. This update brings it closer to the host `cmake` versions (currently mostly 3.12.*) Bump NDK to release [19b][0] (a.k.a. 19.1), with the following changes: * [Issue 855][1]: ndk-build automatically disables multithreaded linking for LLD on Windows, where it may hang. It is not possible for the NDK to detect this situation for CMake, so CMake users and custom build systems must pass `-Wl,--no-threads` when linking with LLD on Windows. * [Issue 849][2]: Fixed unused command line argument warning when using standalone toolchains to compile C code. * [Issue 890][3]: Fixed CMAKE_FIND_ROOT_PATH. CMake projects will no longer search the host's sysroot for headers and libraries. * [Issue 907][4]: Fixed find_path for NDK headers in CMake. [0]: https://github.com/android-ndk/ndk/wiki/Changelog-r19#r19b [1]: android/ndk#855 [2]: android/ndk#849 [3]: android/ndk#890 [4]: android/ndk#907
`cmake` 3.10 is the current version of the tool in the Android SDK, an update from the much older 3.6. This update brings it closer to the host `cmake` versions (currently mostly 3.12.*) Bump NDK to release [19b][0] (a.k.a. 19.1), which changes: * [Issue 855][1]: ndk-build automatically disables multithreaded linking for LLD on Windows, where it may hang. It is not possible for the NDK to detect this situation for CMake, so CMake users and custom build systems must pass `-Wl,--no-threads` when linking with LLD on Windows. * [Issue 849][2]: Fixed unused command line argument warning when using standalone toolchains to compile C code. * [Issue 890][3]: Fixed CMAKE_FIND_ROOT_PATH. CMake projects will no longer search the host's sysroot for headers and libraries. * [Issue 907][4]: Fixed find_path for NDK headers in CMake. [0]: https://github.com/android-ndk/ndk/wiki/Changelog-r19#r19b [1]: android/ndk#855 [2]: android/ndk#849 [3]: android/ndk#890 [4]: android/ndk#907
* Update ndk from branch 'ndk-release-r19' to ad8a8068b079a8a5efdaed3968659cd685b1a885 - Merge "Set CMAKE_FIND_ROOT_PATH to avoid host libraries." into ndk-release-r19 - Set CMAKE_FIND_ROOT_PATH to avoid host libraries. Even though this shouldn't end up being used, it needs to be set so that `CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY` works as intended. Test: Tried to build freetype, it didn't find harfbuzz on my system Bug: android/ndk#890 Change-Id: If4ea8cd1266261a001e20af79f35da52f2a5380e (cherry picked from commit 5be007d29204a9f1701ad0383820ec4ed5c12d25)
Description
I have an app that builds and uses Freetype. This worked fine until I updated the NDK to v19.0.5232133
Now, CMake finds the host system's harfbuzz and tries to link against it, which fails:
CMAKE_FIND_ROOT_PATH_MODE_LIBRARY and ..._INCLUDE are set to ONLY, so I would expect CMake to ignore the host system paths. Freetype uses a FindHarfBuzz.cmake file (included in the test case), but as far as I can tell (I only know basic CMake configuration) it doesn't override this in anyway.
I can't verify which NDK version last worked, but it would have been the last one recommended in the android studio SDK manager before 19.0.5232133
Test case gist
Environment Details
The text was updated successfully, but these errors were encountered: