Add apple xcframework support (#1786)

* Add apple xcframework support

* Fix ci
This commit is contained in:
Deal 2024-04-03 01:48:30 +08:00 committed by GitHub
parent 0c7181c77c
commit 9e944935b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 94 additions and 55 deletions

View File

@ -58,9 +58,13 @@ function(_1kfetch_dist package_name)
endif()
# set platform specific path, PLATFORM_NAME provided by user: win32,winrt,mac,ios,android,tvos,watchos,linux
set(_prebuilt_lib_dir "${_prebuilt_root}/lib/${PLATFORM_NAME}")
if(ANDROID OR WIN32)
set(_prebuilt_lib_dir "${_prebuilt_lib_dir}/${ARCH_ALIAS}")
if(APPLE) # since 1kiss_dist v80+, xcframework don't require platform spec sub folder
set(_prebuilt_lib_dir "${_prebuilt_root}/lib")
else()
set(_prebuilt_lib_dir "${_prebuilt_root}/lib/${PLATFORM_NAME}")
if(ANDROID OR WIN32)
set(_prebuilt_lib_dir "${_prebuilt_lib_dir}/${ARCH_ALIAS}")
endif()
endif()
set(${package_name}_INC_DIR ${_prebuilt_root}/include PARENT_SCOPE)
set(${package_name}_LIB_DIR ${_prebuilt_lib_dir} PARENT_SCOPE)

View File

@ -309,6 +309,8 @@ add_subdirectory(openssl)
if(ANDROID OR LINUX)
target_link_libraries(OpenSSL::SSL INTERFACE OpenSSL::Crypto)
target_link_libraries(3rdparty INTERFACE OpenSSL::SSL)
elseif(APPLE)
target_link_libraries(3rdparty INTERFACE openssl)
else()
target_link_libraries(3rdparty
INTERFACE OpenSSL::Crypto

6
3rdparty/README.md vendored
View File

@ -27,7 +27,7 @@
## c-ares
- [![Upstream](https://img.shields.io/github/v/release/c-ares/c-ares?label=Upstream)](https://github.com/c-ares/c-ares)
- Version: 1.25.0
- Version: 1.28.1
- License: MIT
## Chipmunk2D
@ -52,7 +52,7 @@
## curl
- [![Upstream](https://img.shields.io/github/v/release/curl/curl?label=Upstream)](https://github.com/curl/curl)
- Version: 8.6.0
- Version: 8.7.1
- License: Curl (MIT/X)
## FastLZ
@ -123,7 +123,7 @@
- luajit
- Upstream: https://github.com/LuaJIT/LuaJIT
- Version: 2.1-9cc2e42
- Version: 2.1-d06beb0
- License: MIT
- tolua

View File

@ -26,6 +26,10 @@ if(WINDOWS)
set_target_properties(${target_name} PROPERTIES
IMPORTED_IMPLIB "${cares_LIB_DIR}/cares.lib"
)
elseif(APPLE)
set_target_properties(${target_name} PROPERTIES
IMPORTED_LOCATION "${cares_LIB_DIR}/cares.xcframework"
)
else()
set_target_properties(${target_name} PROPERTIES
IMPORTED_LOCATION "${cares_LIB_DIR}/libcares.a"

View File

@ -20,6 +20,10 @@ if(WINDOWS)
IMPORTED_LOCATION "${curl_LIB_DIR}/lib${lib_name}.dll"
IMPORTED_IMPLIB "${curl_LIB_DIR}/lib${lib_name}_imp.lib"
)
elseif(APPLE)
set_target_properties(${target_name} PROPERTIES
IMPORTED_LOCATION "${curl_LIB_DIR}/${lib_name}.xcframework"
)
else()
set_target_properties(${target_name} PROPERTIES
IMPORTED_LOCATION "${curl_LIB_DIR}/lib${lib_name}.a"

View File

@ -16,6 +16,10 @@ if(WINDOWS)
set_target_properties(${target_name} PROPERTIES
IMPORTED_LOCATION "${jpeg-turbo_LIB_DIR}/jpeg-static.lib"
)
elseif(APPLE)
set_target_properties(${target_name} PROPERTIES
IMPORTED_LOCATION "${jpeg-turbo_LIB_DIR}/jpeg.xcframework"
)
else()
set_target_properties(${target_name} PROPERTIES
IMPORTED_LOCATION "${jpeg-turbo_LIB_DIR}/libjpeg.a"

View File

@ -20,6 +20,10 @@ if(WINDOWS)
IMPORTED_LOCATION "${luajit_LIB_DIR}/lua51.dll"
IMPORTED_IMPLIB "${luajit_LIB_DIR}/lua51.lib"
)
elseif(APPLE)
set_target_properties(${target_name} PROPERTIES
IMPORTED_LOCATION "${luajit_LIB_DIR}/${lib_name}.xcframework"
)
else()
set_target_properties(${target_name} PROPERTIES
IMPORTED_LOCATION "${luajit_LIB_DIR}/lib${lib_name}.a"

View File

@ -7,48 +7,57 @@ _1kfetch_dist(openssl)
set(OPENSSL_INCLUDE_DIR "${openssl_INC_DIR}" CACHE STRING "OpenSSL include dir" FORCE)
# -----macro: set openssl sub target-----
macro(set_openssl_sub_target sub_target_name sub_lib_name)
if(WINDOWS)
add_library(${sub_target_name} SHARED IMPORTED GLOBAL)
else()
add_library(${sub_target_name} STATIC IMPORTED GLOBAL)
endif()
set_target_properties(${sub_target_name} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${openssl_INC_DIR}"
)
set(imp_lib_name "")
if(WINDOWS)
set(impl_lib_suffix "")
if(WIN64)
set(impl_lib_suffix "-${ARCH_ALIAS}")
if(NOT APPLE)
# -----macro: set openssl sub target-----
macro(set_openssl_sub_target sub_target_name sub_lib_name)
if(WINDOWS)
add_library(${sub_target_name} SHARED IMPORTED GLOBAL)
else()
add_library(${sub_target_name} STATIC IMPORTED GLOBAL)
endif()
set(imp_lib_name "${openssl_LIB_DIR}/lib${sub_lib_name}.lib")
set_target_properties(${sub_target_name} PROPERTIES
IMPORTED_LOCATION "${openssl_LIB_DIR}/lib${sub_lib_name}-3${impl_lib_suffix}.dll"
IMPORTED_IMPLIB "${openssl_LIB_DIR}/lib${sub_lib_name}.lib"
)
else()
set(imp_lib_name "${openssl_LIB_DIR}/lib${sub_lib_name}.a")
set_target_properties(${sub_target_name} PROPERTIES
IMPORTED_LOCATION "${openssl_LIB_DIR}/lib${sub_lib_name}.a"
)
endif()
if(${sub_lib_name} STREQUAL "ssl")
set(OPENSSL_ROOT_DIR "${openssl_LIB_DIR}" CACHE STRING "" FORCE)
set(OPENSSL_SSL_LIBRARY "${imp_lib_name}" CACHE STRING "" FORCE)
else()
set(OPENSSL_CRYPTO_LIBRARY "${imp_lib_name}" CACHE STRING "" FORCE)
endif()
endmacro()
# -----sub target 1: ssl-----
set(target_name OpenSSL::SSL ssl)
set_openssl_sub_target(${target_name})
set_target_properties(${sub_target_name} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${openssl_INC_DIR}"
)
# -----sub target 2: crypto-----
set(target_name OpenSSL::Crypto crypto)
set_openssl_sub_target(${target_name})
set(imp_lib_name "")
if(WINDOWS)
set(impl_lib_suffix "")
if(WIN64)
set(impl_lib_suffix "-${ARCH_ALIAS}")
endif()
set(imp_lib_name "${openssl_LIB_DIR}/lib${sub_lib_name}.lib")
set_target_properties(${sub_target_name} PROPERTIES
IMPORTED_LOCATION "${openssl_LIB_DIR}/lib${sub_lib_name}-3${impl_lib_suffix}.dll"
IMPORTED_IMPLIB "${openssl_LIB_DIR}/lib${sub_lib_name}.lib"
)
else()
set(imp_lib_name "${openssl_LIB_DIR}/lib${sub_lib_name}.a")
set_target_properties(${sub_target_name} PROPERTIES
IMPORTED_LOCATION "${openssl_LIB_DIR}/lib${sub_lib_name}.a"
)
endif()
if(${sub_lib_name} STREQUAL "ssl")
set(OPENSSL_ROOT_DIR "${openssl_LIB_DIR}" CACHE STRING "" FORCE)
set(OPENSSL_SSL_LIBRARY "${imp_lib_name}" CACHE STRING "" FORCE)
else()
set(OPENSSL_CRYPTO_LIBRARY "${imp_lib_name}" CACHE STRING "" FORCE)
endif()
endmacro()
# -----sub target 1: ssl-----
set(target_name OpenSSL::SSL ssl)
set_openssl_sub_target(${target_name})
# -----sub target 2: crypto-----
set(target_name OpenSSL::Crypto crypto)
set_openssl_sub_target(${target_name})
else()
set(target_name ${lib_name})
add_library(${target_name} STATIC IMPORTED GLOBAL)
set_target_properties(${target_name} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${openssl_INC_DIR}"
IMPORTED_LOCATION "${openssl_LIB_DIR}/openssl.xcframework"
)
endif()

View File

@ -11,18 +11,23 @@ endif()
set(ZLIB_INCLUDE_DIR "${zlib_INC_DIR}" CACHE STRING "zlib include dir" FORCE)
if(NOT WINDOWS)
set(ZLIB_LIBRARY "${zlib_LIB_DIR}/libz.a" CACHE STRING "zlib library" FORCE)
set_target_properties(${target_name} PROPERTIES
IMPORTED_LOCATION "${zlib_LIB_DIR}/libz.a"
)
else()
if(WINDOWS)
set(ZLIB_LIBRARY "${zlib_LIB_DIR}/zlib.lib" CACHE STRING "zlib library" FORCE)
set_target_properties(${target_name} PROPERTIES
IMPORTED_LOCATION "${zlib_LIB_DIR}/zlib1.dll"
IMPORTED_IMPLIB "${zlib_LIB_DIR}/zlib.lib"
INTERFACE_COMPILE_DEFINITIONS ZLIB_DLL=1
)
elseif(APPLE)
set(ZLIB_LIBRARY "${zlib_LIB_DIR}/zlib.xcframework" CACHE STRING "zlib library" FORCE)
set_target_properties(${target_name} PROPERTIES
IMPORTED_LOCATION "${zlib_LIB_DIR}/zlib.xcframework"
)
else()
set(ZLIB_LIBRARY "${zlib_LIB_DIR}/libz.a" CACHE STRING "zlib library" FORCE)
set_target_properties(${target_name} PROPERTIES
IMPORTED_LOCATION "${zlib_LIB_DIR}/libz.a"
)
endif()
set_target_properties(${target_name} PROPERTIES

View File

@ -42,6 +42,9 @@
- simdjson: 3.7.0 ==> 3.8.0
- flatbuffers: 2.0.8 ==> 24.3.25
- curl: 8.6.0 ==> 8.7.1
- luajit: 2.1-9cc2e42 ==> 2.1-d06beb0
- c-ares: 1.25.0 ==> 1.28.1
## axmol-2.1.2 Feb.25 2024

View File

@ -1,6 +1,6 @@
{
"versions": {
"1kdist": "v72",
"1kdist": "v80",
"oboe": "1.8.1",
"kcp": "v1.7-f2aa30e",
"lz4": "v1.9.4",