[CMake] How to force cmake to only look for C MPI not C++

Bibrak Qamar bibrakc at gmail.com
Tue Mar 18 02:09:41 EDT 2014


Hi,

I am using cmake to create Makefile. I am using MPI in my project but I
only want to use the C (mpicc) not C++ (mpicxx) following is the
CMakeLists.txt:

I have tested it but on some platforms it seems that it only detects the
C++ mpi (mpicxx) and uses its libraries. This creates errors (mpi.h not
found) as the project only needs C (mpicc and its libraries).

So how to force cmake to only search for C (mpicc) and use its libraries
(the mpi.h not mpicxx.h).



ADD_LIBRARY(nativempjdev SHARED ${SOURCE_FILES})

find_package(MPI)
if(MPI_FOUND)
set(CMAKE_C_COMPILE_FLAGS ${CMAKE_C_COMPILE_FLAGS} ${MPI_C_COMPILE_FLAGS})
set(CMAKE_C_LINK_FLAGS ${CMAKE_C_LINK_FLAGS} ${MPI_C_LINK_FLAGS})

include_directories(${MPI_C_INCLUDE_PATH} $ENV{JAVA_HOME}/include
$ENV{JAVA_HOME}/include/linux)
endif(MPI_FOUND)
target_link_libraries(nativempjdev ${MPI_C_LIBRARIES})
install(TARGETS nativempjdev DESTINATION $ENV{MPJ_HOME}/lib)



Thanks
Bibrak Qamar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140318/a4a8d563/attachment.html>


More information about the CMake mailing list