FindMPI and FindOpenMP do not work with CMAKE_EXECUTABLE_SUFFIX
Minimal reproducible example:
cmake_minimum_required(VERSION 3.24.1)
project(foo)
set(CMAKE_EXECUTABLE_SUFFIX "-dbg${CMAKE_EXECUTABLE_SUFFIX}")
find_package(MPI)
find_package(OpenMP)
Output of cmake -B build -S .
:
CMake Error at /usr/share/cmake/Modules/FindMPI.cmake:1269 (try_compile):
Cannot copy output executable
''
to destination specified by COPY_FILE:
'/home/lahwaacz/stuff/cmake_bug_CMAKE_EXECUTABLE_SUFFIX/build/CMakeFiles/FindMPI/test_mpi_C.bin'
Unable to find the executable at any of:
/home/lahwaacz/stuff/cmake_bug_CMAKE_EXECUTABLE_SUFFIX/build/CMakeFiles/CMakeTmp/cmTC_b22c0-dbg
/home/lahwaacz/stuff/cmake_bug_CMAKE_EXECUTABLE_SUFFIX/build/CMakeFiles/CMakeTmp/Debug/cmTC_b22c0-dbg
/home/lahwaacz/stuff/cmake_bug_CMAKE_EXECUTABLE_SUFFIX/build/CMakeFiles/CMakeTmp/Development/cmTC_b22c0-dbg
Call Stack (most recent call first):
/usr/share/cmake/Modules/FindMPI.cmake:1320 (_MPI_try_staged_settings)
/usr/share/cmake/Modules/FindMPI.cmake:1643 (_MPI_check_lang_works)
CMakeLists.txt:4 (find_package)
CMake Error at /usr/share/cmake/Modules/FindMPI.cmake:1746 (file):
file STRINGS file
"/home/lahwaacz/stuff/cmake_bug_CMAKE_EXECUTABLE_SUFFIX/build/CMakeFiles/FindMPI/test_mpi_C.bin"
cannot be read.
Call Stack (most recent call first):
CMakeLists.txt:4 (find_package)
CMake Error at /usr/share/cmake/Modules/FindMPI.cmake:1269 (try_compile):
Cannot copy output executable
''
to destination specified by COPY_FILE:
'/home/lahwaacz/stuff/cmake_bug_CMAKE_EXECUTABLE_SUFFIX/build/CMakeFiles/FindMPI/test_mpi_CXX.bin'
Unable to find the executable at any of:
/home/lahwaacz/stuff/cmake_bug_CMAKE_EXECUTABLE_SUFFIX/build/CMakeFiles/CMakeTmp/cmTC_b9e51-dbg
/home/lahwaacz/stuff/cmake_bug_CMAKE_EXECUTABLE_SUFFIX/build/CMakeFiles/CMakeTmp/Debug/cmTC_b9e51-dbg
/home/lahwaacz/stuff/cmake_bug_CMAKE_EXECUTABLE_SUFFIX/build/CMakeFiles/CMakeTmp/Development/cmTC_b9e51-dbg
Call Stack (most recent call first):
/usr/share/cmake/Modules/FindMPI.cmake:1320 (_MPI_try_staged_settings)
/usr/share/cmake/Modules/FindMPI.cmake:1643 (_MPI_check_lang_works)
CMakeLists.txt:4 (find_package)
CMake Error at /usr/share/cmake/Modules/FindMPI.cmake:1269 (try_compile):
Cannot copy output executable
''
to destination specified by COPY_FILE:
'/home/lahwaacz/stuff/cmake_bug_CMAKE_EXECUTABLE_SUFFIX/build/CMakeFiles/FindMPI/test_mpi_CXX.bin'
Unable to find the executable at any of:
/home/lahwaacz/stuff/cmake_bug_CMAKE_EXECUTABLE_SUFFIX/build/CMakeFiles/CMakeTmp/cmTC_e08a5-dbg
/home/lahwaacz/stuff/cmake_bug_CMAKE_EXECUTABLE_SUFFIX/build/CMakeFiles/CMakeTmp/Debug/cmTC_e08a5-dbg
/home/lahwaacz/stuff/cmake_bug_CMAKE_EXECUTABLE_SUFFIX/build/CMakeFiles/CMakeTmp/Development/cmTC_e08a5-dbg
Call Stack (most recent call first):
/usr/share/cmake/Modules/FindMPI.cmake:1670 (_MPI_try_staged_settings)
CMakeLists.txt:4 (find_package)
CMake Error at /usr/share/cmake/Modules/FindMPI.cmake:1746 (file):
file STRINGS file
"/home/lahwaacz/stuff/cmake_bug_CMAKE_EXECUTABLE_SUFFIX/build/CMakeFiles/FindMPI/test_mpi_CXX.bin"
cannot be read.
Call Stack (most recent call first):
CMakeLists.txt:4 (find_package)
CMake Error at /usr/share/cmake/Modules/FindOpenMP.cmake:397 (try_compile):
Cannot copy output executable
''
to destination specified by COPY_FILE:
'/home/lahwaacz/stuff/cmake_bug_CMAKE_EXECUTABLE_SUFFIX/build/CMakeFiles/FindOpenMP/ompver_C.bin'
Unable to find the executable at any of:
/home/lahwaacz/stuff/cmake_bug_CMAKE_EXECUTABLE_SUFFIX/build/CMakeFiles/CMakeTmp/cmTC_82cd4-dbg
/home/lahwaacz/stuff/cmake_bug_CMAKE_EXECUTABLE_SUFFIX/build/CMakeFiles/CMakeTmp/Debug/cmTC_82cd4-dbg
/home/lahwaacz/stuff/cmake_bug_CMAKE_EXECUTABLE_SUFFIX/build/CMakeFiles/CMakeTmp/Development/cmTC_82cd4-dbg
Call Stack (most recent call first):
/usr/share/cmake/Modules/FindOpenMP.cmake:525 (_OPENMP_GET_SPEC_DATE)
CMakeLists.txt:5 (find_package)
CMake Error at /usr/share/cmake/Modules/FindOpenMP.cmake:397 (try_compile):
Cannot copy output executable
''
to destination specified by COPY_FILE:
'/home/lahwaacz/stuff/cmake_bug_CMAKE_EXECUTABLE_SUFFIX/build/CMakeFiles/FindOpenMP/ompver_CXX.bin'
Unable to find the executable at any of:
/home/lahwaacz/stuff/cmake_bug_CMAKE_EXECUTABLE_SUFFIX/build/CMakeFiles/CMakeTmp/cmTC_e7462-dbg
/home/lahwaacz/stuff/cmake_bug_CMAKE_EXECUTABLE_SUFFIX/build/CMakeFiles/CMakeTmp/Debug/cmTC_e7462-dbg
/home/lahwaacz/stuff/cmake_bug_CMAKE_EXECUTABLE_SUFFIX/build/CMakeFiles/CMakeTmp/Development/cmTC_e7462-dbg
Call Stack (most recent call first):
/usr/share/cmake/Modules/FindOpenMP.cmake:525 (_OPENMP_GET_SPEC_DATE)
CMakeLists.txt:5 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/lahwaacz/stuff/cmake_bug_CMAKE_EXECUTABLE_SUFFIX/build/CMakeFiles/CMakeOutput.log".