MantisBT - CMake
View Issue Details
0010771CMakeModulespublic2010-05-28 03:502010-09-20 16:37
Marcel Loose 
Brad King 
normalminoralways
closedfixed 
CMake-2-8 
CMake 2.8.3CMake 2.8.3 
0010771: FindMPI does not set all required compile flags
FindMPI does not set all required compile flags, the way that mpicc/mpicxx do. At least, that is on Linux with MPICH, where these scripts also set a lot of -f options for GCC. These settings are not picked up by FindMPI, as it does not search for compile flags that start with -f.

For example, running 'mpicxx -show' gives me:

$ /opt/mpich/ch-p4/bin/mpicxx -show
g++ -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector
-funwind-tables -fasynchronous-unwind-tables -g -fno-strict-aliasing
-Impid/mpd/ -Iinclude -DUSE_STDARG -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1
-DHAVE_UNISTD_H=1 -DHAVE_STDARG_H=1 -DUSE_STDARG=1 -DMALLOC_RET_VOID=1
-L/opt/mpich/ch-p4/lib64 -lpmpich++ -lmpich -lpthread -lrt

But the -f options do not appear in the CMakeCache.txt file:

$ grep ^MPI_ CMakeCache.txt | grep -v ADVANCED
MPI_COMPILER:FILEPATH=/opt/mpich/ch-p4/bin/mpicxx
MPI_COMPILE_FLAGS:STRING= -D_FORTIFY_SOURCE=2 -DUSE_STDARG
-DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_UNISTD_H=1
-DHAVE_STDARG_H=1 -DUSE_STDARG=1 -DMALLOC_RET_VOID=1
MPI_EXTRA_LIBRARY:STRING=/opt/mpich/ch-p4/lib64/libmpich.a;/usr/lib64/libpthread.so;/usr/lib64/librt.so
MPI_INCLUDE_PATH:STRING=mpid/mpd/;include
MPI_LIBRARY:FILEPATH=/opt/mpich/ch-p4/lib64/libpmpich++.a
MPI_LINK_FLAGS:STRING=
MPI_ROOT_DIR:UNINITIALIZED=/opt/mpich/ch-p4
MPI_LIB:INTERNAL=MPI_LIB-NOTFOUND

This means, that sources will be compiled differently when using g++
directly, supplying the options gathered by FindMPI, compared to using
mpicxx.
No tags attached.
Issue History
2010-05-28 03:50Marcel LooseNew Issue
2010-08-31 17:11David ColeStatusnew => assigned
2010-08-31 17:11David ColeAssigned To => Brad King
2010-08-31 17:54David ColeTarget Version => CMake 2.8.3
2010-09-09 15:27Brad KingNote Added: 0022165
2010-09-14 09:15David ColeNote Added: 0022216
2010-09-14 09:15David ColeTarget VersionCMake 2.8.3 =>
2010-09-20 07:37Marcel LooseNote Added: 0022273
2010-09-20 09:12Brad KingNote Added: 0022275
2010-09-20 09:12Brad KingStatusassigned => closed
2010-09-20 09:12Brad KingResolutionopen => fixed
2010-09-20 16:37David ColeFixed in Version => CMake 2.8.3
2010-09-20 16:37David ColeTarget Version => CMake 2.8.3

Notes
(0022165)
Brad King   
2010-09-09 15:27   
My mpicc does not add any -f options. Does this patch against master work?

diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake
index 45d6bff..9fef8f9 100644
--- a/Modules/FindMPI.cmake
+++ b/Modules/FindMPI.cmake
@@ -188,7 +188,7 @@ if (MPI_INCLUDE_PATH AND MPI_LIBRARY)
   # the cache, and we don't want to override those settings.
 elseif (MPI_COMPILE_CMDLINE)
   # Extract compile flags from the compile command line.
- string(REGEX MATCHALL "(^| )-D([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_FLAGS "${MPI_COMPILE_CMDLINE}")
+ string(REGEX MATCHALL "(^| )-[Df]([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_FLAGS "${MPI_COMPILE_CMDLINE}")
   set(MPI_COMPILE_FLAGS_WORK)
   foreach(FLAG ${MPI_ALL_COMPILE_FLAGS})
     if (MPI_COMPILE_FLAGS_WORK)
(0022216)
David Cole   
2010-09-14 09:15   
We will not be addressing this for the upcoming CMake 2.8.3 release. Changing target release value back to empty for now.

Waiting for reply from reporter to note 22165.
(0022273)
Marcel Loose   
2010-09-20 07:37   
This patch seems to solve the issue. Using MPICH and GCC I now get:

MPI_COMPILE_FLAGS:STRING= -fmessage-length=0 -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -fno-strict-aliasing -DUSE_STDARG -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_UNISTD_H=1 -DHAVE_STDARG_H=1 -DUSE_STDARG=1 -DMALLOC_RET_VOID=1
(0022275)
Brad King   
2010-09-20 09:12   
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a56969f3 [^]