diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index d48ca58..7370b6a 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -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 @@ -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() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fdfe83d..35bb9d5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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