From kde-commits Wed Sep 30 23:28:57 2015 From: Aleix Pol Date: Wed, 30 Sep 2015 23:28:57 +0000 To: kde-commits Subject: [extra-cmake-modules] toolchain: Remove workaround to delay execution on Android Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=144365574724916 Git commit 3b20ef911eb83b7bd37315ace682e0e6bc6195d9 by Aleix Pol. Committed on 30/09/2015 at 23:25. Pushed by apol into branch 'master'. Remove workaround to delay execution on Android * Remove get_property calls on targets, this way we don't need to be called right before configuration time. * Removes EOFHook Instead we process it at generation time using the link.txt file (which is probably another hack) REVIEW: 125084 M +4 -26 toolchain/Android.cmake M +1 -1 toolchain/deployment-file.json.in A +22 -0 toolchain/specifydependencies.cmake http://commits.kde.org/extra-cmake-modules/3b20ef911eb83b7bd37315ace682e0e6= bc6195d9 diff --git a/toolchain/Android.cmake b/toolchain/Android.cmake index 9b10474..a60771b 100644 --- a/toolchain/Android.cmake +++ b/toolchain/Android.cmake @@ -174,38 +174,16 @@ if(DEFINED QTANDROID_EXPORTED_TARGET AND NOT TARGET $= {CREATEAPK_TARGET_NAME}) = find_package(Qt5Core REQUIRED) = - function(EOFHook) - if(CMAKE_PARENT_LIST_FILE STREQUAL "") - generate_deployment_file() - endif() - endfunction() - - function(generate_deployment_file) - get_property(_DEPENDENCIES TARGET ${QTANDROID_EXPORTED_TARGET} PRO= PERTY INTERFACE_LINK_LIBRARIES) - set(_DEPS_LIST) - foreach(_DEP IN LISTS _DEPENDENCIES) - if(NOT _DEP MATCHES "Qt5::.*") - get_property(_DEP_LOCATION TARGET ${_DEP} PROPERTY "LOCATI= ON_${CMAKE_BUILD_TYPE}") - list(APPEND _DEPS_LIST ${_DEP_LOCATION}) - endif() - endforeach() - string(REPLACE ";" "," _DEPS "${_DEPS_LIST}") - configure_file("${_CMAKE_ANDROID_DIR}/deployment-file.json.in" "${= QTANDROID_EXPORTED_TARGET}-deployment.json") - endfunction() - #we want to call the function after the project has been set up - variable_watch(CMAKE_PARENT_LIST_FILE EOFHook) - -# Create the target that will eventually generate the apk - get_filename_component(QTDIR "${Qt5Core_DIR}/../../../" ABSOLUTE) - find_program(ANDROID_DEPLOY_QT androiddeployqt HINTS "${QTDIR}/bin") set(EXPORT_DIR "${CMAKE_BINARY_DIR}/${QTANDROID_EXPORTED_TARGET}_build= _apk/") set(EXECUTABLE_DESTINATION_PATH "${EXPORT_DIR}/libs/${ANDROID_ABI}/lib= ${QTANDROID_EXPORTED_TARGET}.so") + configure_file("${_CMAKE_ANDROID_DIR}/deployment-file.json.in" "${QTAN= DROID_EXPORTED_TARGET}-deployment.json.in") = add_custom_target(${CREATEAPK_TARGET_NAME} - COMMAND cmake -E echo "Generating $ with ${ANDROID_DEPLOY_QT}" + COMMAND cmake -E echo "Generating $ with $/androiddeployqt" COMMAND cmake -E copy_directory "${ANDROID_APK_DIR}" "${EXPORT_DIR= }" COMMAND cmake -E copy "$= " "${EXECUTABLE_DESTINATION_PATH}" - COMMAND ${ANDROID_DEPLOY_QT} --input "${QTANDROID_EXPORTED_TARGET}= -deployment.json" --output "${EXPORT_DIR}" --deployment bundled "\\$(ARGS)" + COMMAND cmake -DINPUT_FILE=3D"${QTANDROID_EXPORTED_TARGET}-deploym= ent.json.in" -DOUTPUT_FILE=3D"${QTANDROID_EXPORTED_TARGET}-deployment.json"= "-DTARGET_DIR=3D$" "-DTARGET= _NAME=3D${QTANDROID_EXPORTED_TARGET}" -P ${_CMAKE_ANDROID_DIR}/specifydepen= dencies.cmake + COMMAND $/androiddeployqt --input "${Q= TANDROID_EXPORTED_TARGET}-deployment.json" --output "${EXPORT_DIR}" --deplo= yment bundled "\\$(ARGS)" ) else() message(STATUS "You can export a target by specifying -DQTANDROID_EXPO= RTED_TARGET=3D") diff --git a/toolchain/deployment-file.json.in b/toolchain/deployment-file.= json.in index 8534cd2..9367bc1 100644 --- a/toolchain/deployment-file.json.in +++ b/toolchain/deployment-file.json.in @@ -8,7 +8,7 @@ "ndk-host": "@_HOST@", "target-architecture": "@ANDROID_ABI@", "application-binary": "@EXECUTABLE_DESTINATION_PATH@", - "android-extra-libs": "@_DEPS@", + "android-extra-libs": "##EXTRALIBS##", "android-extra-plugins": "@CMAKE_INSTALL_PREFIX@/share,@CMAKE_INSTALL_P= REFIX@/lib/qml", "android-package-source-directory": "@ANDROID_APK_DIR@", "sdkBuildToolsRevision": "@ANDROID_SDK_BUILD_TOOLS_REVISION@" diff --git a/toolchain/specifydependencies.cmake b/toolchain/specifydepende= ncies.cmake new file mode 100644 index 0000000..21b169a --- /dev/null +++ b/toolchain/specifydependencies.cmake @@ -0,0 +1,22 @@ +file(READ "${TARGET_DIR}/CMakeFiles/${TARGET_NAME}.dir/link.txt" out) + +string(FIND "${out}" "-o ${TARGET_NAME}" POS) #we trim the initial argumen= ts, we want the ones in the end. we find the target +string(SUBSTRING "${out}" ${POS} -1 out) #we +string(REGEX MATCHALL " /.+\\.so" outout "${out}") +string(STRIP "${outout}" outout) +string(REPLACE " /" ";/" outout "${outout}") + +set(extralibs) +foreach(lib IN LISTS outout) #now we filter Qt5 libraries, because Qt want= s to take care about these itself + if(NOT ${lib} MATCHES ".*/libQt5.*") + if(extralibs) + set(extralibs "${extralibs},${lib}") + else() + set(extralibs "${lib}") + endif() + endif() +endforeach() + +file(READ "${INPUT_FILE}" CONTENTS) +string(REPLACE "##EXTRALIBS##" "${extralibs}" NEWCONTENTS "${CONTENTS}") +file(WRITE "${OUTPUT_FILE}" ${NEWCONTENTS})