Closed efidler closed 9 years ago
If project has such an option, then probably it has some internal support for ANDROID build and doesn't require a toolchain. And if it requires a toolchain, then it doesn't need that option, because toolchain already defines ANDROID variable.
You've described the problem exactly. Some projects require a toolchain and have conditional stuff in their CMakeLists.txt that depend on the value of the ANDROID variable. Without the toolchain making ANDROID a cache variable, the conditional stuff in the CMakeLists.txt won't happen on the first build.
https://github.com/libgit2/libgit2/blob/master/CMakeLists.txt#L252 is an example.
I still consider it an issue in the project, but not in the toolchain. Option could be changed to (in libgit2): option(ANDROID "Bla-Bla" "${ANDROID}")
Anyway it's just a coincidence that both names match. What if libgit2 was using LIBGIT2_ANDROID variable for that? Do we need to add it as a cache variable to the toolchain anyway?
I think the project should be aware of the toolchain, not vice versa.
Fair enough, but ANDROID is used widely enough that I'd think it's worth supporting this case. We do set ANDROID in the toolchain already, after all.
Do you think there's a downside to ANDROID being a cache variable?
Well, it's up to @taka-no-me to decide.
But when you specified an android toolchain for the project - you ARE building for android. What the point of having ANDROID cache variable that could be set to NO? That will put a project into weird state where android toolchain is used, but ANDROID is set to NO. I don't like the possibility of such inconsistency.
The ANDROID
is designed to serve the same purpose as standard WIN32
or UNIX
variables. So it should not be cached.
Moreover it can not work as an option because it is impossible to change its value after the first run.
Some projects that use CMake and support Android have something in their CMakeLists.txt like: OPTION( ANDROID "Build for Android NDK" OFF )
Using this toolchain file won't override the ANDROID option the first time CMake runs unless ANDROID is a cache variable.