Skip to content

Commit

Permalink
Bufr test improvements (spack#143)
Browse files Browse the repository at this point in the history
* Add variant to disable tests for bufr becuase it downloads test files during CMake phase
* Create patch that links to libm for C tests to workaround DSO error
  • Loading branch information
kgerheiser committed Jul 28, 2022
1 parent 82e4136 commit 54bc0d8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions var/spack/repos/builtin/packages/bufr/c-tests-libm.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/test/CMakeLists.txt 2022-07-28 11:25:13.000000000 -0400
+++ b/test/CMakeLists.txt 2022-07-28 11:26:40.000000000 -0400
@@ -205,7 +205,7 @@
set(test_exe ${test}.x)
add_executable(${test_exe} ${test_src})
add_dependencies(${test_exe} bufr_${kind})
- target_link_libraries(${test_exe} PRIVATE bufr::bufr_${kind})
+ target_link_libraries(${test_exe} PRIVATE bufr::bufr_${kind} m)
add_test(NAME ${test} COMMAND ${CMAKE_BINARY_DIR}/test/${test_exe})
endforeach()
endforeach()
5 changes: 5 additions & 0 deletions var/spack/repos/builtin/packages/bufr/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ class Bufr(CMakePackage):

# Patch to not add '-c' to ranlib flags when using llvm-ranlib on Apple systems
patch('cmakelists-apple-llvm-ranlib.patch', when='@:11.6.0')
# C test does not explicity link to -lm causing DSO error when building shared libs
patch('c-tests-libm.patch', when='@11.5.0:11.7.0')

variant('python', default=False, description='Enable Python interface?')
variant('shared', default=True, description='Build shared libraries')
variant('tests', default=False, description='Build tests')

extends('python', when='+python')

depends_on('python@3:', type=('build', 'run'), when='+python')
Expand All @@ -43,6 +47,7 @@ def cmake_args(self):
args = [
self.define_from_variant('ENABLE_PYTHON', 'python'),
self.define_from_variant('BUILD_SHARED_LIBS', 'shared'),
self.define_from_variant('BUILD_TESTS', 'tests'),
]

return args
Expand Down

0 comments on commit 54bc0d8

Please sign in to comment.