diff options
author | Aleix Pol <aleixpol@kde.org> | 2015-10-01 01:25:03 +0200 |
---|---|---|
committer | Aleix Pol <aleixpol@kde.org> | 2015-10-01 01:25:03 +0200 |
commit | 3b20ef911eb83b7bd37315ace682e0e6bc6195d9 (patch) | |
tree | 610f42d8ea9a803b4b905e2fd4dea65764829d46 | |
parent | 1c20edb86115ecf788f64cb8563b85129c7a669d (diff) | |
download | extra-cmake-modules-3b20ef911eb83b7bd37315ace682e0e6bc6195d9.tar.gz extra-cmake-modules-3b20ef911eb83b7bd37315ace682e0e6bc6195d9.tar.bz2 |
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
-rw-r--r-- | toolchain/Android.cmake | 30 | ||||
-rw-r--r-- | toolchain/deployment-file.json.in | 2 | ||||
-rw-r--r-- | toolchain/specifydependencies.cmake | 22 |
3 files changed, 27 insertions, 27 deletions
diff --git a/toolchain/Android.cmake b/toolchain/Android.cmake index 9b104747..a60771bc 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} PROPERTY INTERFACE_LINK_LIBRARIES) - set(_DEPS_LIST) - foreach(_DEP IN LISTS _DEPENDENCIES) - if(NOT _DEP MATCHES "Qt5::.*") - get_property(_DEP_LOCATION TARGET ${_DEP} PROPERTY "LOCATION_${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" "${QTANDROID_EXPORTED_TARGET}-deployment.json.in") add_custom_target(${CREATEAPK_TARGET_NAME} - COMMAND cmake -E echo "Generating $<TARGET_NAME:${QTANDROID_EXPORTED_TARGET}> with ${ANDROID_DEPLOY_QT}" + COMMAND cmake -E echo "Generating $<TARGET_NAME:${QTANDROID_EXPORTED_TARGET}> with $<TARGET_FILE_DIR:Qt5::qmake>/androiddeployqt" COMMAND cmake -E copy_directory "${ANDROID_APK_DIR}" "${EXPORT_DIR}" COMMAND cmake -E copy "$<TARGET_FILE:${QTANDROID_EXPORTED_TARGET}>" "${EXECUTABLE_DESTINATION_PATH}" - COMMAND ${ANDROID_DEPLOY_QT} --input "${QTANDROID_EXPORTED_TARGET}-deployment.json" --output "${EXPORT_DIR}" --deployment bundled "\\$(ARGS)" + COMMAND cmake -DINPUT_FILE="${QTANDROID_EXPORTED_TARGET}-deployment.json.in" -DOUTPUT_FILE="${QTANDROID_EXPORTED_TARGET}-deployment.json" "-DTARGET_DIR=$<TARGET_FILE_DIR:${QTANDROID_EXPORTED_TARGET}>" "-DTARGET_NAME=${QTANDROID_EXPORTED_TARGET}" -P ${_CMAKE_ANDROID_DIR}/specifydependencies.cmake + COMMAND $<TARGET_FILE_DIR:Qt5::qmake>/androiddeployqt --input "${QTANDROID_EXPORTED_TARGET}-deployment.json" --output "${EXPORT_DIR}" --deployment bundled "\\$(ARGS)" ) else() message(STATUS "You can export a target by specifying -DQTANDROID_EXPORTED_TARGET=<targetname>") diff --git a/toolchain/deployment-file.json.in b/toolchain/deployment-file.json.in index 8534cd2f..9367bc1b 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_PREFIX@/lib/qml", "android-package-source-directory": "@ANDROID_APK_DIR@", "sdkBuildToolsRevision": "@ANDROID_SDK_BUILD_TOOLS_REVISION@" diff --git a/toolchain/specifydependencies.cmake b/toolchain/specifydependencies.cmake new file mode 100644 index 00000000..21b169ae --- /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 arguments, 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 wants 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}) |