CMake build fails in compile stage with mingw-w64 GCC
## Motivation It would be useful to support mingw-w64 and offer GROMACS for easy installation on Windows via [MSYS2](https://www.msys2.org/) [Packages](https://packages.msys2.org/). ## Build issues This is on Debian 12 with `g++-mingw-w64` package installed. I don't have access to a Windows virtual machine at the moment, but mingw-w64 in MSYS2 would likely exhibit the same problems. Running the command: ``` cmake -B build-mingw-w64 -S . -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ ``` Gives the following standard output: ``` -- The C compiler identification is GNU 12.0.0 -- The CXX compiler identification is GNU 12.0.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - failed -- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc -- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc - works -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - failed -- Check for working CXX compiler: /usr/bin/x86_64-w64-mingw32-g++ -- Check for working CXX compiler: /usr/bin/x86_64-w64-mingw32-g++ - works -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found Python3: /usr/bin/python3 (found suitable version "3.11.2", minimum required is "3.7") found components: Interpreter Development Development.Module Development.Embed -- Found Git: /usr/bin/git (found version "2.39.2") -- Found OpenMP_C: -fopenmp -- Found OpenMP_CXX: -fopenmp -- Found OpenMP: TRUE -- Performing Test CFLAGS_WARN -- Performing Test CFLAGS_WARN - Success -- Performing Test CFLAGS_WARN_EXTRA -- Performing Test CFLAGS_WARN_EXTRA - Success -- Performing Test CFLAGS_WARN_UNDEF -- Performing Test CFLAGS_WARN_UNDEF - Success -- Performing Test CFLAGS_WARN_REL -- Performing Test CFLAGS_WARN_REL - Success -- Performing Test CFLAGS_STRINGOP_TRUNCATION -- Performing Test CFLAGS_STRINGOP_TRUNCATION - Success -- Performing Test CFLAGS_WARN_NO_MISSING_FIELD_INITIALIZERS -- Performing Test CFLAGS_WARN_NO_MISSING_FIELD_INITIALIZERS - Success -- Performing Test CFLAGS_EXCESS_PREC -- Performing Test CFLAGS_EXCESS_PREC - Success -- Performing Test CFLAGS_COPT -- Performing Test CFLAGS_COPT - Success -- Performing Test CFLAGS_NOINLINE -- Performing Test CFLAGS_NOINLINE - Success -- Performing Test CXXFLAGS_WARN -- Performing Test CXXFLAGS_WARN - Success -- Performing Test CXXFLAGS_WARN_EXTRA -- Performing Test CXXFLAGS_WARN_EXTRA - Success -- Performing Test CXXFLAGS_WARN_UNDEF -- Performing Test CXXFLAGS_WARN_UNDEF - Success -- Performing Test CXXFLAGS_WARN_REL -- Performing Test CXXFLAGS_WARN_REL - Success -- Performing Test CXXFLAGS_STRINGOP_TRUNCATION -- Performing Test CXXFLAGS_STRINGOP_TRUNCATION - Success -- Performing Test CXXFLAGS_WARN_NO_MISSING_FIELD_INITIALIZERS -- Performing Test CXXFLAGS_WARN_NO_MISSING_FIELD_INITIALIZERS - Success -- Performing Test CXXFLAGS_EXCESS_PREC -- Performing Test CXXFLAGS_EXCESS_PREC - Success -- Performing Test CXXFLAGS_COPT -- Performing Test CXXFLAGS_COPT - Success -- Performing Test CXXFLAGS_NOINLINE -- Performing Test CXXFLAGS_NOINLINE - Success -- Looking for include file unistd.h -- Looking for include file unistd.h - found -- Looking for include file pwd.h -- Looking for include file pwd.h - not found -- Looking for include file dirent.h -- Looking for include file dirent.h - found -- Looking for include file time.h -- Looking for include file time.h - found -- Looking for include file sys/time.h -- Looking for include file sys/time.h - found -- Looking for include file io.h -- Looking for include file io.h - found -- Looking for include file sched.h -- Looking for include file sched.h - found -- Looking for include file xmmintrin.h -- Looking for include file xmmintrin.h - found -- Looking for gettimeofday -- Looking for gettimeofday - found -- Looking for sysconf -- Looking for sysconf - not found -- Looking for nice -- Looking for nice - not found -- Looking for fsync -- Looking for fsync - not found -- Looking for _fileno -- Looking for _fileno - found -- Looking for fileno -- Looking for fileno - found -- Looking for _commit -- Looking for _commit - found -- Looking for sigaction -- Looking for sigaction - not found -- Performing Test HAVE_BUILTIN_CLZ -- Performing Test HAVE_BUILTIN_CLZ - Success -- Performing Test HAVE_BUILTIN_CLZLL -- Performing Test HAVE_BUILTIN_CLZLL - Success -- Looking for clock_gettime in rt -- Looking for clock_gettime in rt - not found -- Looking for feenableexcept in m -- Looking for feenableexcept in m - not found -- Looking for fedisableexcept in m -- Looking for fedisableexcept in m - not found -- Checking for sched.h GNU affinity API -- Performing Test sched_affinity_compile -- Performing Test sched_affinity_compile - Failed -- Looking for include file mm_malloc.h -- Looking for include file mm_malloc.h - found -- Looking for include file malloc.h -- Looking for include file malloc.h - found -- Checking for _mm_malloc() -- Checking for _mm_malloc() - supported -- Looking for posix_memalign -- Looking for posix_memalign - not found -- Looking for memalign -- Looking for memalign - not found -- Check if the system is big endian -- Searching 16 bit integer -- Looking for sys/types.h -- Looking for sys/types.h - found -- Looking for stdint.h -- Looking for stdint.h - found -- Looking for stddef.h -- Looking for stddef.h - found -- Check size of unsigned short -- Check size of unsigned int -- Check size of unsigned long -- Configuring incomplete, errors occurred! See also "/home/vmiletic/workspace/gromacs/build-mingw-w64/CMakeFiles/CMakeOutput.log". See also "/home/vmiletic/workspace/gromacs/build-mingw-w64/CMakeFiles/CMakeError.log". ``` and the following standard error: ``` CMake Error at /usr/share/cmake-3.25/Modules/FindOpenMP.cmake:420 (try_compile): Cannot copy output executable '' to destination specified by COPY_FILE: '/home/vmiletic/workspace/gromacs/build-mingw-w64/CMakeFiles/FindOpenMP/ompver_C.bin' Recorded try_compile output location doesn't exist: /home/vmiletic/workspace/gromacs/build-mingw-w64/CMakeFiles/CMakeScratch/TryCompile-6HPMeP/cmTC_fe88d Call Stack (most recent call first): /usr/share/cmake-3.25/Modules/FindOpenMP.cmake:560 (_OPENMP_GET_SPEC_DATE) cmake/gmxManageOpenMP.cmake:41 (find_package) CMakeLists.txt:427 (include) CMake Error at /usr/share/cmake-3.25/Modules/FindOpenMP.cmake:420 (try_compile): Cannot copy output executable '' to destination specified by COPY_FILE: '/home/vmiletic/workspace/gromacs/build-mingw-w64/CMakeFiles/FindOpenMP/ompver_CXX.bin' Recorded try_compile output location doesn't exist: /home/vmiletic/workspace/gromacs/build-mingw-w64/CMakeFiles/CMakeScratch/TryCompile-ADBjJe/cmTC_99696 Call Stack (most recent call first): /usr/share/cmake-3.25/Modules/FindOpenMP.cmake:560 (_OPENMP_GET_SPEC_DATE) cmake/gmxManageOpenMP.cmake:41 (find_package) CMakeLists.txt:427 (include) CMake Error at /usr/share/cmake-3.25/Modules/CheckTypeSize.cmake:148 (try_compile): Cannot copy output executable '' to destination specified by COPY_FILE: '/home/vmiletic/workspace/gromacs/build-mingw-w64/CMakeFiles/CheckTypeSize/CMAKE_SIZEOF_UNSIGNED_SHORT.bin' Recorded try_compile output location doesn't exist: /home/vmiletic/workspace/gromacs/build-mingw-w64/CMakeFiles/CMakeScratch/TryCompile-0utBVX/cmTC_0a82e Call Stack (most recent call first): /usr/share/cmake-3.25/Modules/CheckTypeSize.cmake:278 (__check_type_size_impl) /usr/share/cmake-3.25/Modules/TestBigEndian.cmake:55 (CHECK_TYPE_SIZE) /usr/share/cmake-3.25/Modules/TestBigEndian.cmake:37 (__TEST_BIG_ENDIAN_LEGACY_IMPL) CMakeLists.txt:547 (test_big_endian) CMake Error at /usr/share/cmake-3.25/Modules/CheckTypeSize.cmake:148 (try_compile): Cannot copy output executable '' to destination specified by COPY_FILE: '/home/vmiletic/workspace/gromacs/build-mingw-w64/CMakeFiles/CheckTypeSize/CMAKE_SIZEOF_UNSIGNED_INT.bin' Recorded try_compile output location doesn't exist: /home/vmiletic/workspace/gromacs/build-mingw-w64/CMakeFiles/CMakeScratch/TryCompile-CI0Fb7/cmTC_29dab Call Stack (most recent call first): /usr/share/cmake-3.25/Modules/CheckTypeSize.cmake:278 (__check_type_size_impl) /usr/share/cmake-3.25/Modules/TestBigEndian.cmake:60 (CHECK_TYPE_SIZE) /usr/share/cmake-3.25/Modules/TestBigEndian.cmake:37 (__TEST_BIG_ENDIAN_LEGACY_IMPL) CMakeLists.txt:547 (test_big_endian) CMake Error at /usr/share/cmake-3.25/Modules/CheckTypeSize.cmake:148 (try_compile): Cannot copy output executable '' to destination specified by COPY_FILE: '/home/vmiletic/workspace/gromacs/build-mingw-w64/CMakeFiles/CheckTypeSize/CMAKE_SIZEOF_UNSIGNED_LONG.bin' Recorded try_compile output location doesn't exist: /home/vmiletic/workspace/gromacs/build-mingw-w64/CMakeFiles/CMakeScratch/TryCompile-Pccvp1/cmTC_d72c0 Call Stack (most recent call first): /usr/share/cmake-3.25/Modules/CheckTypeSize.cmake:278 (__check_type_size_impl) /usr/share/cmake-3.25/Modules/TestBigEndian.cmake:67 (CHECK_TYPE_SIZE) /usr/share/cmake-3.25/Modules/TestBigEndian.cmake:37 (__TEST_BIG_ENDIAN_LEGACY_IMPL) CMakeLists.txt:547 (test_big_endian) CMake Error at /usr/share/cmake-3.25/Modules/TestBigEndian.cmake:72 (message): no suitable type found Call Stack (most recent call first): /usr/share/cmake-3.25/Modules/TestBigEndian.cmake:37 (__TEST_BIG_ENDIAN_LEGACY_IMPL) CMakeLists.txt:547 (test_big_endian) ``` and the two files with the detailed logging: [CMakeError.log](/uploads/beda01f657f4753b0be0d93aa7c30a10/CMakeError.log) [CMakeOutput.log](/uploads/cc9ca139f3946a7cfe2ceafee0c5b59a/CMakeOutput.log)
issue