Skip to content

Commit

Permalink
Find MPI in CMake build
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasgibson committed Oct 18, 2022
1 parent 2c5eee4 commit 0ed56af
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
project(BabelStream VERSION 4.0 LANGUAGES CXX)

# uncomment for debugging build issues:
#set(CMAKE_VERBOSE_MAKEFILE ON)
# set(CMAKE_VERBOSE_MAKEFILE ON)

find_package(MPI)

# some nicer defaults for standard C++
set(CMAKE_CXX_EXTENSIONS OFF)
Expand Down Expand Up @@ -162,6 +164,12 @@ target_compile_options(${EXE_NAME} PUBLIC "$<$<CONFIG:Debug>:${ACTUAL_DEBUG_FLAG
target_link_options(${EXE_NAME} PUBLIC LINKER:${CXX_EXTRA_LINKER_FLAGS})
target_link_options(${EXE_NAME} PUBLIC ${LINK_FLAGS} ${CXX_EXTRA_LINK_FLAGS})

# If MPI is available, link relevant libraries
if(MPI_FOUND)
message(STATUS "MPI Detected. Linking relevant MPI libraries")
target_link_libraries(${EXE_NAME} PUBLIC MPI::MPI_CXX)
endif()

# some models require the target to be already specified so they can finish their setup here
# this only happens if the model.cmake definition contains the `setup_target` macro
if (COMMAND setup_target)
Expand Down

0 comments on commit 0ed56af

Please sign in to comment.