[Piglit] [PATCH 3/6] cmake: Add an Android platform and toolchain

Negreanu, Adrian M adrian.m.negreanu at intel.com
Mon Nov 5 11:17:54 PST 2012


On Mon, Nov 5, 2012 at 9:11 PM, Chad Versace
<chad.versace at linux.intel.com> wrote:
> On 10/24/2012 06:11 AM, groleo at gmail.com wrote:
>> From: Adrian Marius Negreanu <adrian.m.negreanu at intel.com>
>>
>> Signed-off-by: Adrian Marius Negreanu <adrian.m.negreanu at intel.com>
>> ---
>> :000000 100644 0000000... 9dd8b3c... A        cmake/Modules/Compiler/Android.cmake
>> :000000 100644 0000000... 2298263... A        cmake/Modules/Platform/Android.cmake
>>  cmake/Modules/Compiler/Android.cmake | 70 ++++++++++++++++++++++++++++++++++++
>>  cmake/Modules/Platform/Android.cmake | 35 ++++++++++++++++++
>>  2 files changed, 105 insertions(+)
>>
>> diff --git a/cmake/Modules/Compiler/Android.cmake b/cmake/Modules/Compiler/Android.cmake
>> new file mode 100644
>> index 0000000..9dd8b3c
>> --- /dev/null
>> +++ b/cmake/Modules/Compiler/Android.cmake
>> @@ -0,0 +1,70 @@
>
> This file is very clever. I always wondered how people integrated CMake
> with Android.
>
>> +# Set Android toolchain specifics
>> +
>> +SET(CMAKE_SYSTEM_NAME Android)
>> +SET(CMAKE_SYSTEM_VERSION 1)
>> +SET(UNIX True)
>> +SET(ANDROID True)
>> +
>> +IF($ENV{PLATFORM_ANDROID})
>> +    return()
>> +ENDIF()
>> +
>> +SET(ENV{PLATFORM_ANDROID} 1)
>> +
>> +# needed by get_build_var
>> +SET(ENV{CALLED_FROM_SETUP} true)
>> +SET(ENV{BUILD_SYSTEM} build/core)
>> +
>> +MACRO(get_build_var arg1 _output)
>> +    EXECUTE_PROCESS(COMMAND make --no-print-directory -C $ENV{ANDROID_BUILD_TOP} -f build/core/config.mk dumpvar-${arg1}
>> +    OUTPUT_VARIABLE ${_output}
>> +    OUTPUT_STRIP_TRAILING_WHITESPACE
>> +    )
>> +ENDMACRO()
>> +
>> +get_build_var(TARGET_ARCH __TARGET_ARCH)
>> +get_build_var(TARGET_GLOBAL_CFLAGS  __TARGET_GLOBAL_CFLAGS)
>> +get_build_var(TARGET_GLOBAL_LDFLAGS __TARGET_GLOBAL_LDFLAGS)
>> +get_build_var(TARGET_CC   CMAKE_C_COMPILER)
>> +get_build_var(TARGET_CXX  CMAKE_CXX_COMPILER)
>> +
>> +SET(CMAKE_C_COMPILER   $ENV{ANDROID_BUILD_TOP}/${CMAKE_C_COMPILER} CACHE STRING "")
>> +SET(CMAKE_CXX_COMPILER $ENV{ANDROID_BUILD_TOP}/${CMAKE_CXX_COMPILER} CACHE STRING "")
>> +
>> +SET(__NDK_SYSROOT   $ENV{ANDROID_BUILD_TOP}/prebuilts/ndk/android-ndk-r8/platforms/android-14/arch-${__TARGET_ARCH})
>> +SET(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} ${__TARGET_GLOBAL_CFLAGS} -I$ENV{ANDROID_BUILD_TOP} --sysroot=${__NDK_SYSROOT} -Wno-error=return-type " CACHE STRING "c flags")
>> +SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${__TARGET_GLOBAL_CFLAGS} -I$ENV{ANDROID_BUILD_TOP} --sysroot=${__NDK_SYSROOT} -Wno-error=return-type " CACHE STRING "c flags")
>> +
>> +SET(CMAKE_LD_FLAGS  "${CMAKE_LD_FLAGS} -Wl,--allow-shlib-undefined ${__TARGET_GLOBAL_LDFLAGS} --sysroot=${__NDK_SYSROOT}" CACHE STRING "linker flags")
>> +SET(CMAKE_EXE_LINKER_FLAGS ${CMAKE_LD_FLAGS} CACHE STRING "executable linker flags")
>> +
>> +# search only inside sdk, not the remainder of the host filesystem
>> +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
>> +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
>> +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
>
>
>> diff --git a/cmake/Modules/Platform/Android.cmake b/cmake/Modules/Platform/Android.cmake
>
>> +# Set Android specific paths
>> +
>> +LIST(APPEND CMAKE_PREFIX_PATH $ENV{ANDROID_PRODUCT_OUT}/system)
>> +LIST(APPEND CMAKE_PREFIX_PATH $ENV{ANDROID_BUILD_TOP}/external/waffle/include/waffle)
>
> Now that Waffle installs its headers to $ANDROID_PRODUCT_OUT/obj/include/waffle-1,
> is the line above still necessary? I don't know; the Android build system is still
> mysterious to me.
In this case, the line above should be replaced with the one pointing
to ${ANDROID_BUILD_TOP}/...
I'll try and see if pointing only to ${ANDROID_BUILD_TOP}/obj/include
is sufficient, to avoid
specifying waffle altogether.



>
>
>> +LIST(APPEND CMAKE_PREFIX_PATH $ENV{ANDROID_BUILD_TOP}/external/zlib)
>> +
>> +LIST(APPEND CMAKE_SYSTEM_INCLUDE_PATH
>> +  $ENV{ANDROID_BUILD_TOP}/external/mesa/include
>> +  )
>
>
>



-- 
Adrian Marius Negreanu
Open Source Technology Center


More information about the Piglit mailing list