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

Bruce Cartland bruce.cartland at pobox.com
Tue Mar 18 02:22:03 EDT 2014


Try the project command

* project(yourProjectName C)

It's what I use.

Quick Google found this

* http://www.cmake.org/cmake/help/cmake2.6docs.html#command:project


On 18/03/14 17:09, Bibrak Qamar wrote:
> 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/5d66efd0/attachment.html>


More information about the CMake mailing list