kosta777 / parallel-genomeseq

Parallelization of popular genome sequencing algorithms
4 stars 1 forks source link

CMake Config for MPI #11

Closed huanglangwen closed 4 years ago

huanglangwen commented 4 years ago

Firstly install openmpi (suggest 3.0) on your system, and then use cmake .. -DUSEMPI=on to configure openMPI. All the code that calls MPI have to be wrapped by ifdef USEMPI block, so that we can switch between serial version and MPI version.

option(USEMPI "Use MPI" OFF)

if (USEMPI)
    add_definitions(-DUSEMPI)
    find_package(MPI REQUIRED)
    message(STATUS "Using MPI_INCLUDE_PATH: ${MPI_INCLUDE_PATH}")
    message(STATUS "Using MPI_CXX_LIBRARIES: ${MPI_CXX_LIBRARIES}")
    include_directories(SYSTEM ${MPI_INCLUDE_PATH})
    target_link_libraries(${TARGET_NAME} PUBLIC ${MPI_CXX_LIBRARIES})
    set(CMAKE_CXX_COMPILER ${CXX}) #use C-API exposed to C++ https://cmake.org/cmake/help/latest/module/FindMPI.html
endif ()