BinUtils not found for MinGW with suffix
CMakeDetermineCCompiler.cmake
parses the toolchain prefix in the following way:
if (COMPILER_BASENAME MATCHES "^(.+-)(clang|g?cc)(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$")
set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1})
elseif(...)
The gcc-mingw-w64-x86-64 package in Debian provides:
/usr/bin/x86_64-w64-mingw32-gcc-posix
/usr/bin/x86_64-w64-mingw32-gcc-win32
/usr/bin/x86_64-w64-mingw32-gcc-7.3-posix
/usr/bin/x86_64-w64-mingw32-gcc-7.3-win32
/usr/bin/x86_64-w64-mingw32-gcc-ar-posix
/usr/bin/x86_64-w64-mingw32-gcc-ar-win32
/usr/bin/x86_64-w64-mingw32-gcc-ranlib-posix
/usr/bin/x86_64-w64-mingw32-gcc-ranlib-win32
...
The binutils-mingw-w64-x86-64 package in Debian provides:
/usr/bin/x86_64-w64-mingw32-ar
/usr/bin/x86_64-w64-mingw32-strip
...
Issues:
- When the compiler has a suffix like
-posix
, the regular expression does not match. Therefore, the_CMAKE_TOOLCHAIN_PREFIX
is not properly set and binutils likeCMAKE_AR
andCMAKE_STRIP
are not found. - The suffix needs to be used for locating
CMAKE_C_COMPILER_AR
andCMAKE_C_COMPILER_RANLIB
. - The expression needs to accept version numbers with less than 3 components.