From 48cb3ac4104c5d3fa60c675a58755248e8ea76cb Mon Sep 17 00:00:00 2001 From: aabajyan Date: Tue, 19 Mar 2024 23:46:32 +0400 Subject: [PATCH] Do not link to pthread when targeting Android I had issues compiling this for Android, and as it turns out, pthread functionality is part of Bionic itself and linking is not required. --- .github/workflows/ci.yml | 2 +- CMakeLists.txt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c7f2e7d..2812fce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -543,7 +543,7 @@ jobs: run: | mkdir build cd build - $ANDROID_HOME/cmake/3.22.1/bin/cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_HOME/ndk/26.0.10792818/build/cmake/android.toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI="arm64-v8a" -DANDROID_PLATFORM=android-24 .. + $ANDROID_HOME/cmake/3.22.1/bin/cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_HOME/ndk/26.0.10792818/build/cmake/android.toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI="arm64-v8a" -DANDROID_PLATFORM=android-24 -DBUILD_QJS_LIBC=ON .. - name: Build android arm64 run: | $ANDROID_HOME/cmake/3.22.1/bin/cmake --build build --target qjs diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a37825..f2eb540 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,7 +155,8 @@ endif() list(APPEND qjs_defines _GNU_SOURCE) list(APPEND qjs_libs qjs ${CMAKE_DL_LIBS}) if(NOT MSVC) - list(APPEND qjs_libs m pthread) + find_package(Threads) + list(APPEND qjs_libs ${CMAKE_THREAD_LIBS_INIT} m) endif() add_library(qjs ${qjs_sources})