Skip to content

Commit

Permalink
Only build tests for proj package if required (spack#41065)
Browse files Browse the repository at this point in the history
* Only build tests for proj package if required

Even if tests are not explictly required to be built, proj build them
anyway and tries to download Google Test.

* proj: fix name of test activation flag

* proj: Always set test activation flag

* proj: Patch test activation logic for versions 5.x
  • Loading branch information
jcortial-safran authored and AlexanderRichert-NOAA committed Jan 9, 2024
1 parent cc9780c commit 5d1bfaf
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
10 changes: 10 additions & 0 deletions var/spack/repos/builtin/packages/proj/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ class Proj(CMakePackage, AutotoolsPackage):
when="@7:7.2.1",
)

patch("proj.cmakelists.5.0.patch", when="@5.0")
patch("proj.cmakelists.5.1.patch", when="@5.1:5.2")

# https://proj.org/install.html#build-requirements
with when("build_system=cmake"):
depends_on("[email protected]:", when="@6:", type="build")
Expand Down Expand Up @@ -137,6 +140,13 @@ def cmake_args(self):
]
if self.spec.satisfies("@6:") and self.pkg.run_tests:
args.append(self.define("USE_EXTERNAL_GTEST", True))
if self.spec.satisfies("@7:"):
test_flag = "BUILD_TESTING"
elif self.spec.satisfies("@5.1:"):
test_flag = "PROJ_TESTS"
else:
test_flag = "PROJ4_TESTS"
args.append(self.define(test_flag, self.pkg.run_tests))
return args


Expand Down
12 changes: 12 additions & 0 deletions var/spack/repos/builtin/packages/proj/proj.cmakelists.5.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -149,5 +149,6 @@ add_subdirectory(nad)
add_subdirectory(src)
add_subdirectory(man)
add_subdirectory(cmake)
-add_subdirectory(test)
-
+if(PROJ4_TESTS)
+ add_subdirectory(test)
+endif(PROJ4_TESTS)
12 changes: 12 additions & 0 deletions var/spack/repos/builtin/packages/proj/proj.cmakelists.5.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -159,5 +159,6 @@ add_subdirectory(nad)
add_subdirectory(src)
add_subdirectory(man)
add_subdirectory(cmake)
-add_subdirectory(test)
-
+if(PROJ_TESTS)
+ add_subdirectory(test)
+endif(PROJ_TESTS)

0 comments on commit 5d1bfaf

Please sign in to comment.