[CMake] How to compile MPI code
Mª Dolores Villalobos Ortiz
lolalobos17 at yahoo.es
Wed Jun 22 14:11:06 EDT 2011
Thank you.
I have tried to compile my code using that version of CMakeLists, but it doesn't work. My program's output is still wrong.
This is completely, utterly wrong!
# 2.7 was a development version, so you should either specify
# 2.6 or 2.8...
cmake_minim_required(VERSION 2.7)
project(ITK_MPI)
find_package(MPI REQUIRED)
include_directories(${MPI_INCLUDE_PATH})
add_executable(hello hello.cpp)
target_link_libraries(hello ${MPI_LIBRARIES})
if(MPI_COMPILE_FLAGS)
set_target_properties(hello PROPERTIES
COMPILE_FLAGS "${MPI_COMPILE_FLAGS}")
endif()
if(MPI_LINK_FLAGS)
set_target_properties(hello PROPERTIES
LINK_FLAGS "${MPI_LINK_FLAGS}")
endif()
You should *NEVER* set CMAKE_<LANG>_COMPILER, this completely breaks
things. Also, with CMake you shouldn't use the compiler wrappers (mpicxx
etc.), because CMake figures out how to compile MPI programs without it.
HTH
Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110622/b1b70dc4/attachment.htm>
More information about the CMake
mailing list