FindMPI adding -pthread to build line with an extraneous semicolon
CMake since 3.10.0 (using 3.12.2 in this case) is adding -pthread
to the build in such a way that it is causing errors for me in any packages using find_package(MPI)
. Here is an excerpt from the error I see:
-fbounds-check -fbacktrace -fdefault-real-8 -ffree-line-length-none -DNDEBUG -O3 -fexceptions;-pthread
...
/bin/sh: -pthread: command not found
Clearly the semicolon shouldn't be there. I am able to fix this by either using CMake 3.9.4 or commenting out
# MPI might require pthread to work. The above mechanism wouldn't detect it, but we need to
# link it in that case. -lpthread is covered by the normal library treatment on the other hand.
if("${MPI_COMPILE_CMDLINE}" MATCHES "-pthread")
list(APPEND MPI_COMPILE_OPTIONS_WORK "-pthread")
if(MPI_LINK_FLAGS_WORK)
string(APPEND MPI_LINK_FLAGS_WORK " -pthread")
else()
set(MPI_LINK_FLAGS_WORK "-pthread")
endif()
endif()
in FindMPI.cmake. This is on CentOS 7 with OpenMPI 3.1.1. I don't see this behavior on a Mac.
Edited by Jon Rood