[CMake] how to use the FindMPI module correctly?
Alexander Droste
alexander.ra.droste at googlemail.com
Fri Apr 3 14:23:48 EDT 2015
Hello everyone,
based on the documentation here:
http://www.cmake.org/cmake/help/v3.0/module/FindMPI.html
and posts on SO:
http://stackoverflow.com/questions/23163075/how-to-compile-an-mpi-included-c-program-using-cmake
I'm still not a 100% sure if I set up my CMake project correctly.
This is what I do:
#------------------------
#...
find_package(MPI REQUIRED)
add_executable(core.x main.c)
include_directories(SYSTEM ${MPI_C_INCLUDE_PATH})
link_directories(${MPI_C_LINK_FLAGS})
set(CMAKE_COMPILE_FLAGS ${CMAKE_COMPILE_FLAGS} ${MPI_C_COMPILE_FLAGS})
target_link_libraries(core.x ${MPI_C_LIBRARIES})
#-------------------------
Is this the correct way? Am I missing s.th.? I am especially unsure
about the compile flags variable.
At "Usage" (CMake documentation) it said that "To use this module,
simply call FindMPI from a CMakeLists.txt file". So can I break down the
MPI setup to a single command. How do I call FindMPI? Or is it done by
calling find_package like I did?
The program build runs fine but I would like to ensure
that the cmake project is set up as correct and generic as possible.
Greetings,
Alex
More information about the CMake
mailing list