Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msgpack-cxx: make headeronly and boost optional #4648

Merged
merged 16 commits into from
Jul 14, 2024
Merged
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 30 additions & 11 deletions packages/m/msgpack-cxx/xmake.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package("msgpack-cxx")

set_kind("library", {headeronly = true})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should set it dynamicaly in on_load. use package:config("header_only")

Copy link
Contributor Author

@Chi-EEE Chi-EEE Jul 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setting it dynamically in on_load would not work as the cmake file does not generate a .lib file if it is not linked with boost, it only generates a lib file when linking with boost

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package:config("header_only") should be consistent with the state of set_kind("library", {headeronly = true}), otherwise there is no point in adding header_only config.

If the library is always headeronly, we shouldn't add add_configs("header_only")

set_homepage("https://msgpack.org/")
set_description("MessagePack implementation for C++")
set_license("BSL-1.0")
Expand All @@ -9,20 +9,39 @@ package("msgpack-cxx")
add_versions("6.1.0", "23ede7e93c8efee343ad8c6514c28f3708207e5106af3b3e4969b3a9ed7039e7")
add_versions("4.1.1", "8115c5edcf20bc1408c798a6bdaec16c1e52b1c34859d4982a0fb03300438f0b")

add_configs("header_only", {description = "Use header only version.", default = false, type = "boolean"})
Chi-EEE marked this conversation as resolved.
Show resolved Hide resolved
add_configs("std", {description = "Choose C++ standard version.", default = "cxx17", type = "string", values = {"cxx98", "cxx11", "cxx14", "cxx17", "cxx20"}})
add_configs("boost", {description = "Use Boost", default = is_plat("macosx", "linux", "windows", "bsd", "mingw", "cross"), type = "boolean"})

add_deps("cmake", "boost")
on_install("windows", "macosx", "linux", "mingw", function (package)
local configs = {"-DMSGPACK_BUILD_EXAMPLES=OFF", "-DMSGPACK_BUILD_TESTS=OFF", "-DMSGPACK_BUILD_DOCS=OFF", "-DMSGPACK_USE_STATIC_BOOST=ON"}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
if package:config("std") ~= "cxx98" then
table.insert(configs, "-DMSGPACK_" .. package:config("std"):upper() .. "=ON")
on_load(function (package)
if not package:config("header_only") then
package:add("deps", "cmake")
end
if package:config("boost") then
package:add("deps", "boost")
else
package:add("defines", "MSGPACK_NO_BOOST")
end
if package:is_plat("windows") then
table.insert(configs, "-DBoost_USE_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
end)

on_install(function (package)
if package:config("header_only") then
os.cp("include", package:installdir())
else
local configs = {"-DMSGPACK_BUILD_EXAMPLES=OFF", "-DMSGPACK_BUILD_TESTS=OFF", "-DMSGPACK_BUILD_DOCS=OFF"}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
if package:config("std") ~= "cxx98" then
table.insert(configs, "-DMSGPACK_" .. package:config("std"):upper() .. "=ON")
end
if package:config("boost") then
table.insert(configs, "-DMSGPACK_USE_STATIC_BOOST=ON")
table.insert(configs, "-DMSGPACK_USE_BOOST=ON")
else
table.insert(configs, "-DMSGPACK_USE_BOOST=OFF")
end
import("package.tools.cmake").install(package, configs)
end
import("package.tools.cmake").install(package, configs)
end)

on_test(function (package)
Expand Down
Loading