Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions cmake/CMakeCargo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function(cargo_build)
else()
set(LIB_TARGET "i686-pc-windows-msvc")
endif()
elseif(ANDROID)
elseif(ANDROID)
if(ANDROID_SYSROOT_ABI STREQUAL "x86")
set(LIB_TARGET "i686-linux-android")
elseif(ANDROID_SYSROOT_ABI STREQUAL "x86_64")
Expand All @@ -21,11 +21,17 @@ function(cargo_build)
set(LIB_TARGET "aarch64-linux-android")
endif()
elseif(IOS)
set(LIB_TARGET "universal")
set(LIB_TARGET "universal")
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(LIB_TARGET "x86_64-apple-darwin")
else()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL arm64)
set(LIB_TARGET "aarch64-apple-darwin")
else()
set(LIB_TARGET "x86_64-apple-darwin")
endif()
else()
if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL aarch64)
set(LIB_TARGET "aarch64-unknown-linux-gnu")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(LIB_TARGET "x86_64-unknown-linux-gnu")
else()
set(LIB_TARGET "i686-unknown-linux-gnu")
Expand All @@ -42,12 +48,12 @@ function(cargo_build)

set(LIB_FILE "${CARGO_TARGET_DIR}/${LIB_TARGET}/${LIB_BUILD_TYPE}/${CMAKE_STATIC_LIBRARY_PREFIX}${LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}")

if(IOS)
set(CARGO_ARGS "lipo")
else()
set(CARGO_ARGS "build")
list(APPEND CARGO_ARGS "--target" ${LIB_TARGET})
endif()
if(IOS)
set(CARGO_ARGS "lipo")
else()
set(CARGO_ARGS "build")
list(APPEND CARGO_ARGS "--target" ${LIB_TARGET})
endif()

if(${LIB_BUILD_TYPE} STREQUAL "release")
list(APPEND CARGO_ARGS "--release")
Expand All @@ -67,4 +73,4 @@ function(cargo_build)
add_library(${CARGO_NAME} STATIC IMPORTED GLOBAL)
add_dependencies(${CARGO_NAME} ${CARGO_NAME}_target)
set_target_properties(${CARGO_NAME} PROPERTIES IMPORTED_LOCATION ${LIB_FILE})
endfunction()
endfunction()