[cmake-developers] Android variables

Ruslan Baratov ruslan_baratov at yahoo.com
Sat Nov 12 00:53:05 EST 2016


On 12-Nov-16 08:21, Florent Castelli wrote:
> On 10/11/2016 16:05, Ruslan Baratov via cmake-developers wrote:
>> Hi,
>>
>> I wonder if it's possible to introduce next variables describing Android
>> tools:
>> * C preprocessor. Similar to CMAKE_CXX_COMPILER the variable that will
>> contain the path to preprocessor. Example:
>>   * CMAKE_CXX_COMPILER =
>> <ndk-root>/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++
>>
>>   * CMAKE_C_PREPROCESSOR =
>> <ndk-root>/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-cpp
>>
>> * ANDROID_TOOLCHAIN_MACHINE_NAME. In fact I'm not sure what this
>> variable mean but it's an important part of move from taka-no-me
>> toolchain to CMake 3.7. I guess it's like
>>   * CMAKE_CXX_COMPILER =
>> <ndk-root>/toolchains/${ANDROID_TOOLCHAIN_MACHINE_NAME}-4.9/prebuilt/linux-x86_64/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-g++
>>
>>
>> Of course if I'm not missing something and they are not already
>> somewhere :)
>>
>> Ruslo
>
> How about ${CMAKE_C/CXX_COMPILER} -E to call the preprocessor?
I have no idea and not planning to test it because the old code was
using `cpp` preprocessor and I see no point of changing it.

> Calling it directly is kind of dangerous though since you will
> probably be missing the proper language information and other options
> that might affect the predefined preprocessor defines.
I'm not calling it directly, it was used by `configure` script of 3rd party.

> gcc has different binaries for different target archs and has some
> defines baked in, but this won't apply to Clang that uses only one
> binary and a target triple.
For clang based android toolchain the CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX
variable points to the directory with gcc, so it will find `cpp`
preprocessor too. I don't know if it's good or bad :)

Ruslo

> You'll also lose the c/c++ language definition (unless you pass -x
> c++), language standard in use...



More information about the cmake-developers mailing list