|
1 | | -################################ |
2 | | -# Set up 3rdparty dependencies # |
3 | | -################################ |
4 | | - |
5 | | -# Set the architecture information for ultralight |
6 | | -if (CMAKE_SIZEOF_VOID_P EQUAL 8) |
7 | | - set(ULTRALIGHT_ARCH "x64") |
8 | | -elseif (CMAKE_SIZEOF_VOID_P EQUAL 4) |
9 | | - set(ULTRALIGHT_ARCH "x86") |
10 | | -else () |
11 | | - message(FATAL_ERROR "Unsupported pointer size ${CMAKE_SIZEOF_VOID_P}") |
12 | | -endif () |
13 | | - |
14 | | -# Set the OS information for ultralight |
15 | | -if (WIN32) |
16 | | - set(ULTRALIGHT_OS_NAME "win") |
17 | | - set(ULTRALIGHT_LINK_DIRECTORY "lib") |
18 | | -elseif (APPLE) |
19 | | - set(ULTRALIGHT_OS_NAME "mac") |
20 | | - set(ULTRALIGHT_LINK_DIRECTORY "bin") |
21 | | -elseif (UNIX) |
22 | | - set(ULTRALIGHT_OS_NAME "linux") |
23 | | - set(ULTRALIGHT_LINK_DIRECTORY "bin") |
24 | | -else () |
25 | | - message(FATAL_ERROR "Unsupported operating system") |
26 | | -endif () |
27 | | - |
28 | | -# Ultralight |
29 | | -set(ULTRALIGHT_DIR "${CMAKE_CURRENT_BINARY_DIR}/ultralight-${ULTRALIGHT_OS_NAME}-${ULTRALIGHT_ARCH}") |
30 | | -set(ULTRALIGHT_ARCHIVE "${ULTRALIGHT_DIR}/ultralight.7z") |
31 | | -# 5011dbfee009074ca5883588fc164b5ba44bf165 |
32 | | -# Fix repaint bug on Windows (thanks for the report Dark Empath!) |
33 | | -# |
34 | | -# https://github.com/ultralight-ux/Ultralight/tree/5011dbfee009074ca5883588fc164b5ba44bf165 |
35 | | -set(ULTRALIGHT_VERSION "5011dbf") |
36 | | - |
37 | | -# Check the version of ultralight |
38 | | -set(ULTRALIGHT_VERSION_FILE "${ULTRALIGHT_DIR}/.version") |
39 | | -if (EXISTS "${ULTRALIGHT_VERSION_FILE}") |
40 | | - # The version file exists, read it |
41 | | - file(READ "${ULTRALIGHT_VERSION_FILE}" ULTRALIGHT_INSTALLED_VERSION) |
42 | | -endif () |
43 | | - |
44 | | -# Check if the installed version matches the target version |
45 | | -if (NOT "${ULTRALIGHT_VERSION}" STREQUAL "${ULTRALIGHT_INSTALLED_VERSION}") |
46 | | - # Versions do not match, erase the installed version |
47 | | - file(REMOVE_RECURSE "${ULTRALIGHT_DIR}") |
48 | | -endif () |
49 | | - |
50 | | -# Check if the ultralight directory exists |
51 | | -if (NOT EXISTS "${ULTRALIGHT_DIR}") |
52 | | - # It does not, download ultralight and extract it |
53 | | - file(DOWNLOAD |
54 | | - "https://ultralight-sdk.sfo2.cdn.digitaloceanspaces.com/ultralight-sdk-${ULTRALIGHT_VERSION}-${ULTRALIGHT_OS_NAME}-${ULTRALIGHT_ARCH}.7z" |
55 | | - "${ULTRALIGHT_ARCHIVE}" |
56 | | - SHOW_PROGRESS |
57 | | - STATUS ULTRALIGHT_DOWNLOAD_STATUS |
58 | | - LOG ULTRALIGHT_DOWNLOAD_LOG |
59 | | - ) |
60 | | - |
61 | | - # Extract the status from the download return value |
62 | | - list(GET ULTRALIGHT_DOWNLOAD_STATUS 0 ULTRALIGHT_DOWNLOAD_ERROR_CODE) |
63 | | - list(GET ULTRALIGHT_DOWNLOAD_STATUS 1 ULTRALIGHT_DOWNLOAD_ERROR_MESSAGE) |
64 | | - |
65 | | - # Check the download status |
66 | | - if(NOT ULTRALIGHT_DOWNLOAD_ERROR_CODE EQUAL 0) |
67 | | - # Download failed |
68 | | - message(SEND_ERROR "Failed to download Ultralight: ${ULTRALIGHT_DOWNLOAD_ERROR_MESSAGE}\n\n${ULTRALIGHT_DOWNLOAD_LOG}") |
69 | | - endif() |
70 | | - |
71 | | - # Extract it |
72 | | - execute_process( |
73 | | - COMMAND "${CMAKE_COMMAND}" -E tar xvf "${ULTRALIGHT_ARCHIVE}" |
74 | | - WORKING_DIRECTORY "${ULTRALIGHT_DIR}" |
75 | | - RESULT_VARIABLE EXTRACT_ERROR |
76 | | - ) |
77 | | - |
78 | | - if(EXTRACT_ERROR) |
79 | | - message(FATAL_ERROR "Failed to extract the ultralight zip archive") |
80 | | - endif() |
81 | | - |
82 | | - # Delete the archive file |
83 | | - file(REMOVE "${ULTRALIGHT_ARCHIVE}") |
84 | | - |
85 | | - # Write the version file |
86 | | - file(WRITE "${ULTRALIGHT_VERSION_FILE}" "${ULTRALIGHT_VERSION}") |
87 | | -endif () |
88 | | - |
89 | | -# Add the ultralight target |
90 | | -add_library(ultralight INTERFACE) |
91 | | -target_include_directories(ultralight INTERFACE "${ULTRALIGHT_DIR}/include") |
92 | | -target_link_directories(ultralight INTERFACE "${ULTRALIGHT_DIR}/${ULTRALIGHT_LINK_DIRECTORY}") |
93 | | -target_link_libraries(ultralight INTERFACE AppCore Ultralight UltralightCore WebCore) |
| 1 | +################################ |
| 2 | +# Set up 3rdparty dependencies # |
| 3 | +################################ |
| 4 | + |
| 5 | +# Set the architecture information for ultralight |
| 6 | +if (CMAKE_SIZEOF_VOID_P EQUAL 8) |
| 7 | + set(ULTRALIGHT_ARCH "x64") |
| 8 | +elseif (CMAKE_SIZEOF_VOID_P EQUAL 4) |
| 9 | + set(ULTRALIGHT_ARCH "x86") |
| 10 | +else () |
| 11 | + message(FATAL_ERROR "Unsupported pointer size ${CMAKE_SIZEOF_VOID_P}") |
| 12 | +endif () |
| 13 | + |
| 14 | +# Set the OS information for ultralight |
| 15 | +if (WIN32) |
| 16 | + set(ULTRALIGHT_OS_NAME "win") |
| 17 | + set(ULTRALIGHT_LINK_DIRECTORY "lib") |
| 18 | +elseif (APPLE) |
| 19 | + set(ULTRALIGHT_OS_NAME "mac") |
| 20 | + set(ULTRALIGHT_LINK_DIRECTORY "bin") |
| 21 | +elseif (UNIX) |
| 22 | + set(ULTRALIGHT_OS_NAME "linux") |
| 23 | + set(ULTRALIGHT_LINK_DIRECTORY "bin") |
| 24 | +else () |
| 25 | + message(FATAL_ERROR "Unsupported operating system") |
| 26 | +endif () |
| 27 | + |
| 28 | +# Ultralight |
| 29 | +set(ULTRALIGHT_DIR "${CMAKE_CURRENT_BINARY_DIR}/ultralight-${ULTRALIGHT_OS_NAME}-${ULTRALIGHT_ARCH}") |
| 30 | +set(ULTRALIGHT_ARCHIVE "${ULTRALIGHT_DIR}/ultralight.7z") |
| 31 | +# 5011dbfee009074ca5883588fc164b5ba44bf165 |
| 32 | +# Fix repaint bug on Windows (thanks for the report Dark Empath!) |
| 33 | +# |
| 34 | +# https://github.com/ultralight-ux/Ultralight/tree/5011dbfee009074ca5883588fc164b5ba44bf165 |
| 35 | +set(ULTRALIGHT_VERSION "5011dbf") |
| 36 | + |
| 37 | +# Check the version of ultralight |
| 38 | +set(ULTRALIGHT_VERSION_FILE "${ULTRALIGHT_DIR}/.version") |
| 39 | +if (EXISTS "${ULTRALIGHT_VERSION_FILE}") |
| 40 | + # The version file exists, read it |
| 41 | + file(READ "${ULTRALIGHT_VERSION_FILE}" ULTRALIGHT_INSTALLED_VERSION) |
| 42 | +endif () |
| 43 | + |
| 44 | +# Check if the installed version matches the target version |
| 45 | +if (NOT "${ULTRALIGHT_VERSION}" STREQUAL "${ULTRALIGHT_INSTALLED_VERSION}") |
| 46 | + # Versions do not match, erase the installed version |
| 47 | + file(REMOVE_RECURSE "${ULTRALIGHT_DIR}") |
| 48 | +endif () |
| 49 | + |
| 50 | +# Check if the ultralight directory exists |
| 51 | +if (NOT EXISTS "${ULTRALIGHT_DIR}") |
| 52 | + # It does not, download ultralight and extract it |
| 53 | + file(DOWNLOAD |
| 54 | + "https://ultralight-sdk.sfo2.cdn.digitaloceanspaces.com/ultralight-sdk-${ULTRALIGHT_VERSION}-${ULTRALIGHT_OS_NAME}-${ULTRALIGHT_ARCH}.7z" |
| 55 | + "${ULTRALIGHT_ARCHIVE}" |
| 56 | + SHOW_PROGRESS |
| 57 | + STATUS ULTRALIGHT_DOWNLOAD_STATUS |
| 58 | + LOG ULTRALIGHT_DOWNLOAD_LOG |
| 59 | + ) |
| 60 | + |
| 61 | + # Extract the status from the download return value |
| 62 | + list(GET ULTRALIGHT_DOWNLOAD_STATUS 0 ULTRALIGHT_DOWNLOAD_ERROR_CODE) |
| 63 | + list(GET ULTRALIGHT_DOWNLOAD_STATUS 1 ULTRALIGHT_DOWNLOAD_ERROR_MESSAGE) |
| 64 | + |
| 65 | + # Check the download status |
| 66 | + if(NOT ULTRALIGHT_DOWNLOAD_ERROR_CODE EQUAL 0) |
| 67 | + # Download failed |
| 68 | + message(SEND_ERROR "Failed to download Ultralight: ${ULTRALIGHT_DOWNLOAD_ERROR_MESSAGE}\n\n${ULTRALIGHT_DOWNLOAD_LOG}") |
| 69 | + endif() |
| 70 | + |
| 71 | + # Extract it |
| 72 | + execute_process( |
| 73 | + COMMAND "${CMAKE_COMMAND}" -E tar xvf "${ULTRALIGHT_ARCHIVE}" |
| 74 | + WORKING_DIRECTORY "${ULTRALIGHT_DIR}" |
| 75 | + RESULT_VARIABLE EXTRACT_ERROR |
| 76 | + ) |
| 77 | + |
| 78 | + if(EXTRACT_ERROR) |
| 79 | + message(FATAL_ERROR "Failed to extract the ultralight zip archive") |
| 80 | + endif() |
| 81 | + |
| 82 | + # Delete the archive file |
| 83 | + file(REMOVE "${ULTRALIGHT_ARCHIVE}") |
| 84 | + |
| 85 | + # Write the version file |
| 86 | + file(WRITE "${ULTRALIGHT_VERSION_FILE}" "${ULTRALIGHT_VERSION}") |
| 87 | +endif () |
| 88 | + |
| 89 | +# Add the ultralight target |
| 90 | +add_library(ultralight INTERFACE) |
| 91 | +target_include_directories(ultralight INTERFACE "${ULTRALIGHT_DIR}/include") |
| 92 | +target_link_directories(ultralight INTERFACE "${ULTRALIGHT_DIR}/${ULTRALIGHT_LINK_DIRECTORY}") |
| 93 | +target_link_libraries(ultralight INTERFACE AppCore Ultralight UltralightCore WebCore) |
0 commit comments