[CMAKE] - custom compiler for Android

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[CMAKE] - custom compiler for Android

CMake mailing list

Hi,

 

I am reposting the below email. Your help is highly appreciated.

 

We are working towards creating a toolchain file for an ANDROID compiler

 

We understand that the flow in CMAKE, when CMAKE_SYSTEM_NAME is specified in Android, is different when compared to specifying CMAKE_SYSTEM_NAME as IOS or LINUX

 

Please validate our current understanding when a toolchain file or command-line option sets CMAKE_SYSTEM_NAME to "Android"

 

  • CMakeDetermineSystem.cmake loads this file:   Android-Determine.cmake
  • Next is the platform-specific initialization step:   CMakeSystemSpecificInitialize.cmake which loads Android-Initialize.cmake to select the sysroot.
  • A "determine" step also runs for each language when it is first enabled in a new build tree:

 

Android-Determine-C.cmake

Android-Determine-CXX.cmake

 

  • The language files go here:

 

Determine-Compiler.cmake

Determine-Compiler-NDK.cmake

 

  • The latter file is where we parse a bunch of information from the NDK.

The results persist in CMakeFiles/$v/CMake${lang}Compiler.cmake for future runs.

 

Next is the language-specific initialization step. For  Example – in case {lang} is C :     CMakeCInformation.cmake

 

That loads one of these:

 

Android-GNU-C.cmake

Android-Clang-C.cmake

 

which loads one of these:

 

Android-GNU.cmake

Android-Clang.cmake  

 

Determine-Compiler-NDK.cmake is where cmake looks for versions of clang or gcc or llvm toolchains and sets the appropriate compiler.

 

 

Our Requirement and Problem statement

When we tried manually setting a c and cxx compiler from a toolchain file, cmake would not allow us to point to our own compilers. Ideally, we want our toolchain file to tell cmake the libraries to include/link and the compilers to use. But once, System has been determined as android, cmake goes through the above sequence of events and expects toolchains to be specified for either clang, gcc or llvm compilers.

 

We would probably need to make changes in the following files to accommodate cmake to use our own compilers.

Determine-Compiler-NDK.cmake  - We would need to add support for an "NewCompiler Toolchain" which would contain android libraries and compilers.

 

New Android-{NewCompiler}-C.cmake, Android-{ NewCompiler }-CXX.cmake, Android-{ NewCompiler }.cmake and another appropriate toolchain file to set target architecture and compiler flags.

 

 

Can you please provide your suggestions and validate the understanding as well

 

Thanks & Regards,

Ramya

 

 

 


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: [CMAKE] - custom compiler for Android

Brad King
On 12/05/2017 12:05 PM, [hidden email] wrote:
> Please validate our current understanding when a toolchain file or
> command-line option sets CMAKE_SYSTEM_NAME to "Android"

You may find this note helpful:

  https://gitlab.kitware.com/cmake/cmake/issues/16708#note_300971

> Ideally, we want our toolchain file to tell cmake the libraries to
> include/link and the compilers to use.

Toolchain files can set the path to compilers on the host, but
target-platform-wide information like the set of libraries and
include directories to use typically belongs in platform information
modules (e.g. `Platform/Android-...` and the like).

> But once, System has been determined as android, cmake goes
> through the above sequence of events and expects toolchains to be
> specified for either clang, gcc or llvm compilers.

We try to support the compilers that come with the NDK out of the box.
More work may be needed to support other compilers, just as would be
the case for any new platform or new compiler.

> Determine-Compiler-NDK.cmake  - We would need to add support for an
> "NewCompiler Toolchain" which would contain android libraries and compilers.

Since your compiler doesn't come with the NDK, perhaps you could look
at using the standalone toolchain mode.

> New Android-{NewCompiler}-C.cmake, Android-{ NewCompiler }-CXX.cmake,
> Android-{ NewCompiler }.cmake and another appropriate toolchain file to
> set target architecture and compiler flags.

If you have some new compiler then something like that would be needed.
This would be the case for a new compiler on any platform.

-Brad
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: [CMAKE] - custom compiler for Android

CMake mailing list
HI Brad,

Thank you for the response
However we want more guidance on how do we start with the changes needed for
the compiler support

To be more clear, we are trying to build support for the embarcadero
compilers bccaarm.exe. To give more insight on the work and our query, we
have attached a working toolchain that we created and works fine with CMAKE
and the compiler. But we have given the system name CMAKE_SYSTEM_NAME as
"_Android"
Since we havent given it as "Android", it reads all the libraries and the
compilers from our toolchain file and gives the desired output.

Can you please give us some guidance to achieve the same with
CMAKE_SYSTEM_NAME as "Android"

Thanks & Regards,
Ramya

-----Original Message-----
From: Brad King [mailto:[hidden email]]
Sent: Wednesday, December 06, 2017 1:24 AM
To: [hidden email]
Cc: [hidden email]; 'Sumit Chourasia' <[hidden email]>
Subject: Re: [CMAKE] - custom compiler for Android

On 12/05/2017 12:05 PM, [hidden email] wrote:
> Please validate our current understanding when a toolchain file or
> command-line option sets CMAKE_SYSTEM_NAME to "Android"

You may find this note helpful:

  https://gitlab.kitware.com/cmake/cmake/issues/16708#note_300971

> Ideally, we want our toolchain file to tell cmake the libraries to
> include/link and the compilers to use.

Toolchain files can set the path to compilers on the host, but
target-platform-wide information like the set of libraries and include
directories to use typically belongs in platform information modules (e.g.
`Platform/Android-...` and the like).

> But once, System has been determined as android, cmake goes through
> the above sequence of events and expects toolchains to be specified
> for either clang, gcc or llvm compilers.

We try to support the compilers that come with the NDK out of the box.
More work may be needed to support other compilers, just as would be the
case for any new platform or new compiler.

> Determine-Compiler-NDK.cmake  - We would need to add support for an
> "NewCompiler Toolchain" which would contain android libraries and
compilers.

Since your compiler doesn't come with the NDK, perhaps you could look at
using the standalone toolchain mode.

> New Android-{NewCompiler}-C.cmake, Android-{ NewCompiler }-CXX.cmake,
> Android-{ NewCompiler }.cmake and another appropriate toolchain file
> to set target architecture and compiler flags.

If you have some new compiler then something like that would be needed.
This would be the case for a new compiler on any platform.

-Brad

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

bccaarm.cmake (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [CMAKE] - custom compiler for Android

Brad King
On 12/06/2017 11:39 AM, [hidden email] wrote:
> Can you please give us some guidance to achieve the same with
> CMAKE_SYSTEM_NAME as "Android"

You'd need to teach

  Modules/Compiler/Embarcadero-DetermineCompiler.cmake

to recognize the compiler as Embarcadero if it doesn't already,
and then add Modules/Platform/Android* modules named with that
compiler id.

-Brad
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake