Skip to content

Commit

Permalink
Use NDK-supplied cmake binary
Browse files Browse the repository at this point in the history
The CMake toolchain shipped with the NDK doesn't work with CMake-3.7.2
or 3.9.1. To ensure compatibility, use the shipped cmake binary. See
android/ndk#254 or
https://gitlab.kitware.com/cmake/cmake/issues/16708 as well as
android/ndk#504

Change-Id: I31366cd813edc44d0e62021872c63d9fc06ffb7c
  • Loading branch information
saschpe committed Nov 7, 2017
1 parent d82c908 commit f6b264c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# material also contains confidential information which may not be
# disclosed to others without the prior written consent of HERE.

cmake_minimum_required(VERSION 3.7)
cmake_minimum_required(VERSION 3.6)
project(hello_world)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../cmake/modules/")
Expand Down
2 changes: 1 addition & 1 deletion libhello/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# material also contains confidential information which may not be
# disclosed to others without the prior written consent of HERE.

cmake_minimum_required(VERSION 3.7)
cmake_minimum_required(VERSION 3.6)

# Here we create a new library 'hello' for which to generate target platform bindings.
# It aims to serve as a blueprint for real-world libraries such as libguidance or librouting.
Expand Down
2 changes: 1 addition & 1 deletion platforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
# material also contains confidential information which may not be
# disclosed to others without the prior written consent of HERE.

cmake_minimum_required(VERSION 3.7)
cmake_minimum_required(VERSION 3.6)

add_subdirectory(cpp)
2 changes: 1 addition & 1 deletion platforms/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# material also contains confidential information which may not be
# disclosed to others without the prior written consent of HERE.

cmake_minimum_required(VERSION 3.7)
cmake_minimum_required(VERSION 3.6)
project(cpp_app)

if(NOT HELLO_BUILD_CPP_APP)
Expand Down
16 changes: 13 additions & 3 deletions scripts/build-android
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ CMAKE_CROSS_BUILD_PARAMETERS=$(cat <<EOF
EOF
)

# The CMake toolchain shipped with the NDK doesn't work with CMake-3.72
# or 3.9.1. To ensure compatibility, use the shipped cmake binary. See
# https://github.com/android-ndk/ndk/issues/254 or
# https://gitlab.kitware.com/cmake/cmake/issues/16708
NDK_CMAKE_BINARY=$(find $ANDROID_HOME/cmake -executable -type f -name cmake)

# Do cross-compilation build for generating a proper Android Archive
for arch in x86 armeabi-v7a ${HOST_ARCH} ; do
build_dir=${PWD}/build-android-${arch}
Expand All @@ -43,21 +49,25 @@ for arch in x86 armeabi-v7a ${HOST_ARCH} ; do
pushd ${build_dir}

CMAKE_EXTRA_PARAMETERS=
# Do host-native build for testing on the JVM with Robolectric
# Do host-native build for testing on the JVM with Robolectric using the
# CMake binary supplied (and supported) by the NDK
if [ "${arch}" != "host-$(uname -m)" ] ; then
CMAKE_EXTRA_PARAMETERS="${CMAKE_CROSS_BUILD_PARAMETERS} \
-DANDROID_ABI=${arch}"
CMAKE_BINARY=${NDK_CMAKE_BINARY}
else
CMAKE_BINARY=cmake
fi

safe cmake \
safe ${CMAKE_BINARY} \
${CMAKE_DEFAULT_PARAMETERS} \
${CMAKE_EXTRA_PARAMETERS} \
-DCMAKE_INSTALL_PREFIX=${install_dir} \
..

popd

safe cmake \
safe ${CMAKE_BINARY} \
--build ${build_dir} \
--target install
done
Expand Down

0 comments on commit f6b264c

Please sign in to comment.