Skip to content

Commit

Permalink
add jthread repo (#5236)
Browse files Browse the repository at this point in the history
* add jthread repo

* change the version and patch name

* change pathc and test way

* change patch and test way

* Revert "change pathc and test way"

This reverts commit 8ab9284.

* change patch and test way

* change patch  for share or static build

* change patch
  • Loading branch information
hahahahbenny authored Sep 15, 2024
1 parent ce48c8c commit d5382a3
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/j/jthread/patches/2023.08.18/cmakelist.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 517e13f..2a6427a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -35,7 +35,7 @@ else ()
set(JTHREAD_COMPILE_STATIC ON CACHE BOOL "Flag indicating if a static library should be built, or a dynamic one")
endif ()

-if (NOT MSVC OR JTHREAD_COMPILE_STATIC)
+if (JTHREAD_COMPILE_STATIC)
set(JTHREAD_INSTALLTARGETS jthread-static)
add_library(jthread-static STATIC ${SOURCES} ${HEADERS})
set_target_properties(jthread-static PROPERTIES OUTPUT_NAME jthread)
@@ -43,7 +43,7 @@ if (NOT MSVC OR JTHREAD_COMPILE_STATIC)
target_link_libraries(jthread-static ${CMAKE_THREAD_LIBS_INIT})
endif()

-if ((NOT MSVC AND NOT JTHREAD_COMPILE_STATIC_ONLY) OR (MSVC AND NOT JTHREAD_COMPILE_STATIC))
+if (NOT JTHREAD_COMPILE_STATIC)
add_library(jthread-shared SHARED ${SOURCES} ${HEADERS})
set_target_properties(jthread-shared PROPERTIES VERSION ${VERSION})
set_target_properties(jthread-shared PROPERTIES OUTPUT_NAME jthread)
27 changes: 27 additions & 0 deletions packages/j/jthread/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package("jthread")
set_homepage("https://github.com/j0r1/JThread")
set_description("The JThread package provides some classes to make use of threads easy on different platforms")
set_license("MIT")

add_urls("https://github.com/j0r1/JThread.git")

add_versions("2023.08.18", "719413043807b77448df3ba1c749798fb72ee459")
add_deps("cmake")

add_patches("2023.08.18", "patches/2023.08.18/cmakelist.patch", "62304c64bf7a84ce7d3f95042d2307b4306d934e00cc033837610d9cef8401d5")

add_includedirs("include", "include/jthread")

on_install("windows", "linux", "macosx", function(package)
local configs = {}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
table.insert(configs, "-DJTHREAD_COMPILE_STATIC=" .. (package:config("shared") and "OFF" or "ON"))
import("package.tools.cmake").install(package, configs)
end)

on_test(function (package)
assert(package:check_cxxsnippets({test = [[
using namespace jthread;
JMutex* test = new JMutex();
]]}, {configs = {languages = "c++11"}, includes = "jthread.h"}))
end)

0 comments on commit d5382a3

Please sign in to comment.