39
39
 
find_valid_components (GPTL)
40
40
 
41
41
 
#==============================================================================
42
42
 
# SEARCH FOR VALIDATED COMPONENTS
43
43
 
foreach (GPTL_comp IN LISTS GPTL_FIND_VALID_COMPONENTS)
44
44
 
45
45
 
    # If not found already, search...
46
46
 
    if (NOT GPTL_${GPTL_comp}_FOUND)
47
47
 
48
48
 
        # Manually add the MPI include and library dirs to search paths
49
 
-
        if (GPTL_comp STREQUAL C)
50
 
-
            if (MPI_C_FOUND)
51
 
-
                set (GPTL_${GPTL_comp}_PATHS ${MPI_C_INCLUDE_PATH})
52
 
-
                foreach (lib IN LISTS MPI_C_LIBRARIES)
53
 
-
                    get_filename_component (libdir ${lib} PATH)
54
 
-
                    list (APPEND GPTL_${GPTL_comp}_PATHS ${libdir})
55
 
-
                    unset (libdir)
56
 
-
                endforeach ()
57
 
-
            endif ()
58
 
-
        else ()
59
 
-
            if (MPI_Fortran_FOUND)
60
 
-
                set (GPTL_${GPTL_comp}_PATHS ${MPI_Fortran_INCLUDE_PATH})
61
 
-
                foreach (lib IN LISTS MPI_Fortran_LIBRARIES)
62
 
-
                    get_filename_component (libdir ${lib} PATH)
63
 
-
                    list (APPEND GPTL_${GPTL_comp}_PATHS ${libdir})
64
 
-
                    unset (libdir)
65
 
-
                endforeach ()
66
 
-
            endif ()
 
49
+
        if (GPTL_comp STREQUAL C AND MPI_C_FOUND)
 
50
+
            set (mpiincs ${MPI_C_INCLUDE_PATH})
 
51
+
            set (mpilibs ${MPI_C_LIBRARIES})
 
52
+
            set (mpifound ${MPI_C_FOUND})
 
53
+
        elseif (MPI_Fortran_FOUND)
 
54
+
            set (mpiincs ${MPI_Fortran_INCLUDE_PATH})
 
55
+
            set (mpilibs ${MPI_Fortran_LIBRARIES})
 
56
+
            set (mpifound ${MPI_Fortran_FOUND})
67
57
 
        endif ()
68
 
-
 
58
+
        
69
59
 
        # Search for the package component
70
 
-
        find_package_component(GPTL COMPONENT ${GPTL_comp}
71
 
-
                               PATHS ${GPTL_${GPTL_comp}_PATHS})
 
60
+
        if (mpifound)
 
61
+
            initialize_paths (GPTL_${GPTL_comp}_PATHS
 
62
+
                              INCLUDE_DIRECTORIES ${mpiincs}
 
63
+
                              LIBRARIES ${mpilibs})
 
64
+
            find_package_component(GPTL COMPONENT ${GPTL_comp}
 
65
+
                                   PATHS ${GPTL_${GPTL_comp}_PATHS})
 
66
+
        else ()
 
67
+
            find_package_component(GPTL COMPONENT ${GPTL_comp})
 
68
+
        endif ()
72
69
 
73
70
 
    endif ()
74
71
 
    
75
72
 
endforeach ()