[CMake] FindMPI.cmake bug

Simone Crippa crippa at kth.se
Mon Aug 11 05:24:46 EDT 2008


Hi,

I hope this is the correct way to report a bug as a non-developer. If it
is not the case, then I hope that somebody can report this through the
correct channels.


I have found a bug in the module FindMPI.cmake of cmake 2.6.1 (and at
least also in 2.6.0). In line 205 and 211, there is a regexp string,
which is meant to match a flag for linking libraries (e.g. -lmpich). The
problem is that the regexp matches also any other flag that contains the
characters "-l", for example (as in my case) "-fmessage-length=0". In my
case, I received from cmake an error message complaining about a missing
"ength=0" library!

To fix this, I modified the regexp from matching "-l" to matching "
-l" (including a space in front of -l). I attach a diff of the modified
file Modules/FindMPI.cmake.



Best regards, Simone




*** 202,214 ****

    # Extract the set of libraries to link against from the link command
    # line
!   string(REGEX MATCHALL " -l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES
"${MPI_LINK_CMDLINE}")

    # Determine full path names for all of the libraries that one needs
    # to link against in an MPI program
    set(MPI_LIBRARIES)
    foreach(LIB ${MPI_LIBNAMES})
!     string(REGEX REPLACE "^ -l" "" LIB ${LIB})
      set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE)
      find_library(MPI_LIB ${LIB} HINTS ${MPI_LINK_PATH})
      if (MPI_LIB)
--- 202,214 ----

    # Extract the set of libraries to link against from the link command
    # line
!   string(REGEX MATCHALL "-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES
"${MPI_LINK_CMDLINE}")

    # Determine full path names for all of the libraries that one needs
    # to link against in an MPI program
    set(MPI_LIBRARIES)
    foreach(LIB ${MPI_LIBNAMES})
!     string(REGEX REPLACE "^-l" "" LIB ${LIB})
      set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE)
      find_library(MPI_LIB ${LIB} HINTS ${MPI_LINK_PATH})
      if (MPI_LIB)




More information about the CMake mailing list