c4core: add package (#4405)

pull/4407/head
star9029 5 months ago committed by GitHub
parent 886959c389
commit 1598d93a9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 29
      packages/c/c4core/patches/0.2.1/cmake-deps.patch
  2. 56
      packages/c/c4core/xmake.lua

@ -0,0 +1,29 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ea146a8..31373e5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -69,14 +69,12 @@ set(C4CORE_SRC_FILES
c4/windows_push.hpp
c4/c4core.natvis
#
- c4/ext/debugbreak/debugbreak.h
c4/ext/rng/rng.hpp
c4/ext/sg14/inplace_function.h
)
if(C4CORE_WITH_FASTFLOAT)
list(APPEND C4CORE_SRC_FILES
c4/ext/fast_float.hpp
- c4/ext/fast_float_all.h
)
endif()
set(C4CORE_AMALGAMATED ${C4CORE_SRC_DIR}/../src_singleheader/c4/c4core_all.hpp)
@@ -97,6 +95,9 @@ c4_add_library(c4core
)
if(NOT C4CORE_WITH_FASTFLOAT)
target_compile_definitions(c4core PUBLIC -DC4CORE_NO_FAST_FLOAT)
+else()
+ find_package(FastFloat REQUIRED CONFIG)
+ target_link_libraries(c4core PUBLIC "FastFloat::fast_float")
endif()
if(C4CORE_NO_DEBUG_BREAK)
target_compile_definitions(c4core PUBLIC -DC4_NO_DEBUG_BREAK)

@ -0,0 +1,56 @@
package("c4core")
set_homepage("https://github.com/biojppm/c4core")
set_description("C++ utilities")
set_license("MIT")
add_urls("https://github.com/biojppm/c4core/releases/download/v$(version)/c4core-$(version)-src.zip",
"https://github.com/biojppm/c4core.git")
add_versions("0.2.1", "81ff1c0d15e24da6d76fdd1b6fdd903fa23d0df7c82e564f993147a4dac88773")
add_configs("fast_float", {description = "use fastfloat to parse floats", default = false, type = "boolean"})
add_configs("debugbreak", {description = "use debug break in debug builds", default = false, type = "boolean"})
add_deps("cmake")
on_load(function (package)
if package:config("fast_float") then
package:add("deps", "fast_float")
else
package:add("defines", "C4CORE_NO_FAST_FLOAT")
end
if package:config("debugbreak") then
package:add("deps", "debugbreak")
else
package:add("defines", "C4_NO_DEBUG_BREAK")
end
if package:config("fast_float") or package:config("debugbreak") then
package:add("patches", "0.2.1", "patches/0.2.1/cmake-deps.patch", "92c0c6510cc3b8cbd10b575b5b9d0defa2a19d19f24c1618a73d4f4636da4c9b")
end
end)
on_install(function (package)
if package:config("fast_float") then
io.replace("src/c4/ext/fast_float.hpp", "c4/ext/fast_float_all.h", "fast_float/fast_float.h", {plain = true})
end
if package:config("debugbreak") then
io.replace("src/c4/error.hpp", "c4/ext/debugbreak/debugbreak.h", "debugbreak.h", {plain = true})
end
local configs = {}
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"))
table.insert(configs, "-DC4CORE_WITH_FASTFLOAT=" .. (package:config("fast_float") and "ON" or "OFF"))
table.insert(configs, "-DC4CORE_NO_DEBUG_BREAK=" .. (package:config("debugbreak") and "OFF" or "ON"))
import("package.tools.cmake").install(package, configs, {packagedeps = "debugbreak"})
end)
on_test(function (package)
assert(package:check_cxxsnippets({test = [[
void test() {
double value;
c4::from_chars("52.4354", &value);
}
]]}, {configs = {languages = "c++11"}, includes = "c4/charconv.hpp"}))
end)
Loading…
Cancel
Save