mirror of
https://github.com/libsdl-org/SDL.git
synced 2024-11-26 21:33:26 +08:00
cmake: create and install SDL3::Jar target for Android
This commit is contained in:
parent
53544cabaa
commit
a45b371de0
@ -1350,6 +1350,10 @@ if(ANDROID)
|
||||
VERSION "${SDL3_VERSION}"
|
||||
)
|
||||
set_property(TARGET SDL3-jar PROPERTY OUTPUT "${SDL3_BINARY_DIR}/SDL3-${SDL3_VERSION}.jar")
|
||||
add_library(SDL3__Jar INTERFACE)
|
||||
add_library(SDL3::Jar ALIAS SDL3__Jar)
|
||||
get_property(sdl3_jar_location TARGET SDL3-jar PROPERTY JAR_FILE)
|
||||
set_property(TARGET SDL3__Jar PROPERTY JAR_FILE "${sdl3_jar_location}")
|
||||
set(javasourcesjar "${SDL3_BINARY_DIR}/SDL3-${SDL3_VERSION}-sources.jar")
|
||||
string(REGEX REPLACE "${android_java_sources_root}/" "" sdl_relative_java_sources "${SDL_JAVA_SOURCES}")
|
||||
add_custom_command(
|
||||
@ -3292,6 +3296,7 @@ sdl_cmake_config_find_pkg_config_commands(SDL_TEST_FIND_PKG_CONFIG_COMMANDS
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
configure_package_config_file(cmake/SDL3Config.cmake.in SDL3Config.cmake
|
||||
NO_SET_AND_CHECK_MACRO
|
||||
PATH_VARS CMAKE_INSTALL_PREFIX
|
||||
INSTALL_DESTINATION "${SDL_SDL_INSTALL_CMAKEDIR}"
|
||||
)
|
||||
@ -3421,10 +3426,19 @@ if(NOT SDL_DISABLE_INSTALL)
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
set(SDL_INSTALL_JAVADIR "${CMAKE_INSTALL_DATAROOTDIR}/java" CACHE PATH "Path where to install java clases + java sources")
|
||||
if(TARGET SDL3-jar)
|
||||
install(FILES "${SDL3_BINARY_DIR}/SDL3.jar" "${SDL3_BINARY_DIR}/SDL3-${SDL3_VERSION}.jar"
|
||||
set(SDL_INSTALL_JAVADIR "${CMAKE_INSTALL_DATAROOTDIR}/java" CACHE PATH "Path where to install java clases + java sources")
|
||||
install(FILES $<TARGET_PROPERTY:SDL3-jar,INSTALL_FILES>
|
||||
DESTINATION "${SDL_INSTALL_JAVADIR}/SDL3")
|
||||
configure_package_config_file(cmake/SDL3jarTargets.cmake.in SDL3jarTargets.cmake
|
||||
INSTALL_DESTINATION "${SDL_SDL_INSTALL_CMAKEDIR}"
|
||||
PATH_VARS SDL_INSTALL_JAVADIR
|
||||
NO_CHECK_REQUIRED_COMPONENTS_MACRO
|
||||
INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}"
|
||||
)
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/SDL3jarTargets.cmake"
|
||||
DESTINATION "${SDL_SDL_INSTALL_CMAKEDIR}"
|
||||
)
|
||||
endif()
|
||||
if(TARGET SDL3-javasources)
|
||||
install(FILES "${SDL3_BINARY_DIR}/SDL3-${SDL3_VERSION}-sources.jar"
|
||||
|
@ -48,6 +48,11 @@ else()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ANDROID AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL3jarTargets.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/SDL3jarTargets.cmake")
|
||||
set(SDL3_Jar_FOUND TRUE)
|
||||
endif()
|
||||
|
||||
if(SDL3_SDL3-shared_FOUND OR SDL3_SDL3-static_FOUND)
|
||||
set(SDL3_SDL3_FOUND TRUE)
|
||||
endif()
|
||||
|
10
cmake/SDL3jarTargets.cmake.in
Normal file
10
cmake/SDL3jarTargets.cmake.in
Normal file
@ -0,0 +1,10 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
set_and_check(SDL3_JAR "@PACKAGE_SDL_INSTALL_JAVADIR@/SDL3/SDL3-@SDL3_VERSION@.jar")
|
||||
|
||||
if(NOT TARGET SDL3::Jar)
|
||||
add_library(SDL3::Jar INTERFACE IMPORTED)
|
||||
set_property(TARGET SDL3::Jar PROPERTY JAR_FILE "${SDL3_JAR}")
|
||||
endif()
|
||||
|
||||
unset(SDL3_JAR)
|
@ -93,4 +93,8 @@ find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3)
|
||||
add_executable(gui-whatever WIN32 main_gui.c)
|
||||
target_link_libraries(gui-whatever PRIVATE SDL3::SDL3)
|
||||
|
||||
if(ANDROID)
|
||||
find_package(SDL3 REQUIRED CONFIG COMPONENTS Jar)
|
||||
endif()
|
||||
|
||||
feature_summary(WHAT ALL)
|
||||
|
@ -583,7 +583,7 @@ if(SDL_INSTALL_TESTS)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(ANDROID AND TARGET SDL3-jar)
|
||||
if(ANDROID AND TARGET SDL3::Jar)
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake/android")
|
||||
find_package(SdlAndroid MODULE)
|
||||
if(SdlAndroid_FOUND)
|
||||
@ -640,14 +640,14 @@ if(ANDROID AND TARGET SDL3-jar)
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${classes_path}"
|
||||
COMMAND ${Java_JAVAC_EXECUTABLE}
|
||||
-source 1.8 -target 1.8
|
||||
-bootclasspath "$<TARGET_PROPERTY:SDL3-jar,OUTPUT>"
|
||||
-bootclasspath "$<TARGET_PROPERTY:SDL3::Jar,JAR_FILE>"
|
||||
"${JAVA_PACKAGE_DIR}/SDLEntryTestActivity.java"
|
||||
"${JAVA_PACKAGE_DIR}/SDLTestActivity.java"
|
||||
$<TARGET_PROPERTY:${TEST}-apk-linked,JAVA_R>
|
||||
-cp "$<TARGET_PROPERTY:SDL3-jar,OUTPUT>:${path_android_jar}"
|
||||
-cp "$<TARGET_PROPERTY:SDL3::Jar,JAR_FILE>:${SDL_ANDROID_PLATFORM_ANDROID_JAR}"
|
||||
-d "${classes_path}"
|
||||
COMMAND ${Java_JAR_EXECUTABLE} cf "${OUT_JAR}" -C "${classes_path}" .
|
||||
DEPENDS $<TARGET_PROPERTY:${TEST}-apk-linked,OUTPUTS> "$<TARGET_PROPERTY:SDL3-jar,OUTPUT>" "${JAVA_PACKAGE_DIR}/SDLTestActivity.java" "${JAVA_PACKAGE_DIR}/SDLEntryTestActivity.java"
|
||||
DEPENDS $<TARGET_PROPERTY:${TEST}-apk-linked,OUTPUTS> "$<TARGET_PROPERTY:SDL3::Jar,JAR_FILE>" "${JAVA_PACKAGE_DIR}/SDLTestActivity.java" "${JAVA_PACKAGE_DIR}/SDLEntryTestActivity.java"
|
||||
)
|
||||
add_custom_target(${TEST}-jar DEPENDS "${OUT_JAR}")
|
||||
set_property(TARGET ${TEST}-jar PROPERTY OUTPUT "${OUT_JAR}")
|
||||
@ -663,10 +663,10 @@ if(ANDROID AND TARGET SDL3-jar)
|
||||
OUTPUT "${classes_dex}"
|
||||
COMMAND SdlAndroid::d8
|
||||
$<TARGET_PROPERTY:${TEST}-jar,OUTPUT>
|
||||
$<TARGET_PROPERTY:SDL3-jar,OUTPUT>
|
||||
--lib "${path_android_jar}"
|
||||
$<TARGET_PROPERTY:SDL3::Jar,JAR_FILE>
|
||||
--lib "${SDL_ANDROID_PLATFORM_ANDROID_JAR}"
|
||||
--output "${dexworkdir}"
|
||||
DEPENDS $<TARGET_PROPERTY:${TEST}-jar,OUTPUT> $<TARGET_PROPERTY:SDL3-jar,OUTPUT>
|
||||
DEPENDS $<TARGET_PROPERTY:${TEST}-jar,OUTPUT> $<TARGET_PROPERTY:SDL3::Jar,JAR_FILE>
|
||||
)
|
||||
add_custom_target(${TEST}-dex DEPENDS "${classes_dex}")
|
||||
set_property(TARGET ${TEST}-dex PROPERTY OUTPUT "${classes_dex}")
|
||||
|
Loading…
Reference in New Issue
Block a user