Thanks for the validation.
But wouldn't the shorter version break in case MPI_C_COMPILE_FLAGS are
added in the future?
On 03.04.15 23:28, Thompson, KT wrote:
Alex,
Your setup looks fine. However, depending on your environment, you may be able
to use a simplified CMakeLists.txt. This is what I use on Linux with g++ and
OpenMPI.
#--------------------
cmake_minimum_required(VERSION 2.8)
project(hw CXX)
find_package( MPI )
include_directories( ${MPI_CXX_INCLUDE_PATH} )
add_executable( hw hw.cc )
target_link_libraries( hw ${MPI_CXX_LIBRARIES} )
#--------------------
-kt
-----Original Message-----
From: CMake [mailto:[email protected]] On Behalf Of Alexander Droste
Sent: Friday, April 03, 2015 12:24 PM
To: [email protected]
Subject: [CMake] how to use the FindMPI module correctly?
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
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake