Skip to content

Instantly share code, notes, and snippets.

@niklasfi
Created October 18, 2012 21:45
Show Gist options
  • Save niklasfi/3914935 to your computer and use it in GitHub Desktop.
Save niklasfi/3914935 to your computer and use it in GitHub Desktop.
cmake_minimum_required(VERSION 2.8)
project(foo)
message(STATUS "### MPI active ###")
find_package(MPI REQUIRED)
message(STATUS "MPI FOUND: ${MPI_FOUND}")
message(STATUS "include path: ${MPI_INCLUDE_PATH}")
include_directories(${MPI_INCLUDE_PATH})
message(STATUS "mpi compile flags: ${MPI_CXX_COMPILE_FLAGS}")
message(STATUS "cxx flags (before): ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MPI_CXX_COMPILE_FLAGS}")
message(STATUS "cxx flags (after): ${CMAKE_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MPI_LINK_FLAGS}")
add_library(lib1 lib1)
add_executable(test test)
target_link_libraries(test lib1)
niklas@x230t:~/drops2/cmaketest/bin$ cmakesrc
-- ### MPI active ###
-- MPI FOUND: TRUE
-- include path: /usr/lib/openmpi/include;/usr/lib/openmpi/include/openmpi
-- mpi compile flags:
-- cxx flags (before):
-- cxx flags (after):
-- Configuring done
-- Generating done
-- Build files have been written to: /home/niklas/drops2/cmaketest/bin
niklas@x230t:~/drops2/cmaketest/bin$ mpicxx --showme:compile
-I/usr/lib/openmpi/include -I/usr/lib/openmpi/include/openmpi -pthread
niklas@x230t:~/drops2/cmaketest/bin$ mpicxx --showme:link
-pthread -L/usr/lib/openmpi/lib -lmpi_cxx -lmpi -lopen-rte -lopen-pal -ldl -Wl,--export-dynamic -lnsl -lutil -lm -ldl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment