فهرست منبع

boost: fix container lib with emscripten (#7874)

star9029 1 ماه پیش
والد
کامیت
a7d9296ed3
1فایلهای تغییر یافته به همراه20 افزوده شده و 0 حذف شده
  1. 20 0
      packages/b/boost/cmake/install.lua

+ 20 - 0
packages/b/boost/cmake/install.lua

@@ -109,9 +109,29 @@ function _add_opt(package, opt)
     end
 end
 
+function _patch()
+    -- https://github.com/microsoft/vcpkg/pull/38806
+    local file = io.open("libs/container/CMakeLists.txt", "a")
+    file:write([[
+        if(NOT WIN32)
+            set(THREADS_PREFER_PTHREAD_FLAG 1)
+            find_package(Threads REQUIRED)
+            target_link_libraries(boost_container PUBLIC Threads::Threads)
+            if(EMSCRIPTEN)
+                # Boost config needs `-pthread` to see `_POSIX_THREADS`,
+                # but FindTheads.cmake finishes with `CMAKE_HAVE_LIBC_PTHREAD`.
+                target_compile_options(boost_container PUBLIC -pthread)
+            endif()
+        endif()
+    ]])
+    file:close()
+end
+
 function main(package)
     import("libs", {rootdir = package:scriptdir()})
 
+    _patch()
+
     local configs = {"-DBOOST_INSTALL_LAYOUT=system"}
     table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
     table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))