34
34
 
find_valid_components (NetCDF)
35
35
 
36
36
 
#==============================================================================
37
37
 
# SEARCH FOR VALIDATED COMPONENTS
38
38
 
foreach (NCDFcomp IN LISTS NetCDF_FIND_VALID_COMPONENTS)
39
39
 
40
40
 
    # If not found already, search...
41
41
 
    if (NOT NetCDF_${NCDFcomp}_FOUND)
42
42
 
43
43
 
        # Manually add the MPI include and library dirs to search paths
 
44
+
        # and search for the package component
44
45
 
        if (MPI_${NCDFcomp}_FOUND)
45
 
-
            set (NetCDF_${NCDFcomp}_PATHS ${MPI_${NCDFcomp}_INCLUDE_PATH})
46
 
-
            foreach (lib IN LISTS MPI_${NCDFcomp}_LIBRARIES)
47
 
-
                get_filename_component (libdir ${lib} PATH)
48
 
-
                list (APPEND NetCDF_${NCDFcomp}_PATHS ${libdir})
49
 
-
                unset (libdir)
50
 
-
            endforeach ()
 
46
+
            initialize_paths (NetCDF_${NCDFcomp}_PATHS
 
47
+
                              INCLUDE_DIRECTORIES ${MPI_${NCDFcomp}_INCLUDE_PATH}
 
48
+
                              LIBRARIES ${MPI_${NCDFcomp}_LIBRARIES})
 
49
+
            find_package_component(NetCDF COMPONENT ${NCDFcomp}
 
50
+
                                   PATHS ${NetCDF_${NCDFcomp}_PATHS})
 
51
+
        else ()
 
52
+
            find_package_component(NetCDF COMPONENT ${NCDFcomp})
51
53
 
        endif ()
52
 
-
        
53
 
-
        # Search for the package component    
54
 
-
        find_package_component(NetCDF COMPONENT ${NCDFcomp}
55
 
-
                               PATHS ${NetCDF_${NCDFcomp}_PATHS})
56
54
 
57
55
 
        # Continue only if component found
58
56
 
        if (NetCDF_${NCDFcomp}_FOUND)
59
57
 
        
60
58
 
            # Checks
61
59
 
            if (NCDFcomp STREQUAL C)            
62
60
 
            
63
61
 
                # Check version
64
62
 
                check_version (NetCDF
65
63
 
                               NAME "netcdf_meta.h"