Skip to content

Commit

Permalink
examples: netcdf shared lib paths
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Jan 8, 2024
1 parent 540e1c3 commit 6435ffc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
22 changes: 21 additions & 1 deletion example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.11...3.25)
cmake_minimum_required(VERSION 3.15...3.28)

project(nc4fortranExample
LANGUAGES C Fortran
Expand All @@ -25,3 +25,23 @@ target_link_libraries(example2 nc4fortran::nc4fortran)
add_test(NAME nc4fortran:Example2 COMMAND example2
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)

# --- NetCDF shared lib paths needed
get_property(test_names DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY TESTS)
get_property(incdir TARGET nc4fortran::nc4fortran PROPERTY INTERFACE_INCLUDE_DIRECTORIES)

if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.22)
if(WIN32)
set_property(TEST ${test_names} PROPERTY
ENVIRONMENT_MODIFICATION "PATH=path_list_append:${incdir}/../bin"
)
elseif(APPLE)
set_property(TEST ${test_names} PROPERTY
ENVIRONMENT_MODIFICATION "DYLD_LIBRARY_PATH=path_list_append:${incdir}/../lib"
)
else()
set_property(TEST ${test_names} PROPERTY
ENVIRONMENT_MODIFICATION "LD_LIBRARY_PATH=path_list_append:${incdir}/../lib"
)
endif()
endif()
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ EXECUTABLE ${CMAKE_CTEST_COMMAND}
)
endif()

# --- Windows shared DLLs
# --- NetCDF shared lib paths needed
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.22)
if(WIN32)
set_property(TEST minimal ${test_names} PROPERTY
Expand Down

0 comments on commit 6435ffc

Please sign in to comment.