Changeset View
Changeset View
Standalone View
Standalone View
toolchain/Android.cmake
Show First 20 Lines • Show All 210 Lines • ▼ Show 20 Line(s) | |||||
211 | #we want executables to be shared libraries, hooks will invoke the exported cmake function | 211 | #we want executables to be shared libraries, hooks will invoke the exported cmake function | ||
212 | set(CMAKE_CXX_LINK_EXECUTABLE | 212 | set(CMAKE_CXX_LINK_EXECUTABLE | ||
213 | "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" | 213 | "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" | ||
214 | ) | 214 | ) | ||
215 | 215 | | |||
216 | # needed for Qt to define Q_OS_ANDROID | 216 | # needed for Qt to define Q_OS_ANDROID | ||
217 | add_definitions(-DANDROID) | 217 | add_definitions(-DANDROID) | ||
218 | 218 | | |||
219 | set(ECM_DIR "${CMAKE_CURRENT_LIST_DIR}/.." CACHE STRING "") | ||||
219 | 220 | | |||
220 | ######### generation | 221 | ######### generation | ||
221 | 222 | | |||
222 | set(CREATEAPK_TARGET_NAME "create-apk-${QTANDROID_EXPORTED_TARGET}") | 223 | set(CREATEAPK_TARGET_NAME "create-apk-${QTANDROID_EXPORTED_TARGET}") | ||
223 | # Need to ensure we only get in here once, as this file is included twice: | 224 | # Need to ensure we only get in here once, as this file is included twice: | ||
224 | # from CMakeDetermineSystem.cmake and from CMakeSystem.cmake generated within the | 225 | # from CMakeDetermineSystem.cmake and from CMakeSystem.cmake generated within the | ||
225 | # build directory. | 226 | # build directory. | ||
226 | if(DEFINED QTANDROID_EXPORTED_TARGET AND NOT TARGET ${CREATEAPK_TARGET_NAME}) | 227 | if(DEFINED QTANDROID_EXPORTED_TARGET AND NOT TARGET ${CREATEAPK_TARGET_NAME}) | ||
Show All 10 Lines | |||||
237 | add_custom_target(${CREATEAPK_TARGET_NAME} | 238 | add_custom_target(${CREATEAPK_TARGET_NAME} | ||
238 | COMMAND cmake -E echo "Generating $<TARGET_NAME:${QTANDROID_EXPORTED_TARGET}> with $<TARGET_FILE_DIR:Qt5::qmake>/androiddeployqt" | 239 | COMMAND cmake -E echo "Generating $<TARGET_NAME:${QTANDROID_EXPORTED_TARGET}> with $<TARGET_FILE_DIR:Qt5::qmake>/androiddeployqt" | ||
239 | COMMAND cmake -E remove_directory "${EXPORT_DIR}" | 240 | COMMAND cmake -E remove_directory "${EXPORT_DIR}" | ||
240 | COMMAND cmake -E copy_directory "${ANDROID_APK_DIR}" "${EXPORT_DIR}" | 241 | COMMAND cmake -E copy_directory "${ANDROID_APK_DIR}" "${EXPORT_DIR}" | ||
241 | COMMAND cmake -E copy "$<TARGET_FILE:${QTANDROID_EXPORTED_TARGET}>" "${EXECUTABLE_DESTINATION_PATH}" | 242 | COMMAND cmake -E copy "$<TARGET_FILE:${QTANDROID_EXPORTED_TARGET}>" "${EXECUTABLE_DESTINATION_PATH}" | ||
242 | 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}" "-DEXPORT_DIR=${CMAKE_INSTALL_PREFIX}" -P ${_CMAKE_ANDROID_DIR}/specifydependencies.cmake | 243 | 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}" "-DEXPORT_DIR=${CMAKE_INSTALL_PREFIX}" -P ${_CMAKE_ANDROID_DIR}/specifydependencies.cmake | ||
243 | COMMAND $<TARGET_FILE_DIR:Qt5::qmake>/androiddeployqt --input "${QTANDROID_EXPORTED_TARGET}-deployment.json" --output "${EXPORT_DIR}" --deployment bundled "\\$(ARGS)" | 244 | COMMAND $<TARGET_FILE_DIR:Qt5::qmake>/androiddeployqt --input "${QTANDROID_EXPORTED_TARGET}-deployment.json" --output "${EXPORT_DIR}" --deployment bundled "\\$(ARGS)" | ||
244 | ) | 245 | ) | ||
246 | | ||||
247 | add_custom_target(install-apk-${QTANDROID_EXPORTED_TARGET} | ||||
248 | COMMAND adb install -r "${EXPORT_DIR}/bin/QtApp-debug.apk" | ||||
249 | ) | ||||
245 | else() | 250 | else() | ||
246 | message(STATUS "You can export a target by specifying -DQTANDROID_EXPORTED_TARGET=<targetname>") | 251 | message(STATUS "You can export a target by specifying -DQTANDROID_EXPORTED_TARGET=<targetname>") | ||
247 | endif() | 252 | endif() |