summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarmen Stoppels <harmenstoppels@gmail.com>2023-09-25 10:13:30 +0200
committerGitHub <noreply@github.com>2023-09-25 10:13:30 +0200
commit65ffd0dd637d6f994a6b8cd8e011e48d573056ca (patch)
tree74addadaee1c1c9d89746c63f9efd36fc7c696d2
parent3d2c779b87886ba1e2b8d1bb7d7f58616fcb1f83 (diff)
downloadspack-65ffd0dd637d6f994a6b8cd8e011e48d573056ca.tar.gz
spack-65ffd0dd637d6f994a6b8cd8e011e48d573056ca.tar.bz2
spack-65ffd0dd637d6f994a6b8cd8e011e48d573056ca.tar.xz
spack-65ffd0dd637d6f994a6b8cd8e011e48d573056ca.zip
jsoncpp: add meson build system, update package, update cmake ~ownlibs (#39639)
-rw-r--r--var/spack/repos/builtin/packages/cmake/package.py7
-rw-r--r--var/spack/repos/builtin/packages/jsoncpp/package.py46
2 files changed, 30 insertions, 23 deletions
diff --git a/var/spack/repos/builtin/packages/cmake/package.py b/var/spack/repos/builtin/packages/cmake/package.py
index a9135ad13b..9f0dfe86a5 100644
--- a/var/spack/repos/builtin/packages/cmake/package.py
+++ b/var/spack/repos/builtin/packages/cmake/package.py
@@ -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:", when="@3.12.0:")
depends_on("rhash", when="@3.8.0:")
+ depends_on("jsoncpp", when="@3.2:")
depends_on("ncurses", when="+ncurses")
@@ -354,12 +355,8 @@ class Cmake(Package):
# Build and link to the Spack-installed third-party libraries
args.append("--system-libs")
- if spec.satisfies("@3.2:"):
- # jsoncpp requires CMake to build
- # use CMake-provided library to avoid circular dependency
- args.append("--no-system-jsoncpp")
+ # cppdap is a CMake package, avoid circular dependency
if spec.satisfies("@3.27:"):
- # cppdap depends on jsoncpp in CMake.
args.append("--no-system-cppdap")
# Whatever +/~ownlibs, use system curl.
diff --git a/var/spack/repos/builtin/packages/jsoncpp/package.py b/var/spack/repos/builtin/packages/jsoncpp/package.py
index b5eff5150d..55c2f22a02 100644
--- a/var/spack/repos/builtin/packages/jsoncpp/package.py
+++ b/var/spack/repos/builtin/packages/jsoncpp/package.py
@@ -6,7 +6,7 @@
from spack.package import *
-class Jsoncpp(CMakePackage):
+class Jsoncpp(CMakePackage, MesonPackage):
"""JsonCpp is a C++ library that allows manipulating JSON values,
including serialization and deserialization to and from strings.
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.3", sha256="1cfcad14054039ba97c22531888796cb9369e6353f257aacaad34fda956ada53")
- variant(
- "build_type",
- default="RelWithDebInfo",
- description="The build type to build",
- values=("Debug", "Release", "RelWithDebInfo", "MinSizeRel", "Coverage"),
- )
-
+ # From 1.9.3 onwards CMAKE_CXX_STANDARD is finally set to 11.
variant(
"cxxstd",
default="default",
- values=("default", "98", "11", "14", "17"),
+ values=("default", conditional("98", when="@:1.8"), "11", "14", "17"),
multi=False,
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")
# Ref: https://github.com/open-source-parsers/jsoncpp/pull/1023
@@ -62,13 +65,20 @@ class Jsoncpp(CMakePackage):
"src/lib_json/json_value.cpp",
)
+
+class CMakeBuilder(spack.build_systems.cmake.CMakeBuilder):
def cmake_args(self):
- args = ["-DBUILD_SHARED_LIBS=ON"]
- cxxstd = self.spec.variants["cxxstd"].value
- if cxxstd != "default":
- args.append("-DCMAKE_CXX_STANDARD={0}".format(cxxstd))
- if self.run_tests:
- args.append("-DJSONCPP_WITH_TESTS=ON")
- else:
- args.append("-DJSONCPP_WITH_TESTS=OFF")
+ args = [
+ self.define("BUILD_SHARED_LIBS", True),
+ self.define("JSONCPP_WITH_TESTS", self.pkg.run_tests),
+ ]
+ if "cxxstd" in self.spec.variants:
+ cxxstd = self.spec.variants["cxxstd"].value
+ if cxxstd != "default":
+ args.append(self.define("CMAKE_CXX_STANDARD", cxxstd))
return args
+
+
+class MesonBuilder(spack.build_systems.meson.MesonBuilder):
+ def meson_args(self):
+ return ["-Dtests={}".format("true" if self.pkg.run_tests else "false")]