forked from MaaAssistantArknights/MaaDeps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
maadeps.cmake
61 lines (52 loc) · 2.34 KB
/
maadeps.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
function(detect_maadeps_triplet outvar)
string(TOLOWER "${CMAKE_SYSTEM_NAME}" maadeps_triplet_system)
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" maadeps_triplet_arch)
if(maadeps_triplet_system STREQUAL "darwin")
set(maadeps_triplet_system "osx")
list(LENGTH CMAKE_OSX_ARCHITECTURES osx_archcount)
if(osx_archcount GREATER 1)
message(FATAL_ERROR "More than one CMAKE_OSX_ARCHITECTURES is not supported")
elseif(osx_archcount EQUAL 0)
message("No CMAKE_OSX_ARCHITECTURES given, default to ${maadeps_triplet_arch}")
else()
set(maadeps_triplet_arch "${CMAKE_OSX_ARCHITECTURES}")
endif()
endif()
message("maadeps_triplet_system: ${maadeps_triplet_system}")
message("maadeps_triplet_arch: ${maadeps_triplet_arch}")
if(maadeps_triplet_arch MATCHES "(amd64|x86_64)")
set(maadeps_triplet_arch "x64")
elseif(maadeps_triplet_arch MATCHES "i[3456]86")
set(maadeps_triplet_arch "x86")
elseif(maadeps_triplet_arch MATCHES "(aarch64|armv8l|arm64)")
set(maadeps_triplet_arch "arm64")
else()
message(FATAL_ERROR "Unrecognized CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
endif()
set(${outvar} "maa-${maadeps_triplet_arch}-${maadeps_triplet_system}" PARENT_SCOPE)
endfunction()
if(NOT DEFINED MAADEPS_TRIPLET)
detect_maadeps_triplet(MAADEPS_TRIPLET)
set(MAADEPS_TRIPLET "${MAADEPS_TRIPLET}" CACHE STRING "")
message(STATUS "Use autodetected MAADEPS_TRIPLET: ${MAADEPS_TRIPLET}, override it if not correct.")
endif()
if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/vcpkg/installed/${MAADEPS_TRIPLET}")
message(FATAL_ERROR
" "
" Dependencies not found for ${MAADEPS_TRIPLET}\n"
" run maadeps-download.py to download prebuilt binaries\n"
" or maadeps-build.py to build from source\n"
)
endif()
if(CMAKE_CROSSCOMPILING)
list(PREPEND CMAKE_FIND_ROOT_PATH "${CMAKE_CURRENT_LIST_DIR}/vcpkg/installed/${MAADEPS_TRIPLET}")
else()
list(PREPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}/vcpkg/installed/${MAADEPS_TRIPLET}")
endif()
function(maadeps_install dest)
if(MSVC)
install(DIRECTORY "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/runtime/${MAADEPS_TRIPLET}/$<$<CONFIG:Debug>:msvc-debug/>" DESTINATION ${dest} USE_SOURCE_PERMISSIONS)
else()
install(DIRECTORY "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/runtime/${MAADEPS_TRIPLET}/" DESTINATION ${dest} USE_SOURCE_PERMISSIONS)
endif()
endfunction()