ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/cmake/modules/FindMpiCompilers.cmake
(Generate patch)

Comparing branches/development/cmake/modules/FindMpiCompilers.cmake (file contents):
Revision 1625 by chuckv, Fri Jul 9 23:13:29 2010 UTC vs.
Revision 1626 by gezelter, Tue Sep 13 15:39:54 2011 UTC

# Line 1 | Line 1
1   # - Find the MPI compiler wrappers
2 < # This module locates the MPI compiler wrappers (mpicc, mpicxx/mpic++,  
3 < mpif77 and mpif90).
4 < # It is useful if one wants to force a project to use the MPI compiler  
5 < wrappers as default
2 > # This module locates the MPI compiler wrappers (mpicc, mpicxx/mpic++, mpif77 and mpif90).
3 > # It is useful if one wants to force a project to use the MPI compiler wrappers as default
4   # compilers.
5   #
6   # The module has the following COMPONENTS:
# Line 12 | Line 10 | wrappers as default
10   #  F90  searches for mpif90
11   # If no components are specified, all of them are enabled by default.
12   #
13 < # The module sets the following cache variables (if the corresponding  
16 < module is enabled):
13 > # The module sets the following cache variables (if the corresponding module is enabled):
14   #  MPICOMPILERS_C    the mpicc compiler
15   #  MPICOMPILERS_CXX  the mpicxx/mpic++ compiler
16   #  MPICOMPILERS_F77  the mpif77 compiler
17   #  MPICOMPILERS_F90  the mpif90 compiler
18   #
19 < # If the user wishes to specify a specific compiler wrapper (e.g. one  
20 < which is
24 < # using a non-standard name or one which is not found on the path) can  
25 < do so
19 > # If the user wishes to specify a specific compiler wrapper (e.g. one which is
20 > # using a non-standard name or one which is not found on the path) can do so
21   # by setting the corresponding MPICOMPILERS_XXX variable (e.g. using the
22 < # -D flag the first time CMake is run). It also honours environment  
23 < variables
29 < # by the same name. The CC, CXX and similar variables are not  
30 < considered by
22 > # -D flag the first time CMake is run). It also honours environment variables
23 > # by the same name. The CC, CXX and similar variables are not considered by
24   # design.
25   #
26   # If the module is not REQUIRED make sure to check the MPICOMPILERS_XXX
27   # variables.
28   #
29 < # Beware that although the module can search for both the mpif77 and  
30 < mpif90
31 < # compiler wrappers, CMake only knows the CMAKE_Fortran_COMPILER  
39 < variable
40 < # which means that you can't use both of the wrappers in the same  
41 < project. This,
29 > # Beware that although the module can search for both the mpif77 and mpif90
30 > # compiler wrappers, CMake only knows the CMAKE_Fortran_COMPILER variable
31 > # which means that you can't use both of the wrappers in the same project. This,
32   # however, probably is not a big issue as Fortran90 is a superset of
33   # Fortran77 and all Fortran90 compilers I know of also process Fortran77
34   # sources.
35   #
36   # An example CMakeLists.txt could look like this:
37   #
38 < #  # prevent CMake from compiler detection using NONE as the project  
49 < language
38 > #  # prevent CMake from compiler detection using NONE as the project language
39   #  project( some_project NONE )
40 < #
40 > #  
41   #  cmake_minimum_required( VERSION 2.6 )
42 < #
42 > #  
43   #  # find the mpi compiler wrappers
44   #  find_package( MpiCompilers REQUIRED CXX F77 )
45 < #
45 > #  
46   #  # set the CMAKE_XXX_COMPILER variables
47   #  set( CMAKE_CXX_COMPILER ${MPICOMPILERS_CXX} )
48   #  set( CMAKE_Fortran_COMPILER ${MPICOMPILERS_F77} )
49   #  # enable the corresponding languages to do the compiler detection
50   #  enable_language( CXX )
51   #  enable_language( Fortran )
52 < #
52 > #  
53   #  # now go on as usual
54   #  add_executable( fancy_mpi_program source1.cxx source2.f )
55  
56 < # Copyright 2009 Michael Wild <themiwi at users.sourceforge.net>
56 > # Copyright 2009 Michael Wild <themiwi@users.sourceforge.net>
57 > # All rights reserved.
58 > #
59 > # Redistribution and use in source and binary forms, with or without
60 > # modification, are permitted provided that the following conditions are met:
61 > #
62 > # * Redistributions of source code must retain the above copyright notice,
63 > #   this list of conditions and the following disclaimer.
64 > # * Redistributions in binary form must reproduce the above copyright notice,
65 > #   this list of conditions and the following disclaimer in the documentation
66 > #   and/or other materials provided with the distribution.
67 > # * The names of its contributors may not be used to endorse or promote
68 > #   products derived from this software without specific prior written
69 > #   permission.
70 > #
71 > # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
72 > # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
73 > # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
74 > # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
75 > # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
76 > # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
77 > # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
78 > # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
79 > # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
80 > # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
81 > # POSSIBILITY OF SUCH DAMAGE.
82  
83   # check the components that are requested
84   if( MpiCompilers_FIND_COMPONENTS )
85 <   set( __MpiCompilers_C FALSE )
86 <   set( __MpiCompilers_CXX FALSE )
87 <   set( __MpiCompilers_F77 FALSE )
88 <   set( __MpiCompilers_F90 FALSE )
89 <   foreach( __MpiCompilers_comp ${MpiCompilers_FIND_COMPONENTS} )
90 <     if( __MpiCompilers_comp STREQUAL C )
91 <       set( __MpiCompilers_C TRUE )
92 <     elseif( __MpiCompilers_comp STREQUAL CXX )
93 <       set( __MpiCompilers_CXX TRUE )
94 <     elseif(__MpiCompilers_comp STREQUAL F77 )
95 <       set( __MpiCompilers_F77 TRUE )
96 <     elseif( __MpiCompilers_comp STREQUAL F90 )
97 <       set( __MpiCompilers_F90 TRUE )
98 <     else( __MpiCompilers_comp STREQUAL C )
99 <       message( FATAL_ERROR "Unknown component ${__MpiCompilers_comp}" )
100 <     endif( __MpiCompilers_comp STREQUAL C )
101 <   endforeach( __MpiCompilers_comp )
85 >  set( __MpiCompilers_C FALSE )
86 >  set( __MpiCompilers_CXX FALSE )
87 >  set( __MpiCompilers_F77 FALSE )
88 >  set( __MpiCompilers_F90 FALSE )
89 >  foreach( __MpiCompilers_comp ${MpiCompilers_FIND_COMPONENTS} )
90 >    if( __MpiCompilers_comp STREQUAL C )
91 >      set( __MpiCompilers_C TRUE )
92 >    elseif( __MpiCompilers_comp STREQUAL CXX )
93 >      set( __MpiCompilers_CXX TRUE )
94 >    elseif(__MpiCompilers_comp STREQUAL F77 )
95 >      set( __MpiCompilers_F77 TRUE )
96 >    elseif( __MpiCompilers_comp STREQUAL F90 )
97 >      set( __MpiCompilers_F90 TRUE )
98 >    else( __MpiCompilers_comp STREQUAL C )
99 >      message( FATAL_ERROR "Unknown component ${__MpiCompilers_comp}" )
100 >    endif( __MpiCompilers_comp STREQUAL C )
101 >  endforeach( __MpiCompilers_comp )
102   else( MpiCompilers_FIND_COMPONENTS )
103 <   # by default turn all components on
104 <   set( __MpiCompilers_C TRUE )
105 <   set( __MpiCompilers_CXX TRUE )
106 <   set( __MpiCompilers_F77 TRUE )
107 <   set( __MpiCompilers_F90 TRUE )
103 >  # by default turn all components on
104 >  set( __MpiCompilers_C TRUE )
105 >  set( __MpiCompilers_CXX TRUE )
106 >  set( __MpiCompilers_F77 TRUE )
107 >  set( __MpiCompilers_F90 TRUE )
108   endif( MpiCompilers_FIND_COMPONENTS )
109  
110   # find the requested compilers and set up the list
# Line 98 | Line 112 | if( __MpiCompilers_C )
112   set( __MpiCompilers_REQVARS "" )
113   set( __MpiCompilers_FOUNDCOMPILERS "" )
114   if( __MpiCompilers_C )
115 <   if( NOT "$ENV{MPICOMPILERS_C}" STREQUAL "" )
116 <     set( MPICOMPILERS_C $ENV{MPICOMPILERS_C} CACHE FILEPATH "Path to  
117 < the MPI C compiler" )
118 <   else( NOT "$ENV{MPICOMPILERS_C}" STREQUAL "" )
119 <     find_program( MPICOMPILERS_C mpicc DOC "Path to the MPI C  
120 < compiler" )
121 <   endif( NOT "$ENV{MPICOMPILERS_C}" STREQUAL "" )
108 <   list( APPEND __MpiCompilers_REQVARS MPICOMPILERS_C )
109 <   set( __MpiCompilers_FOUNDCOMPILERS "$
110 < {__MpiCompilers_FOUNDCOMPILERS} ${MPICOMPILERS_C}" )
115 >  if( NOT "$ENV{MPICOMPILERS_C}" STREQUAL "" )
116 >    set( MPICOMPILERS_C $ENV{MPICOMPILERS_C} CACHE FILEPATH "Path to the MPI C compiler" )
117 >  else( NOT "$ENV{MPICOMPILERS_C}" STREQUAL "" )
118 >    find_program( MPICOMPILERS_C mpicc DOC "Path to the MPI C compiler" )
119 >  endif( NOT "$ENV{MPICOMPILERS_C}" STREQUAL "" )
120 >  list( APPEND __MpiCompilers_REQVARS MPICOMPILERS_C )
121 >  set( __MpiCompilers_FOUNDCOMPILERS "${__MpiCompilers_FOUNDCOMPILERS} ${MPICOMPILERS_C}" )
122   endif( __MpiCompilers_C )
123   if( __MpiCompilers_CXX )
124 <   if( NOT "$ENV{MPICOMPILERS_CXX}" STREQUAL "" )
125 <     set( MPICOMPILERS_CXX $ENV{MPICOMPILERS_CXX} CACHE FILEPATH "Path  
126 < to the MPI C++ compiler" )
127 <   else( NOT "$ENV{MPICOMPILERS_CXX}" STREQUAL "" )
128 <     find_program( MPICOMPILERS_CXX NAMES mpicxx mpic++ DOC "Path to  
129 < the MPI C++ compiler" )
130 <   endif( NOT "$ENV{MPICOMPILERS_CXX}" STREQUAL "" )
120 <   list( APPEND __MpiCompilers_REQVARS MPICOMPILERS_CXX )
121 <   set( __MpiCompilers_FOUNDCOMPILERS "$
122 < {__MpiCompilers_FOUNDCOMPILERS} ${MPICOMPILERS_CXX}" )
124 >  if( NOT "$ENV{MPICOMPILERS_CXX}" STREQUAL "" )
125 >    set( MPICOMPILERS_CXX $ENV{MPICOMPILERS_CXX} CACHE FILEPATH "Path to the MPI C++ compiler" )
126 >  else( NOT "$ENV{MPICOMPILERS_CXX}" STREQUAL "" )
127 >    find_program( MPICOMPILERS_CXX NAMES mpicxx mpic++ DOC "Path to the MPI C++ compiler" )
128 >  endif( NOT "$ENV{MPICOMPILERS_CXX}" STREQUAL "" )
129 >  list( APPEND __MpiCompilers_REQVARS MPICOMPILERS_CXX )
130 >  set( __MpiCompilers_FOUNDCOMPILERS "${__MpiCompilers_FOUNDCOMPILERS} ${MPICOMPILERS_CXX}" )
131   endif( __MpiCompilers_CXX )
132   if( __MpiCompilers_F77 )
133 <   if( NOT "$ENV{MPICOMPILERS_F77}" STREQUAL "" )
134 <     set( MPICOMPILERS_F77 $ENV{MPICOMPILERS_F77} CACHE FILEPATH "Path  
135 < to the MPI F77 compiler" )
136 <   else( NOT "$ENV{MPICOMPILERS_F77}" STREQUAL "" )
137 <     find_program( MPICOMPILERS_F77 mpif77 DOC "Path to the MPI F77  
138 < compiler" )
139 <   endif( NOT "$ENV{MPICOMPILERS_F77}" STREQUAL "" )
132 <   list( APPEND __MpiCompilers_REQVARS MPICOMPILERS_F77 )
133 <   set( __MpiCompilers_FOUNDCOMPILERS "$
134 < {__MpiCompilers_FOUNDCOMPILERS} ${MPICOMPILERS_F77}" )
133 >  if( NOT "$ENV{MPICOMPILERS_F77}" STREQUAL "" )
134 >    set( MPICOMPILERS_F77 $ENV{MPICOMPILERS_F77} CACHE FILEPATH "Path to the MPI F77 compiler" )
135 >  else( NOT "$ENV{MPICOMPILERS_F77}" STREQUAL "" )
136 >    find_program( MPICOMPILERS_F77 mpif77 DOC "Path to the MPI F77 compiler" )
137 >  endif( NOT "$ENV{MPICOMPILERS_F77}" STREQUAL "" )
138 >  list( APPEND __MpiCompilers_REQVARS MPICOMPILERS_F77 )
139 >  set( __MpiCompilers_FOUNDCOMPILERS "${__MpiCompilers_FOUNDCOMPILERS} ${MPICOMPILERS_F77}" )
140   endif( __MpiCompilers_F77 )
141   if( __MpiCompilers_F90 )
142 <   if( NOT "$ENV{MPICOMPILERS_F90}" STREQUAL "" )
143 <     set( MPICOMPILERS_F90 $ENV{MPICOMPILERS_F90} CACHE FILEPATH "Path  
144 < to the MPI F90 compiler" )
145 <   else( NOT "$ENV{MPICOMPILERS_F90}" STREQUAL "" )
146 <     find_program( MPICOMPILERS_F90 mpif90 DOC "Path to the MPI F77  
147 < compiler" )
148 <   endif( NOT "$ENV{MPICOMPILERS_F90}" STREQUAL "" )
144 <   list( APPEND __MpiCompilers_REQVARS MPICOMPILERS_F90 )
145 <   set( __MpiCompilers_FOUNDCOMPILERS "$
146 < {__MpiCompilers_FOUNDCOMPILERS} ${MPICOMPILERS_F90}" )
142 >  if( NOT "$ENV{MPICOMPILERS_F90}" STREQUAL "" )
143 >    set( MPICOMPILERS_F90 $ENV{MPICOMPILERS_F90} CACHE FILEPATH "Path to the MPI F90 compiler" )
144 >  else( NOT "$ENV{MPICOMPILERS_F90}" STREQUAL "" )
145 >    find_program( MPICOMPILERS_F90 mpif90 DOC "Path to the MPI F77 compiler" )
146 >  endif( NOT "$ENV{MPICOMPILERS_F90}" STREQUAL "" )
147 >  list( APPEND __MpiCompilers_REQVARS MPICOMPILERS_F90 )
148 >  set( __MpiCompilers_FOUNDCOMPILERS "${__MpiCompilers_FOUNDCOMPILERS} ${MPICOMPILERS_F90}" )
149   endif( __MpiCompilers_F90 )
150  
151   mark_as_advanced( ${__MpiCompilers_REQVARS} )
152  
153   # handle standard arguments
154   include( FindPackageHandleStandardArgs )
155 < find_package_handle_standard_args( MpiCompilers DEFAULT_MSG  
154 < __MpiCompilers_FOUNDCOMPILERS ${__MpiCompilers_REQVARS} )
155 > find_package_handle_standard_args( MpiCompilers DEFAULT_MSG __MpiCompilers_FOUNDCOMPILERS ${__MpiCompilers_REQVARS} )
156  
157 + ############################## END OF FindMpiCompilers.cmake ##############################

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines