On 01/07/2011 11:36 AM, Mark Abraham wrote:
> Hi,
>
> When using MPI, our project needs to be able to test for the validity of
> MPI_IN_PLACE (http://redmine.gromacs.org/issues/594). Ideally we could
> use try_compile to compile a simple test program, however we need to be
> able to direct the use of the compiler information CMake found using the
> FindMPI module. I don't think this is possible at the moment.
>
> Is there a recommended procedure? Should I open a try_compile feature
> request in the issue tracker?
>
> Regards,
>
> Mark
Try this:
find_package(MPI REQUIRED)
include(CheckCSourceCompiles)
set(CMAKE_REQUIRED_DEFINITIONS ${MPI_COMPILE_FLAGS})
set(CMAKE_REQUIRED_INCLUDES ${MPI_INCLUDE_PATH})
set(CMAKE_REQUIRED_LIBRARIES ${MPI_LIBRARIES})
check_c_source_compiles(
"#include <mpi.h>
int main() {
void* buf;
MPI_Allreduce(MPI_IN_PLACE, buf, 10, MPI_FLOAT, MPI_SUM, MPI_COMM_WORLD);
}" MPI_IN_PLACE_COMPILE_OK)
Works for me, on Ubuntu 10.10 with openmpi. Internally, the
CheckCSourceCompiles.cmake module also uses try_compile, but wraps it
nicely and makes sure the test is only run once, and then the result is
cached.
Michael
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake