Skip to content

Instantly share code, notes, and snippets.

@mgerhardy
Created October 8, 2015 19:44
Show Gist options
  • Save mgerhardy/5e4432d6a1202d2c1cb4 to your computer and use it in GitHub Desktop.
Save mgerhardy/5e4432d6a1202d2c1cb4 to your computer and use it in GitHub Desktop.
CMake android install packages by id - ANDROID_SDK_TOOL is set to the "android" binary
set(ANDROID_SDK_TOOL android)
#
# Install android packages
#
# parameters:
# PACKAGE The package id that you need to install
#
macro(cp_android_package PACKAGE)
message("install android sdk package ${PACKAGE}")
file(WRITE ${CMAKE_BINARY_DIR}/yes.txt "y")
execute_process(
COMMAND ${ANDROID_SDK_TOOL} list target -c
OUTPUT_VARIABLE TARGETS_LIST
)
if (${TARGETS_LIST} MATCHES ${PACKAGE})
message("${PACKAGE} is already installed")
else()
execute_process(
COMMAND ${ANDROID_SDK_TOOL} update sdk -a -u -s -t ${PACKAGE}
INPUT_FILE ${CMAKE_BINARY_DIR}/yes.txt
)
endif()
endmacro()
Call it with:
cp_android_package("android-13")
cp_android_package("android-16")
cp_android_package("extra-google-google_play_services")
cp_android_package("platform-tools")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment