use find_package over manual configuration

This commit is contained in:
Kylie C 2025-08-14 15:54:56 -04:00
parent fc2fee33ab
commit 434afbe084
2 changed files with 6 additions and 13 deletions

View File

@ -75,15 +75,8 @@ if (DOWNLOAD_DEPENDENCIES)
include(FetchContent) include(FetchContent)
if(ANDROID) if(ANDROID)
set(SDL3_SOURCE_DIR "${CMAKE_SOURCE_DIR}/android-project/build/_deps/sdl3-src") # Built by Gradle
find_package(SDL3 REQUIRED CONFIG COMPONENTS Shared)
add_library(SDL3 SHARED IMPORTED)
set_target_properties(SDL3 PROPERTIES
IMPORTED_LOCATION "${SDL3_SOURCE_DIR}/build-android/${CMAKE_ANDROID_ARCH_ABI}-build/libSDL3.so"
INTERFACE_INCLUDE_DIRECTORIES "${SDL3_SOURCE_DIR}/include"
)
add_library(SDL3::SDL3 ALIAS SDL3)
add_library(SDL3::Headers ALIAS SDL3)
else() else()
if (WINDOWS_STORE) if (WINDOWS_STORE)
FetchContent_Declare( FetchContent_Declare(

View File

@ -66,7 +66,7 @@ afterEvaluate {
} }
} }
def aarDest = file("${projectDir}/libs/SDL3.aar") def aarDest = project.providers.provider { file("${projectDir}/libs/SDL3.aar") }
tasks.register('downloadSDL3', Exec) { tasks.register('downloadSDL3', Exec) {
workingDir = androidProject workingDir = androidProject
commandLine 'cmake', '-P', 'downloadSDL3.cmake' commandLine 'cmake', '-P', 'downloadSDL3.cmake'
@ -85,14 +85,14 @@ tasks.register('compileSDL3AndroidArchive', Exec) {
def aarFile = file("${androidProject}/${sdl3Dir}/build-android").listFiles().find { def aarFile = file("${androidProject}/${sdl3Dir}/build-android").listFiles().find {
it.name.endsWith(".aar") it.name.endsWith(".aar")
} }
aarDest.parentFile.mkdirs() aarDest.get().parentFile.mkdirs()
aarFile.renameTo(aarDest) aarFile.renameTo(aarDest.get())
} }
} }
tasks.register('ensureSDL3') { tasks.register('ensureSDL3') {
// if DOWNLOAD_DEPENDENCIES=OFF download the version appropriate // if DOWNLOAD_DEPENDENCIES=OFF download the version appropriate
// 'devel android zip' and place the .aar at `aarDest` // 'devel android zip' and place the .aar at `aarDest`
if (aarDest.exists()) { return false } if (aarDest.get().exists()) { return false }
dependsOn(compileSDL3AndroidArchive) dependsOn(compileSDL3AndroidArchive)
} }