jsoncpp: add meson build system, update package, update cmake ~ownlibs (#39639)

This commit is contained in:
Harmen Stoppels 2023-09-25 10:13:30 +02:00 committed by GitHub
parent 3d2c779b87
commit 65ffd0dd63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 23 deletions

View File

@ -238,6 +238,7 @@ class Cmake(Package):
depends_on("libuv@1.10.0:1.10", when="@3.11.0:3.11") depends_on("libuv@1.10.0:1.10", when="@3.11.0:3.11")
depends_on("libuv@1.10.0:", when="@3.12.0:") depends_on("libuv@1.10.0:", when="@3.12.0:")
depends_on("rhash", when="@3.8.0:") depends_on("rhash", when="@3.8.0:")
depends_on("jsoncpp", when="@3.2:")
depends_on("ncurses", when="+ncurses") depends_on("ncurses", when="+ncurses")
@ -354,12 +355,8 @@ def bootstrap_args(self):
# Build and link to the Spack-installed third-party libraries # Build and link to the Spack-installed third-party libraries
args.append("--system-libs") args.append("--system-libs")
if spec.satisfies("@3.2:"): # cppdap is a CMake package, avoid circular dependency
# jsoncpp requires CMake to build
# use CMake-provided library to avoid circular dependency
args.append("--no-system-jsoncpp")
if spec.satisfies("@3.27:"): if spec.satisfies("@3.27:"):
# cppdap depends on jsoncpp in CMake.
args.append("--no-system-cppdap") args.append("--no-system-cppdap")
# Whatever +/~ownlibs, use system curl. # Whatever +/~ownlibs, use system curl.

View File

@ -6,7 +6,7 @@
from spack.package import * from spack.package import *
class Jsoncpp(CMakePackage): class Jsoncpp(CMakePackage, MesonPackage):
"""JsonCpp is a C++ library that allows manipulating JSON values, """JsonCpp is a C++ library that allows manipulating JSON values,
including serialization and deserialization to and from strings. including serialization and deserialization to and from strings.
It can also preserve existing comment in unserialization/serialization It can also preserve existing comment in unserialization/serialization
@ -33,22 +33,25 @@ class Jsoncpp(CMakePackage):
version("1.7.4", sha256="10dcd0677e80727e572a1e462193e51a5fde3e023b99e144b2ee1a469835f769") version("1.7.4", sha256="10dcd0677e80727e572a1e462193e51a5fde3e023b99e144b2ee1a469835f769")
version("1.7.3", sha256="1cfcad14054039ba97c22531888796cb9369e6353f257aacaad34fda956ada53") version("1.7.3", sha256="1cfcad14054039ba97c22531888796cb9369e6353f257aacaad34fda956ada53")
variant( # From 1.9.3 onwards CMAKE_CXX_STANDARD is finally set to 11.
"build_type",
default="RelWithDebInfo",
description="The build type to build",
values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel", "Coverage"),
)
variant( variant(
"cxxstd", "cxxstd",
default="default", default="default",
values=("default", "98", "11", "14", "17"), values=("default", conditional("98", when="@:1.8"), "11", "14", "17"),
multi=False, multi=False,
description="Use the specified C++ standard when building.", description="Use the specified C++ standard when building.",
when="@:1.9.2 build_system=cmake",
) )
depends_on("cmake@3.1:", type="build") build_system("cmake", conditional("meson", when="@1.9.2:"), default="cmake")
with when("build_system=cmake"):
depends_on("cmake@3.1:", type="build")
depends_on("cmake@1.9:", when="@1.9:", type="build")
with when("build_system=meson"):
depends_on("meson@0.49.0:", type="build")
depends_on("python", type="test") depends_on("python", type="test")
# Ref: https://github.com/open-source-parsers/jsoncpp/pull/1023 # Ref: https://github.com/open-source-parsers/jsoncpp/pull/1023
@ -62,13 +65,20 @@ def patch(self):
"src/lib_json/json_value.cpp", "src/lib_json/json_value.cpp",
) )
class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder):
def cmake_args(self): def cmake_args(self):
args = ["-DBUILD_SHARED_LIBS=ON"] args = [
cxxstd = self.spec.variants["cxxstd"].value self.define("BUILD_SHARED_LIBS", True),
if cxxstd != "default": self.define("JSONCPP_WITH_TESTS", self.pkg.run_tests),
args.append("-DCMAKE_CXX_STANDARD={0}".format(cxxstd)) ]
if self.run_tests: if "cxxstd" in self.spec.variants:
args.append("-DJSONCPP_WITH_TESTS=ON") cxxstd = self.spec.variants["cxxstd"].value
else: if cxxstd != "default":
args.append("-DJSONCPP_WITH_TESTS=OFF") args.append(self.define("CMAKE_CXX_STANDARD", cxxstd))
return args return args
class MesonBuilder(spack.build_systems.meson.MesonBuilder):
def meson_args(self):
return ["-Dtests={}".format("true" if self.pkg.run_tests else "false")]