Skip to content

Commit

Permalink
Fix cmake android when outside of hello imgui
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Dec 17, 2023
1 parent d48798b commit 258f81c
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 46 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ set(CMAKE_CXX_STANDARD 17)
# hello_imgui_add_app(app_name file1.cpp file2.cpp ...)
#
# Features:
# * It will automaticaly link the target to the required libraries (hello_imgui, OpenGl, glad, etc)
# * It will automatically link the target to the required libraries (hello_imgui, OpenGl, glad, etc)
# * It will embed the assets (for desktop, mobile, and emscripten apps)
# * It will perform additional customization (app icon and name on mobile platforms, etc)
set(HELLOIMGUI_CMAKE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/hello_imgui_cmake CACHE STRING "" FORCE)
Expand Down
19 changes: 4 additions & 15 deletions hello_imgui_cmake/android/apkCMake/apkCMake.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
if (NOT DEFINED apkCMake_projectTemplateFolder)
message(FATAL_ERROR "Please define apkCMake_projectTemplateFolder")
endif()
if (NOT DEFINED apkCMake_resTemplateFolder)
message(FATAL_ERROR "Please define apkCMake_resTemplateFolder")
endif()

set(apkCMake_projectTemplateFolder ${HELLOIMGUI_CMAKE_PATH}/android/apkCMake/templates/sdl CACHE STRING "" FORCE)
include(${apkCMake_projectTemplateFolder}/apkCMake_makeSymLinks.cmake)


Expand Down Expand Up @@ -187,14 +181,10 @@ function(apkCMake_copyAndConfigureDirectoryContent src dst)
endfunction()


function(apkCMake_addResFolder resFolder)
set(resOutputFolder ${apkCMake_outputProjectFolder}/app/src/main/res)
apkCMake_copyDirectoryContent(${resFolder} ${resOutputFolder})
endfunction()


function(apkCMake_addTemplateResFolder)
apkCMake_addResFolder(${apkCMake_resTemplateFolder})
set(apkCMake_resTemplateFolder ${HELLOIMGUI_CMAKE_PATH}/android/res)
set(resOutputFolder ${apkCMake_outputProjectFolder}/app/src/main/res)
apkCMake_copyDirectoryContent(${apkCMake_resTemplateFolder} ${resOutputFolder})
endfunction()


Expand Down Expand Up @@ -225,7 +215,6 @@ endfunction()


function(apkCMake_makeAndroidStudioProject appTargetToEmbed assets_location)
#message(FATAL_ERROR "ANDROID_STL=${ANDROID_STL}")
message(STATUS "apkCMake_makeAndroidStudioProject ${appTargetToEmbed}")
apkCMake_fillVariables(${appTargetToEmbed})
apkCMake_copyAndConfigureDirectoryContent(${apkCMake_projectTemplateFolder}/gradle_template ${apkCMake_outputProjectFolder})
Expand Down
7 changes: 0 additions & 7 deletions hello_imgui_cmake/android/res/values/colors.xml

This file was deleted.

3 changes: 0 additions & 3 deletions hello_imgui_cmake/android/res/values/strings.xml

This file was deleted.

8 changes: 0 additions & 8 deletions hello_imgui_cmake/android/res/values/styles.xml

This file was deleted.

16 changes: 6 additions & 10 deletions hello_imgui_cmake/hello_imgui_add_app.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,14 @@ endfunction()
function(hello_imgui_platform_customization app_name assets_location)
endfunction()
# But it can be overriden by platform specific implementations, in the following files:
include(${CMAKE_CURRENT_LIST_DIR}/apple/hello_imgui_apple.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/android/hello_imgui_android.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/emscripten/hello_imgui_emscripten.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/windows/hello_imgui_windows.cmake)
include(${HELLOIMGUI_CMAKE_PATH}/apple/hello_imgui_apple.cmake)
include(${HELLOIMGUI_CMAKE_PATH}/android/hello_imgui_android.cmake)
include(${HELLOIMGUI_CMAKE_PATH}/emscripten/hello_imgui_emscripten.cmake)
include(${HELLOIMGUI_CMAKE_PATH}/windows/hello_imgui_windows.cmake)
include(${HELLOIMGUI_CMAKE_PATH}/assets/hello_imgui_assets.cmake)

include(${HELLOIMGUI_CMAKE_PATH}/android/apkCMake/apkCMake.cmake)

include(${CMAKE_CURRENT_LIST_DIR}/assets/hello_imgui_assets.cmake)


set(apkCMake_projectTemplateFolder ${CMAKE_CURRENT_LIST_DIR}/android/apkCMake/templates/sdl)
set(apkCMake_resTemplateFolder ${CMAKE_CURRENT_LIST_DIR}/android/res)
include(${CMAKE_CURRENT_LIST_DIR}/android/apkCMake/apkCMake.cmake)

function(set_bundle_variables_defaults app_name)
if (NOT DEFINED HELLO_IMGUI_BUNDLE_IDENTIFIER_URL_PART)
Expand Down
8 changes: 7 additions & 1 deletion tools/android/cmake_arm-android.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#!/usr/bin/env bash

# Assert we have one parameter and set source_dir to it
if [ $# -ne 1 ]; then
echo "Usage: $0 <source_dir>"
exit 1
fi
export source_dir=$1

THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
export source_dir=$THIS_DIR/../..

export android_abi=armeabi-v7a
$THIS_DIR/_impl_cmake_android.sh
8 changes: 7 additions & 1 deletion tools/android/cmake_arm64-android.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#!/usr/bin/env bash

# Assert we have one parameter and set source_dir to it
if [ $# -ne 1 ]; then
echo "Usage: $0 <source_dir>"
exit 1
fi
export source_dir=$1

THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
export source_dir=$THIS_DIR/../..

export android_abi=arm64-v8a
$THIS_DIR/_impl_cmake_android.sh

0 comments on commit 258f81c

Please sign in to comment.