Re: [CMake] Need code review of my android toolchain file

2017-04-21 Thread Volker Enderlein

Hi Robert,

I would use

file(TO_NATIVE_PATH "${_dir}" _dir) and file(TO_CMAKE_PATH "${_dir}" _dir)

hope that helps,

Cheers, Volker

Am 21/04/2017 um 15:45 schrieb Robert Dailey:

I guess the only feedback I really would like is if the path
normalization I'm doing for CMAKE_ANDROID_NDK is necessary (converting
backslashes to forward slashes). Will CMake translate the backslashes
properly?

Sometimes I use CMAKE_ANDROID_NDK in custom commands and custom
targets to build absolute paths to items in the NDK.

On Tue, Apr 18, 2017 at 9:45 PM, Robert Dailey  wrote:

I'm trying to follow best practices where I can, but the trouble is
I'm not aware of any. So I want to post my android.toolchain.cmake
file here, with the hope that I can get some pointers.

The main thing I want to understand is when it is appropriate to
require cache variables be set via command line argument (-D) or via
the toolchain file itself. Here is what is in my toolchain right now:


set(CMAKE_SYSTEM_NAME Android)
set(CMAKE_SYSTEM_VERSION 15) # API level
set(CMAKE_ANDROID_ARCH_ABI armeabi-v7a)
set(CMAKE_ANDROID_STL_TYPE c++_static)
set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION clang)

string(REGEX REPLACE "" "/" ndk_path "$ENV{ANDROID_NDK}")
set(CMAKE_ANDROID_NDK ${ndk_path})

unset(ndk_path)



My idea here is to provide a different toolchain file per specific NDK
configuration. For example, I need to build my native libraries for
both x86 and ARM platforms, so I would use 2 CMAKE_BINARY_DIR, each
configured using a different toolchain:

x86 would use "android.toolchain.x86.cmake"
ARM would use "android.toolchain.arm.cmake"

Something like that. Is this best practice? What other advice would you offer?

Thanks in advance.



--
Volker Enderlein Institut für Mechatronik e.V.
Phone: +49 (0)371 531 19651  Reichenhainer Strasse 88
Fax:   +49 (0)371 531 19699  D-09126 Chemnitz
Mail: volker.enderl...@ifm-chemnitz.de   www.ifm-chemnitz.de

Vorstand:
Prof. Dr.-Ing. Welf-Guntram Drossel (Vorsitz)
Dipl.-Ing. Heiko Freudenberg (Geschäftsführer)

Amtsgericht Chemnitz VR 713
Ust.-IdNr. DE 159285348

--

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

Re: [CMake] Need code review of my android toolchain file

2017-04-21 Thread Robert Dailey
I guess the only feedback I really would like is if the path
normalization I'm doing for CMAKE_ANDROID_NDK is necessary (converting
backslashes to forward slashes). Will CMake translate the backslashes
properly?

Sometimes I use CMAKE_ANDROID_NDK in custom commands and custom
targets to build absolute paths to items in the NDK.

On Tue, Apr 18, 2017 at 9:45 PM, Robert Dailey  wrote:
> I'm trying to follow best practices where I can, but the trouble is
> I'm not aware of any. So I want to post my android.toolchain.cmake
> file here, with the hope that I can get some pointers.
>
> The main thing I want to understand is when it is appropriate to
> require cache variables be set via command line argument (-D) or via
> the toolchain file itself. Here is what is in my toolchain right now:
>
>
> set(CMAKE_SYSTEM_NAME Android)
> set(CMAKE_SYSTEM_VERSION 15) # API level
> set(CMAKE_ANDROID_ARCH_ABI armeabi-v7a)
> set(CMAKE_ANDROID_STL_TYPE c++_static)
> set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION clang)
>
> string(REGEX REPLACE "" "/" ndk_path "$ENV{ANDROID_NDK}")
> set(CMAKE_ANDROID_NDK ${ndk_path})
>
> unset(ndk_path)
>
>
>
> My idea here is to provide a different toolchain file per specific NDK
> configuration. For example, I need to build my native libraries for
> both x86 and ARM platforms, so I would use 2 CMAKE_BINARY_DIR, each
> configured using a different toolchain:
>
> x86 would use "android.toolchain.x86.cmake"
> ARM would use "android.toolchain.arm.cmake"
>
> Something like that. Is this best practice? What other advice would you offer?
>
> Thanks in advance.
-- 

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