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)
if(ANDROID)
set(SDL3_SOURCE_DIR "${CMAKE_SOURCE_DIR}/android-project/build/_deps/sdl3-src")
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)
# Built by Gradle
find_package(SDL3 REQUIRED CONFIG COMPONENTS Shared)
else()
if (WINDOWS_STORE)
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) {
workingDir = androidProject
commandLine 'cmake', '-P', 'downloadSDL3.cmake'
@ -85,14 +85,14 @@ tasks.register('compileSDL3AndroidArchive', Exec) {
def aarFile = file("${androidProject}/${sdl3Dir}/build-android").listFiles().find {
it.name.endsWith(".aar")
}
aarDest.parentFile.mkdirs()
aarFile.renameTo(aarDest)
aarDest.get().parentFile.mkdirs()
aarFile.renameTo(aarDest.get())
}
}
tasks.register('ensureSDL3') {
// if DOWNLOAD_DEPENDENCIES=OFF download the version appropriate
// 'devel android zip' and place the .aar at `aarDest`
if (aarDest.exists()) { return false }
if (aarDest.get().exists()) { return false }
dependsOn(compileSDL3AndroidArchive)
}