https://bugzilla.redhat.com/show_bug.cgi?id=870455
--- Comment #8 from Erik van Pienbroek erik-fedora@vanpienbroek.nl --- The Fedora MinGW SIG recommends to use the mingw32-cmake / mingw64-cmake wrappers to call CMake with the proper environment set. Internally these wrappers call this RPM macro:
%mingw32_cmake %{mingw32_env} ; \ if test -f CMakeLists.txt; then __mingw32_topdir=.; \\ elif test -f ../CMakeLists.txt; then __mingw32_topdir=..; \\ else __mingw32_topdir=""; fi; \\ PATH=%{_prefix}/%{mingw32_target}/bin:$PATH %__cmake \\ -DCMAKE_VERBOSE_MAKEFILE=ON \\ -DCMAKE_INSTALL_PREFIX:PATH=%{mingw32_prefix} \\ -DCMAKE_INSTALL_LIBDIR:PATH=%{mingw32_libdir} \\ -DINCLUDE_INSTALL_DIR:PATH=%{mingw32_includedir} \\ -DLIB_INSTALL_DIR:PATH=%{mingw32_libdir} \\ -DSYSCONF_INSTALL_DIR:PATH=%{mingw32_sysconfdir} \\ -DSHARE_INSTALL_PREFIX:PATH=%{mingw32_datadir} \\ %{?_cmake_skip_rpath} \\ -DBUILD_SHARED_LIBS:BOOL=ON \\ -DCMAKE_TOOLCHAIN_FILE=/usr/share/mingw/Toolchain-mingw32.cmake \\ ${MINGW_CMAKE_ARGS} \\ ${MINGW32_CMAKE_ARGS} \\ "$@" $__mingw32_topdir
If I understand the discussion above correctly then the QT_BINARY_DIR which is set in Toolchain-mingw32.cmake / Toolchain-mingw64.cmake is redundant and should be removed. I just tried to remove it from the toolchain file, but doing so causes mingw32-cmake to not be able to detect to qt tools (like moc and rcc) any more.
I think this is because QT_BINARY_DIR will be set to /usr/i686-w64-mingw32/sys-root/mingw/bin internally by CMake. However, this path only contains cross-compiled binaries. The native binaries belonging to the cross-compiled Qt are in /usr/i686-w64-mingw32/bin (we don't want to mix native and cross-compiled binaries in the same folder).
In the FindQt4.cmake file there's this snippet of code:
# ask qmake for the binary dir IF (NOT QT_BINARY_DIR OR QT_QMAKE_CHANGED) _qt4_query_qmake(QT_INSTALL_BINS qt_bins) SET(QT_BINARY_DIR ${qt_bins} CACHE INTERNAL "" FORCE) ENDIF (NOT QT_BINARY_DIR OR QT_QMAKE_CHANGED)
The qmake variable QT_INSTALL_BINS is used by Qt's build system to determine where the (cross-)compiled binaries will be installed. I could try hack up the mingw-qt package so that QT_INSTALL_BINS points to /usr/i686-w64-mingw32/bin instead of /usr/i686-w64-mingw32/sys-root/mingw/bin but that isn't the most elegant solution and I'm not sure what else will break because of this..
All qmake mkspecs profiles contain variables like QMAKE_MOC which points to the full path where the moc binary is installed. Ideally CMake should be able to use these variables instead of only searching for $QT_INSTALL_BINS/moc or $PATH/moc. Unfortunately these value for these variables can't be extracted with 'qmake-qt4 -query' so I guess a different solution should be searched..