From 0f25d3b2192dd325c78c07cfd03bbdb114f15a00 Mon Sep 17 00:00:00 2001 From: "Seth R. Johnson" Date: Tue, 23 Aug 2022 07:05:03 -0400 Subject: Add cxxstd flag to googletest and default mock to true (#32171) --- var/spack/repos/builtin/packages/curl/package.py | 1 + .../repos/builtin/packages/googletest/package.py | 39 ++++++++++++---------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/var/spack/repos/builtin/packages/curl/package.py b/var/spack/repos/builtin/packages/curl/package.py index f600d50127..df23f8ace2 100644 --- a/var/spack/repos/builtin/packages/curl/package.py +++ b/var/spack/repos/builtin/packages/curl/package.py @@ -18,6 +18,7 @@ class Curl(AutotoolsPackage): url = "http://curl.haxx.se/download/curl-7.78.0.tar.bz2" executables = ["^curl$"] + tags = ["build-tools"] version("7.84.0", sha256="702fb26e73190a3bd77071aa146f507b9817cc4dfce218d2ab87f00cd3bc059d") version("7.83.0", sha256="247c7ec7521c4258e65634e529270d214fe32969971cccb72845e7aa46831f96") diff --git a/var/spack/repos/builtin/packages/googletest/package.py b/var/spack/repos/builtin/packages/googletest/package.py index e74afaff06..2b8a73ea67 100644 --- a/var/spack/repos/builtin/packages/googletest/package.py +++ b/var/spack/repos/builtin/packages/googletest/package.py @@ -13,6 +13,8 @@ class Googletest(CMakePackage): url = "https://github.com/google/googletest/archive/release-1.10.0.tar.gz" git = "https://github.com/google/googletest" + maintainers = ["sethrj"] + version("main", branch="main") version("1.12.1", sha256="81964fe578e9bd7c94dfdb09c8e4d6e6759e19967e397dbea48d1c10e45d0df2") version("1.12.0", sha256="2a4f11dce6188b256f3650061525d0fe352069e5c162452818efbbf8d0b5fe1c") @@ -23,30 +25,33 @@ class Googletest(CMakePackage): version("1.7.0", sha256="9639cf8b7f37a4d0c6575f52c01ef167c5f11faee65252296b3ffc2d9acd421b") version("1.6.0", sha256="a61e20c65819eb39a2da85c88622bac703b865ca7fe2bfdcd3da734d87d5521a") - variant("gmock", default=False, description="Build with gmock") - conflicts("+gmock", when="@:1.7.0") - + variant("gmock", default=True, when="@1.8:", description="Build with gmock") variant("pthreads", default=True, description="Build multithreaded version with pthreads") variant("shared", default=True, description="Build shared libraries (DLLs)") + variant( + "cxxstd", + default="11", + values=("98", "11", "14", "17"), + multi=False, + description="Use the specified C++ standard when building", + ) + conflicts("cxxstd=98", when="@1.9:") + conflicts("cxxstd=11", when="@1.13:") + def cmake_args(self): spec = self.spec - if "@1.8.0:" in spec: + args = [ + self.define_from_variant("gtest_disable_pthreads", "pthreads"), + self.define_from_variant("BUILD_SHARED_LIBS", "shared"), + self.define_from_variant("CMAKE_CXX_STANDARD", "cxxstd"), + ] + if spec.satisfies("@1.8:"): # New style (contains both Google Mock and Google Test) - options = ["-DBUILD_GTEST=ON"] - if "+gmock" in spec: - options.append("-DBUILD_GMOCK=ON") - else: - options.append("-DBUILD_GMOCK=OFF") - else: - # Old style (contains only GTest) - options = [] + args.append(self.define("BUILD_GTEST", True)) + args.append(self.define_from_variant("BUILD_GMOCK", "gmock")) - options.append( - "-Dgtest_disable_pthreads={0}".format("OFF" if "+pthreads" in spec else "ON") - ) - options.append(self.define_from_variant("BUILD_SHARED_LIBS", "shared")) - return options + return args @when("@:1.7.0") def install(self, spec, prefix): -- cgit v1.2.3-60-g2f50