remove `#!/usr/bin/env sh`
[liba.git] / quickjs / quickjs.cmake
blob5430874ab6a8ddda3817d7ecadbbb0d078e0de6b
1 set(QUICKJS_VERSION 2024-01-13)
2 set(QUICKJS_SOURCE_DIR ${CMAKE_BINARY_DIR}/quickjs-${QUICKJS_VERSION})
3 set(QUICKJS_BINARY_DIR ${CMAKE_BINARY_DIR}/quickjs-${QUICKJS_VERSION})
4 set(QUICKJS_ARCHIVE_URL https://bellard.org/quickjs/quickjs-${QUICKJS_VERSION}.tar.xz)
5 set(QUICKJS_ARCHIVE_HASH 3c4bf8f895bfa54beb486c8d1218112771ecfc5ac3be1036851ef41568212e03)
6 if(CMAKE_HOST_WIN32)
7   file(TO_CMAKE_PATH $ENV{USERPROFILE}/.cache/quickjs-${QUICKJS_VERSION}.tar.xz QUICKJS_ARCHIVE_TXZ)
8 else()
9   file(TO_CMAKE_PATH $ENV{HOME}/.cache/quickjs-${QUICKJS_VERSION}.tar.xz QUICKJS_ARCHIVE_TXZ)
10 endif()
11 if(NOT EXISTS ${QUICKJS_SOURCE_DIR}/quickjs.h)
12   file(DOWNLOAD ${QUICKJS_ARCHIVE_URL} ${QUICKJS_ARCHIVE_TXZ} EXPECTED_HASH SHA256=${QUICKJS_ARCHIVE_HASH} SHOW_PROGRESS)
13   execute_process(WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E tar xf ${QUICKJS_ARCHIVE_TXZ})
14   find_package(Patch)
15   if(Patch_FOUND)
16     file(GLOB QUICKJS_PATCH *.patch)
17     foreach(patch ${QUICKJS_PATCH})
18       execute_process(WORKING_DIRECTORY ${QUICKJS_SOURCE_DIR}
19         COMMAND ${Patch_EXECUTABLE} -p1 -i ${patch}
20       )
21     endforeach()
22   endif()
23 endif()
24 file(COPY src/CMakeLists.txt DESTINATION ${QUICKJS_SOURCE_DIR})