forked from scream3r/java-simple-serial-connector
-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathMingwAarch64.cmake
More file actions
37 lines (33 loc) · 1.69 KB
/
Copy pathMingwAarch64.cmake
File metadata and controls
37 lines (33 loc) · 1.69 KB
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
set(CMAKE_SYSTEM_NAME Windows)
# URL for llvm-mingw
set(URL "https://github.com/mstorsjo/llvm-mingw/releases/download/20201020/llvm-mingw-20201020-msvcrt-ubuntu-18.04.tar.xz")
set(SHA256 "96e94e469665ee5632fff32a19b589ae1698859189d85615f3062b1544510b75")
get_filename_component(ARCHIVE_NAME "${URL}" NAME)
set(ARCHIVE "${CMAKE_BINARY_DIR}/llvm-mingw/${ARCHIVE_NAME}")
# Try to predict the subdirectory name from the file name
string(REPLACE ".tar.xz" "" SUBDIR "${ARCHIVE_NAME}")
# Prevent extract process from running more than once
if(NOT TOOLCHAIN_LOCATION)
if(NOT EXISTS "${CMAKE_BINARY_DIR}/llvm-mingw/${SUBDIR}")
if(NOT EXISTS "${ARCHIVE}")
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/llvm-mingw")
message(STATUS "Downloading ${URL} to ${ARCHIVE}...")
file(DOWNLOAD ${URL} ${ARCHIVE} TIMEOUT 60 EXPECTED_HASH SHA256=${SHA256})
endif()
message(STATUS "Extracting ${ARCHIVE} to ${CMAKE_BINARY_DIR}/llvm-mingw/${SUBDIR}/...")
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.18.0")
file(ARCHIVE_EXTRACT INPUT "${ARCHIVE}" DESTINATION "${CMAKE_BINARY_DIR}/llvm-mingw")
else()
execute_process(COMMAND tar xf "${ARCHIVE}" -C "${CMAKE_BINARY_DIR}/llvm-mingw")
endif()
endif()
endif()
set(TOOLCHAIN_LOCATION "${CMAKE_BINARY_DIR}/llvm-mingw/${SUBDIR}/bin")
set(TOOLCHAIN_PREFIX "${TOOLCHAIN_LOCATION}/aarch64-w64-mingw32")
set(CMAKE_C_COMPILER "${TOOLCHAIN_PREFIX}-gcc")
set(CMAKE_CXX_COMPILER "${TOOLCHAIN_PREFIX}-g++")
set(CMAKE_RC_COMPILER "${TOOLCHAIN_PREFIX}-windres")
set(CMAKE_STRIP "${TOOLCHAIN_PREFIX}-strip" CACHE FILEPATH "" FORCE)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)