Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

Commit

Permalink
Set GDBSERVER basing on CMAKE_ANDROID_{NDK,ARCH}
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslo committed Nov 15, 2016
1 parent 7a5f840 commit 32531ad
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
22 changes: 21 additions & 1 deletion AndroidApk.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,26 @@ function(android_create_apk)
endforeach()
endif()

string(COMPARE EQUAL "${CMAKE_ANDROID_NDK}" "" is_empty)
if(is_empty)
message(FATAL_ERROR "CMAKE_ANDROID_NDK is empty")
endif()

string(COMPARE EQUAL "${CMAKE_ANDROID_ARCH}" "" is_empty)
if(is_empty)
message(FATAL_ERROR "CMAKE_ANDROID_ARCH is empty")
endif()

# Rejected: https://gitlab.kitware.com/cmake/cmake/merge_requests/74
set(
GDBSERVER
"${CMAKE_ANDROID_NDK}/prebuilt/android-${CMAKE_ANDROID_ARCH}/gdbserver/gdbserver"
)

if(NOT EXISTS "${GDBSERVER}")
message(FATAL_ERROR "gdbserver not found: ${GDBSERVER}")
endif()

add_custom_command(
TARGET
"${apk_target_name}"
Expand All @@ -462,7 +482,7 @@ function(android_create_apk)
"-DANDROID_ZIPALIGN_COMMAND_PATH=${ANDROID_ZIPALIGN_COMMAND_PATH}"
"-DAPK_BUILD_TYPE=$<CONFIG>"
"-DAPPLICATION_NAME=${APPLICATION_NAME}"
"-DCMAKE_GDBSERVER=${CMAKE_GDBSERVER}"
"-DGDBSERVER=${GDBSERVER}"
"-D_ANDROID_APK_THIS_DIRECTORY=${_ANDROID_APK_THIS_DIRECTORY}"
"-Dx_BASE_TARGET=${x_BASE_TARGET}"
"-Dx_DIRECTORY=${x_DIRECTORY}"
Expand Down
10 changes: 5 additions & 5 deletions scripts/CreateApk.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ if(is_empty)
message(FATAL_ERROR "APPLICATION_NAME not set")
endif()

string(COMPARE EQUAL "${CMAKE_GDBSERVER}" "" is_empty)
string(COMPARE EQUAL "${GDBSERVER}" "" is_empty)
if(is_empty)
message(FATAL_ERROR "CMAKE_GDBSERVER not set")
message(FATAL_ERROR "GDBSERVER not set")
endif()

string(COMPARE EQUAL "${ANDROID_ANDROID_COMMAND_PATH}" "" is_empty)
Expand Down Expand Up @@ -112,13 +112,13 @@ endif()

# In case of debug build, do also copy gdbserver
if(is_debug)
if(NOT EXISTS "${CMAKE_GDBSERVER}")
message(FATAL_ERROR "Not found: ${CMAKE_GDBSERVER}")
if(NOT EXISTS "${GDBSERVER}")
message(FATAL_ERROR "Not found: ${GDBSERVER}")
endif()
execute_process(
COMMAND
"${CMAKE_COMMAND}" -E copy
"${CMAKE_GDBSERVER}"
"${GDBSERVER}"
"${x_DIRECTORY}/libs/${ANDROID_ABI_DIR}"
WORKING_DIRECTORY "${x_DIRECTORY}"
RESULT_VARIABLE result
Expand Down

0 comments on commit 32531ad

Please sign in to comment.