-
Notifications
You must be signed in to change notification settings - Fork 263
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
Write CMake variables set in CMake toolchain files to the CMake cache #1369
Comments
I suspect #463 fixes this. Either way, we should make sure those get set in the legacy toolchain file so this works for current versions of CMake too.
We've already shipped r22 beta 1 and so far it's not looking like we'll need a respin, but I've added this to our triage list so we can try to pick it up if that changes. Otherwise we can get this into r23. |
#463 won't fix this. Because upstream cmake does not add these variables to cache either... I'll send a patch upstream to see what they say. Also what do you need from |
If a toolchain defines |
Sounds like it should be fine if https://android-review.googlesource.com/c/platform/ndk/+/1495340 |
Does intellisense need to know where the sysroot is, or does it just need the compiler to work? Can you use the compilation database that CMake generates? |
Nothing besides CMake should be reading information from |
Gotcha, thanks for the advice :) I know that the sysroot appears in the file API because we use it in AGP, but that's kind of a bug. If it is actually needed by intellisense we'll keep it, so curious about the answers to my questions above. |
IntelliSense needs the set of include paths searched. We have had complaints from Android (r21) developers that the includes added to the search path when the sysroot is used on the command line were not being searched. But if the NDK compiler no longer depends on sysroot then maybe it is no longer an issue. We only need to use sysroot for IntelliSense in the cases when the build is going to use it. What do you mean by the “compilation database”? We are happy to use the file api instead of |
No one in CMake upstream is working on CMake issue 19514. Contributors welcome. |
NDK builds still use the sysroot, clang just doesn't need to be told where it is. It's installed in a fixed location relative to the clang binary and clang understands its layout. The only reliable way to determine what include directories are used by the compiler is to run a test compile with all the same flags and adding
If that's not feasible, https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md#Sysroot describes the layout. It's not as robust, but certainly easier. Having given this a bit more thought I'd guess it wouldn't actually be very helpful to guarantee that this value remains in the cmake output. The behavior is documented, and if it ever changes it's likely not the only change that will be needed to adapt. |
Thanks for the info. We do run the compiler with -v, but we need a way to append sysroot. When 19514 is addressed we will use file api to read CMake compiler variables instead of reading from |
It should be implicit. I didn't pass |
If I've understood correctly, there's nothing for us to do here, and the changes required are on the IntelliSense side? @esweet431 lmk if I've misunderstood and will reopen. |
Hi, I work on Microsoft's C++ Team. We recently changed the way we handle CMake toolchains to better support Android projects. We use the value of the following CMake variables in the CMake cache to automatically configure IntelliSense for Android projects configured with a CMake toolchain file:
CMAKE_C_COMPILER_TARGET
CMAKE_CXX_COMPILER_TARGET
CMAKE_SYSROOT
CMAKE_C_COMPILER
CMAKE_CXX_COMPILER
However, the CMake toolchain files provided by the Android ndk do not write the value of these 5 CMake variables to the cache. Are you able to add "CACHE <type> <docstring>" (ref) to the setting of these 5 variables in your CMake toolchain files, so that the variables are written to the CMake cache? This will provide Android developers with IntelliSense when they are using Visual Studio's CMake support.
The text was updated successfully, but these errors were encountered: