Skip to content

Commit 6435ffc

Browse files
committed
examples: netcdf shared lib paths
1 parent 540e1c3 commit 6435ffc

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

example/CMakeLists.txt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.11...3.25)
1+
cmake_minimum_required(VERSION 3.15...3.28)
22

33
project(nc4fortranExample
44
LANGUAGES C Fortran
@@ -25,3 +25,23 @@ target_link_libraries(example2 nc4fortran::nc4fortran)
2525
add_test(NAME nc4fortran:Example2 COMMAND example2
2626
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
2727
)
28+
29+
# --- NetCDF shared lib paths needed
30+
get_property(test_names DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY TESTS)
31+
get_property(incdir TARGET nc4fortran::nc4fortran PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
32+
33+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.22)
34+
if(WIN32)
35+
set_property(TEST ${test_names} PROPERTY
36+
ENVIRONMENT_MODIFICATION "PATH=path_list_append:${incdir}/../bin"
37+
)
38+
elseif(APPLE)
39+
set_property(TEST ${test_names} PROPERTY
40+
ENVIRONMENT_MODIFICATION "DYLD_LIBRARY_PATH=path_list_append:${incdir}/../lib"
41+
)
42+
else()
43+
set_property(TEST ${test_names} PROPERTY
44+
ENVIRONMENT_MODIFICATION "LD_LIBRARY_PATH=path_list_append:${incdir}/../lib"
45+
)
46+
endif()
47+
endif()

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ EXECUTABLE ${CMAKE_CTEST_COMMAND}
4242
)
4343
endif()
4444

45-
# --- Windows shared DLLs
45+
# --- NetCDF shared lib paths needed
4646
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.22)
4747
if(WIN32)
4848
set_property(TEST minimal ${test_names} PROPERTY

0 commit comments

Comments
 (0)