如何编译MPI使用cmake包括C程序 [英] How to compile an MPI included c program using cmake
问题描述
我想申请OpenMP和MPI技术,以一个开放源码的C程序要求cmake的&安培;&放大器;使待建。我已经找到在<一个href=\"http://stackoverflow.com/questions/12399422/how-to-set-linker-flags-for-openmp-in-cmakes-try-compile-function\">How设置链接标志中的OpenMP的CMake的try_compile功能的如何包括-fopenmp标志,但仍然感到困惑MPI。我能做些什么呢?
I am trying to apply openmp and mpi techniques to an open source C program which requires "cmake . && make" to be built. I already found at How to set linker flags for OpenMP in CMake's try_compile function how to include the -fopenmp flags but still confused about mpi. What can I do about that?
推荐答案
这是一个关于的OpenMP 的问题?然后,所有你需要做的就是用 -fopenmp
编译您可以通过追加到 CMAKE_C_FLAGS
,例如做:
OpenMP
Is this a question about OpenMP? Then all you have to do is compile with -fopenmp
which you can do by appending it to CMAKE_C_FLAGS
, for example:
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp)
MPI
对于 MPI ,你必须先找到MPI
MPI
For MPI, you have to find mpi first
find_package(MPI) #make it REQUIRED, if you want
然后将其添加的头文件到您的搜索路径
then add it's header files to your search path
include_directories(SYSTEM ${MPI_INCLUDE_PATH})
和最后链接程序(S)(即 my_mpi_target
在我的情况)
and finally link your program(s) (which is my_mpi_target
in my case)
target_link_libraries(my_mpi_target ${MPI_C_LIBRARIES})
这篇关于如何编译MPI使用cmake包括C程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!