diff options
author | Aleix Pol <aleixpol@kde.org> | 2018-11-16 19:17:45 +0100 |
---|---|---|
committer | Aleix Pol <aleixpol@kde.org> | 2018-11-19 16:16:02 +0100 |
commit | 06061b0e3ce4342b5cbb1c0e6c8d285b524e30f0 (patch) | |
tree | fbd21d3b48965aff7cec9751a8640b521e2f2ae2 | |
parent | 96d169b87292d935646b1924952829b0f4d5d669 (diff) | |
download | extra-cmake-modules-06061b0e3ce4342b5cbb1c0e6c8d285b524e30f0.tar.gz extra-cmake-modules-06061b0e3ce4342b5cbb1c0e6c8d285b524e30f0.tar.bz2 |
Android: improve clang support
Summary:
Infer the toolchain we are using through cmake's detection of ranlib
instead of asking the user to fill it.
It's only used in androiddeployqt and cmake expects it to be version
"clang" for clang builds while androiddeployqt expects it to be "4.9".
Reviewers: #build_system, #android, vkrause
Reviewed By: #android, vkrause
Subscribers: kde-frameworks-devel, kde-buildsystem
Tags: #frameworks, #build_system
Differential Revision: https://phabricator.kde.org/D16930
-rw-r--r-- | toolchain/Android.cmake | 8 | ||||
-rw-r--r-- | toolchain/ECMAndroidDeployQt.cmake | 6 | ||||
-rw-r--r-- | toolchain/deployment-file.json.in | 6 | ||||
-rw-r--r-- | toolchain/specifydependencies.cmake | 8 |
4 files changed, 16 insertions, 12 deletions
diff --git a/toolchain/Android.cmake b/toolchain/Android.cmake index 74b1dbfc..76b3665a 100644 --- a/toolchain/Android.cmake +++ b/toolchain/Android.cmake @@ -42,12 +42,6 @@ # # Additional options are specified as cache variables (eg: on the command line): # -# ``ANDROID_TOOLCHAIN`` -# The toolchain to use. See the ``toolchains`` directory of the NDK. -# Default: ``arm-linux-androideabi``. -# ``ANDROID_COMPILER_PREFIX`` -# The prefix for the gcc and g++ executables. See the ``toolchains/$ANDROID_TOOLCHAIN/prebuilt/*/bin/*-gcc`` in the NDK. -# Default: ``arm-linux-androideabi``. # ``ANDROID_ABI`` # The ABI to use. See the ``sources/cxx-stl/gnu-libstdc++/*/libs`` # directories in the NDK. Default: ``armeabi-v7a``. @@ -156,8 +150,6 @@ set_deprecated_variable(CMAKE_ANDROID_ARCH_ABI ANDROID_ABI "armeabi-v7a") set_deprecated_variable(CMAKE_ANDROID_API ANDROID_API_LEVEL "14") set(ANDROID_SDK_ROOT "$ENV{ANDROID_SDK_ROOT}" CACHE path "Android SDK path") -set(ANDROID_TOOLCHAIN "arm-linux-androideabi" CACHE string "Used SDK") -set(ANDROID_COMPILER_PREFIX "arm-linux-androideabi" CACHE string "Prefix for gcc/g++/etc") file(GLOB build-tools LIST_DIRECTORIES TRUE RELATIVE ${ANDROID_SDK_ROOT}/build-tools ${ANDROID_SDK_ROOT}/build-tools/*) list(GET build-tools 0 _default_sdk) diff --git a/toolchain/ECMAndroidDeployQt.cmake b/toolchain/ECMAndroidDeployQt.cmake index 66dbbd6e..25da4a23 100644 --- a/toolchain/ECMAndroidDeployQt.cmake +++ b/toolchain/ECMAndroidDeployQt.cmake @@ -44,7 +44,13 @@ function(ecm_androiddeployqt QTANDROID_EXPORTED_TARGET ECM_ADDITIONAL_FIND_ROOT_ file(WRITE ${CMAKE_BINARY_DIR}/stl "${OUTSTR}") endif() endfunction() + function(haveranlib var access VALUE) + if (NOT VALUE STREQUAL "") + file(WRITE ${CMAKE_BINARY_DIR}/ranlib "${VALUE}") + endif() + endfunction() variable_watch(CMAKE_CXX_STANDARD_LIBRARIES havestl) + variable_watch(CMAKE_RANLIB haveranlib) if (NOT TARGET create-apk) add_custom_target(create-apk) diff --git a/toolchain/deployment-file.json.in b/toolchain/deployment-file.json.in index 2b9b44f1..907401b9 100644 --- a/toolchain/deployment-file.json.in +++ b/toolchain/deployment-file.json.in @@ -2,9 +2,9 @@ "qt": "@_qt5Core_install_prefix@", "sdk": "@ANDROID_SDK_ROOT@", "ndk": "@CMAKE_ANDROID_NDK@", - "toolchain-prefix": "@ANDROID_TOOLCHAIN@", - "tool-prefix": "@ANDROID_COMPILER_PREFIX@", - "toolchain-version": "@CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION@", + "toolchain-prefix": "##ANDROID_TOOL_PREFIX##", + "tool-prefix": "##ANDROID_COMPILER_PREFIX##", + "toolchain-version": "##ANDROID_TOOLCHAIN_VERSION##", "ndk-host": "@_LOWER_CMAKE_HOST_SYSTEM_NAME@-@CMAKE_HOST_SYSTEM_PROCESSOR@", "target-architecture": "@ANDROID_ABI@", "application-binary": "@EXECUTABLE_DESTINATION_PATH@", diff --git a/toolchain/specifydependencies.cmake b/toolchain/specifydependencies.cmake index 9cab3f2d..942e88e2 100644 --- a/toolchain/specifydependencies.cmake +++ b/toolchain/specifydependencies.cmake @@ -51,7 +51,13 @@ endif() file(READ "${INPUT_FILE}" CONTENTS) file(READ "stl" stl_contents) -string(REPLACE "##EXTRALIBS##" "${extralibs}" NEWCONTENTS "${CONTENTS}") +file(READ "ranlib" ranlib_contents) +string(REGEX MATCH ".+/toolchains/(.+)-([^\\-]+)/prebuilt/.*/bin/(.*)-ranlib" x ${ranlib_contents}) + +string(REPLACE "##ANDROID_TOOL_PREFIX##" "${CMAKE_MATCH_1}" NEWCONTENTS "${CONTENTS}") +string(REPLACE "##ANDROID_TOOLCHAIN_VERSION##" "${CMAKE_MATCH_2}" NEWCONTENTS "${NEWCONTENTS}") +string(REPLACE "##ANDROID_COMPILER_PREFIX##" "${CMAKE_MATCH_3}" NEWCONTENTS "${NEWCONTENTS}") +string(REPLACE "##EXTRALIBS##" "${extralibs}" NEWCONTENTS "${NEWCONTENTS}") string(REPLACE "##EXTRAPLUGINS##" "${extraplugins}" NEWCONTENTS "${NEWCONTENTS}") string(REPLACE "##CMAKE_CXX_STANDARD_LIBRARIES##" "${stl_contents}" NEWCONTENTS "${NEWCONTENTS}") file(WRITE "${OUTPUT_FILE}" ${NEWCONTENTS}) |