Skip to content

Commit 972e7dc

Browse files
committed
switch from git submodule gtest to linked gtest, update spack.yaml
1 parent ebafd7f commit 972e7dc

14 files changed

Lines changed: 18 additions & 47 deletions

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ endmacro()
124124
# ---------------------------------------------------------------
125125
# ------ Start of find_package section --------------------------
126126
# ---------------------------------------------------------------
127+
if(BUILD_TESTS)
128+
find_package(GTest CONFIG REQUIRED)
129+
endif(BUILD_TESTS)
127130

128131
# Need to check for MPI before building external libraries
129132
find_package(MPI REQUIRED COMPONENTS C CXX Fortran REQUIRED) # MPI_C is needed for the mpi that HDF can bring in
@@ -245,8 +248,6 @@ find_package(Eigen3 REQUIRED NO_MODULE)
245248
set(BLA_VENDOR OpenBLAS)
246249
find_package(BLAS REQUIRED)
247250

248-
249-
250251
find_package(Sparsehash)
251252
if( Sparsehash_FOUND )
252253
add_definitions(-DUSE_SPARSEHASH)

spack.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ spack:
3131
- "cmake@3.30:"
3232
- "openmpi"
3333
- "vtk@9.3:"
34+
- "googletest"
3435
# - "gcc@14"
3536
# - udunits
3637
view:

src/CMakeLists.txt

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,6 @@ endif()
394394

395395
if (BUILD_TESTS)
396396
message(STATUS "Tests enabled. Run with make check")
397-
add_subdirectory (tests/googletest/googletest)
398397

399398
set(TEST_SRCS
400399
tests/test_station.cpp
@@ -409,15 +408,12 @@ if (BUILD_TESTS)
409408
# test_daily.cpp
410409
tests/test_triangulation.cpp
411410
tests/main.cpp
412-
)
413-
411+
)
414412

415-
set( GTEST_LINK
416-
gtest
413+
set(GTEST_LINK
414+
GTest::gtest
417415
)
418416

419-
420-
421417
add_executable(
422418
runUnitTests
423419
${CHM_SRCS}
@@ -455,32 +451,6 @@ if (BUILD_TESTS)
455451
DEPENDS runUnitTests
456452
WORKING_DIRECTORY ${TEST_DIR})
457453

458-
if(BUILD_WITH_CONAN)
459-
if(APPLE)
460-
add_custom_command(TARGET runUnitTests POST_BUILD
461-
#patch CHM to look for @rpath/ for all dylibs that aren't looking for @rpath
462-
COMMAND bash -c "otool -l ${TEST_DIR}/runUnitTests | grep name | grep -v segname | grep -v sectname | grep -v @rpath | awk '{print $2}' | grep -v '^/' | while read x; do install_name_tool -change $x @rpath/`echo $x | grep -Eo '[a-zA-Z0-9_\.-]+\.dylib'` ${TEST_DIR}/runUnitTests; done"
463-
#strip all LC_RPATH from our non-install binary
464-
COMMAND bash -c "otool -l ${TEST_DIR}/runUnitTests | grep LC_RPATH -A2 | grep path | awk '{print $2}' | while read x; do install_name_tool -delete_rpath $x ${TEST_DIR}/runUnitTests; done"
465-
#update LC_RPATH for our non-install binary
466-
COMMAND bash -c "install_name_tool -add_rpath @executable_path/../lib ${TEST_DIR}/runUnitTests"
467-
VERBATIM)
468-
else()
469-
target_link_options(runUnitTests
470-
PUBLIC "LINKER:--disable-new-dtags" )
471-
472-
add_custom_command(TARGET runUnitTests POST_BUILD
473-
# # Some .so will have runpaths, some do not. Just remove them all. The RUNPATHS override the binarie's rpath (I don't know why)
474-
COMMAND bash -c "cd ${CMAKE_BINARY_DIR}/lib ; ls | while read x; do patchelf --remove-rpath $x; done"
475-
#
476-
# # RPATH correctly works, so unlikely to be needed but kept just in case.
477-
# # This removes all runpaths , and then here we will patch each .so to have the correct RUNPATH
478-
COMMAND bash -c "cd ${CMAKE_BINARY_DIR}/lib ; ls | while read x; do patchelf --set-rpath '\$ORIGIN/../lib' $x; done"
479-
480-
VERBATIM
481-
)
482-
endif()
483-
endif()
484454

485455
#copy the data files from test_data to the dir that holds the test binary
486456
add_custom_command(TARGET runUnitTests PRE_BUILD
@@ -490,5 +460,4 @@ if (BUILD_TESTS)
490460
COMMENT "Copying files to $<TARGET_FILE_DIR:runUnitTests> from ${CMAKE_SOURCE_DIR}/test_data/")
491461

492462

493-
494463
endif()

src/tests/test_core.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ friend class core;
4242

4343
virtual void SetUp()
4444
{
45-
logging::core::get()->set_logging_enabled(false);
45+
// // logging::core::get()->set_logging_enabled(false);
4646

4747
// ASSERT_NO_THROW(c0.init(argc,argv));
4848
}

src/tests/test_daily.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class DailyTest : public testing::Test
3434
virtual void SetUp()
3535
{
3636

37-
logging::core::get()->set_logging_enabled(false);
37+
// logging::core::get()->set_logging_enabled(false);
3838

3939
ASSERT_NO_THROW(ts.open("test_daily_vv_oct2010.txt"));
4040
}

src/tests/test_interpolation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class InterpTest : public testing::Test
4040

4141
virtual void SetUp()
4242
{
43-
logging::core::get()->set_logging_enabled(false);
43+
// // logging::core::get()->set_logging_enabled(false);
4444
}
4545

4646
};

src/tests/test_mesh.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class MeshTest : public testing::Test
3232

3333
virtual void SetUp()
3434
{
35-
logging::core::get()->set_logging_enabled(false);
35+
// logging::core::get()->set_logging_enabled(false);
3636
EXPECT_NO_THROW(t.from_file("tin_30mdem_30mtol_nodes.csv"));
3737

3838
}

src/tests/test_metdata.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class MetdataTest : public testing::Test
3333

3434
virtual void SetUp()
3535
{
36-
logging::core::get()->set_logging_enabled(false);
36+
// logging::core::get()->set_logging_enabled(false);
3737

3838
}
3939
std::string proj4str = "+proj=utm +zone=8 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ";

src/tests/test_netcdf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class NetCDFTest : public testing::Test
3333

3434
virtual void SetUp()
3535
{
36-
logging::core::get()->set_logging_enabled(false);
36+
// logging::core::get()->set_logging_enabled(false);
3737

3838
nc.open_GEM("GEM-CHM_2p5_snowcast_2018011506_2018011605.nc");
3939

src/tests/test_regexptokenizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class RegexpTokenizerTest : public testing::Test
3232

3333
virtual void SetUp()
3434
{
35-
logging::core::get()->set_logging_enabled(false);
35+
// logging::core::get()->set_logging_enabled(false);
3636
}
3737

3838
};

0 commit comments

Comments
 (0)