Intel oneAPI MPI: check_cxx_source_compiles() does not like MPI_CXX_LINK_FLAGS
I provided a failing example in the mpi
folder of this repository: https://github.com/marcfehling/cmake-test
Whenever calling check_cxx_source_compiles()
with CMAKE_REQUIRED_LIBRARIES
set to MPI_CXX_LINK_FLAGS
, I will get the following error:
CMake Warning (dev) at /home/marc/cmake-test/mpi/build/CMakeFiles/CMakeTmp/CMakeLists.txt:15:
Syntax Warning in cmake code at column 90
Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Error at /home/marc/cmake-test/mpi/build/CMakeFiles/CMakeTmp/CMakeLists.txt:14 (add_executable):
Target "cmTC_24f4d" links to item "-Xlinker --enable-new-dtags -Xlinker
-rpath -Xlinker " which has leading or trailing whitespace. This is now an
error according to policy CMP0004.
I can reproduce this with both CMake 3.20.5
and CMake 3.21.0-rc3
. Further, I noticed the following:
- If I specify a compiler wrapper via
CMAKE_CXX_COMPILER=mpiicpc
, thecheck_cxx_source_compiles()
test succeeds. - If I skip the
check_cxx_source_compiles()
test,hello.cpp
compiles just fine.
An overview on how MPI_CXX_LINK_FLAGS
will be set:
compiler | mpi | MPI_CXX_LINK_FLAGS |
---|---|---|
g++ | openmpi | -Wl,-rpath -Wl,/usr/lib64 -Wl,-rpath -Wl,/usr/lib/openmpi -Wl,--enable-new-dtags -L/usr/lib -pthread |
mpigxx | openmpi | |
g++/icpc | impi | -Xlinker --enable-new-dtags -Xlinker -rpath -Xlinker "/opt/intel/oneapi/mpi/2021.3.0/lib/release" -Xlinker -rpath -Xlinker "/opt/intel/oneapi/mpi/2021.3.0/lib" |
mpigxx/mpiicpc | impi |
Notice how the error message from above is truncated after the first double quotes "
.
I supplied a hotfix to my failing example. If I replace all double quotes "
with single quotes '
via the following command, the check_cxx_source_compiles()
test succeeds.
string(REPLACE "\"" "'" CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
It seems like try_compile()
does somehow truncate the CMAKE_REQUIRED_LIBRARIES
variable after the first double quotes "
. This seems odd. Have i made a mistake somewhere? Or is this unintended behavior?
Error first encountered while setting up CI for deal.II: https://github.com/dealii/dealii/pull/12554