Skip to content

Commit 82540c8

Browse files
committed
fix-examples: Fix crash in examples
This fixes: > $ examples/example_vdata > terminate called after throwing an instance of 'hdf4cpp::HdfException' > what(): HDF4CPP: cannot construct object, the id is invalid > [1] 29130 abort (core dumped) examples/example_vdata This was caused by an unset TEST_DATA_PATH variable. It was only set in the tests directory, which did not propagate to the examples directory.
1 parent ff52956 commit 82540c8

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ endif ()
6767
option(HDF4CPP_BUILD_TESTS "Enable building tests" ON)
6868
option(HDF4CPP_BUILD_EXAMPLES "Enable building examples" ON)
6969

70+
if (NOT DEFINED TEST_DATA_PATH)
71+
set(TEST_DATA_PATH "${PROJECT_SOURCE_DIR}/tests/test_data/")
72+
message(STATUS "No path to test data defined, using ${TEST_DATA_PATH} as default")
73+
endif ()
74+
7075
if (HDF4CPP_BUILD_TESTS)
7176
add_subdirectory(tests)
7277
endif()

tests/CMakeLists.txt

-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ target_compile_definitions(hdf4cpp-tests PRIVATE
1919
GTEST_DONT_DEFINE_FAIL
2020
GTEST_DONT_DEFINE_SUCCEED)
2121

22-
23-
if (NOT DEFINED TEST_DATA_PATH)
24-
set(TEST_DATA_PATH "${PROJECT_SOURCE_DIR}/tests/test_data/")
25-
message(STATUS "No path to test data defined, using ${TEST_DATA_PATH} as default")
26-
endif ()
2722
target_compile_definitions(hdf4cpp-tests PRIVATE
2823
"TEST_DATA_PATH=\"${TEST_DATA_PATH}\"")
2924

0 commit comments

Comments
 (0)