There is a problem when building static libraries with Mingw-w64 (32 and 64 versions). It is in the Macros.cmake file at lines 18-19:
if(NOT ${lib} MATCHES ".*/.*")
string(REGEX REPLACE "(.*)/bin/.*\\.exe" "\\1" STANDARD_LIBS_PATH "${CMAKE_CXX_COMPILER}")
set(lib "${STANDARD_LIBS_PATH}/lib/lib${lib}.a")
endif()
The problem is that the libs are split between a couple of directories. Specifically, in my 32-bit version, libopengl32.a, libgdi32.a, libwinmm.a and a few others are not in <mingw>/lib, but rather in <mingw>/i686-w64-mingw32/lib. This totally breaks the above code, which assumes they are in <mingw>/lib, and the make fails.