View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0010771CMakeModulespublic2010-05-28 03:502010-09-20 16:37
ReporterMarcel Loose 
Assigned ToBrad King 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product VersionCMake-2-8 
Target VersionCMake 2.8.3Fixed in VersionCMake 2.8.3 
Summary0010771: FindMPI does not set all required compile flags
DescriptionFindMPI 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.
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0022165)
Brad King (manager)
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 (manager)
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 (developer)
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 (manager)
2010-09-20 09:12

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a56969f3 [^]

 Issue History
Date Modified Username Field Change
2010-05-28 03:50 Marcel Loose New Issue
2010-08-31 17:11 David Cole Status new => assigned
2010-08-31 17:11 David Cole Assigned To => Brad King
2010-08-31 17:54 David Cole Target Version => CMake 2.8.3
2010-09-09 15:27 Brad King Note Added: 0022165
2010-09-14 09:15 David Cole Note Added: 0022216
2010-09-14 09:15 David Cole Target Version CMake 2.8.3 =>
2010-09-20 07:37 Marcel Loose Note Added: 0022273
2010-09-20 09:12 Brad King Note Added: 0022275
2010-09-20 09:12 Brad King Status assigned => closed
2010-09-20 09:12 Brad King Resolution open => fixed
2010-09-20 16:37 David Cole Fixed in Version => CMake 2.8.3
2010-09-20 16:37 David Cole Target Version => CMake 2.8.3


Copyright © 2000 - 2018 MantisBT Team