[vtkusers] VTK + openMPI + CMake

Kevin H. Hobbs hobbsk at ohio.edu
Mon Nov 26 11:31:24 EST 2012


On 11/26/2012 10:52 AM, Matthias Härtel wrote:
> 
> In Cmake i must set some entries manually: i set MPI_LIBRARY to

This is all I have in CMakeLists.txt:

	project( MPI_CMake )
	
	cmake_minimum_required( VERSION 2.8 )
	
	find_package( MPI REQUIRED )
	
	// Fedora puts openMPI and mpich in nonstandard
	// places to allow the user to switch.
	include_directories( ${MPI_INCLUDE_PATH} )
	
	add_executable( hello hello.cxx )
	target_link_libraries( hello ${MPI_CXX_LIBRARIES} )

and this is hello.cxx

	#include <stdlib.h>
	#include <stdio.h>
	#include <mpi.h>
	
	int main( int argc, char *argv[] )
	{
	
	  int mpi_rank;
	  int mpi_size;
	
	  // Initialise MPI
	  MPI_Init( &argc, &argv );
	  MPI_Comm_rank( MPI_COMM_WORLD, &mpi_rank );
	  MPI_Comm_size( MPI_COMM_WORLD, &mpi_size );
	
	  printf( "%i of %i\n", mpi_rank, mpi_size );
	
	  // End MPI
	  MPI_Finalize ();
	
	  return 0;
	
	}

which works for me with "cmake . && make && mpiexec -n 2 ./hello"

What do you have in CMakeCache.txt if you do not set any variables manually?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 253 bytes
Desc: OpenPGP digital signature
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20121126/15c04cdf/attachment.pgp>


More information about the vtkusers mailing list