[CMake] bug in FindwxWidget.cmake (patch proposed)

Florent Teichteil florent.teichteil at gmail.com
Thu Oct 7 03:28:31 EDT 2010


Hi all,

As mentioned in my previous post, there is a bug in the cmake module
FindwxWidgets.cmake that prevents any library using wxWidgets to cross
compile for Windows from Linux. Lines 192 to 198 are concerned by this bug:

IF(WIN32 AND NOT CYGWIN AND NOT MSYS)
  SET(wxWidgets_FIND_STYLE "win32")
ELSE(WIN32 AND NOT CYGWIN AND NOT MSYS)
  IF(UNIX OR MSYS)
    SET(wxWidgets_FIND_STYLE "unix")
  ENDIF(UNIX OR MSYS)
ENDIF(WIN32 AND NOT CYGWIN AND NOT MSYS)

The problem is that, when cross compiling from Linux for Windows, the
test "WIN32 AND NOT CYGWIN AND NOT MSYS" is true but find style should
be "unix", because the Windows-based wxWidget library is installed in a
unix environment.

Therefore, the following line replacement corrects this bug:

IF(WIN32 AND NOT CYGWIN AND NOT MSYS AND NOT CMAKE_CROSSCOMPILING)
  SET(wxWidgets_FIND_STYLE "win32")
ELSE(WIN32 AND NOT CYGWIN AND NOT MSYS AND NOT CMAKE_CROSSCOMPILING)
  IF(UNIX OR MSYS OR CMAKE_CROSSCOMPILING)
    SET(wxWidgets_FIND_STYLE "unix")
  ENDIF(UNIX OR MSYS OR CMAKE_CROSSCOMPILING)
ENDIF(WIN32 AND NOT CYGWIN AND NOT MSYS AND NOT CMAKE_CROSSCOMPILING)

The modified FindwxWidget.cmake module runs fine with the following
toolchain cmake file:

SET(CMAKE_SYSTEM_NAME Windows)
SET(CMAKE_C_COMPILER   /usr/bin/i686-pc-mingw32-gcc)
SET(CMAKE_CXX_COMPILER /usr/bin/i686-pc-mingw32-g++)
SET(CMAKE_FIND_ROOT_PATH  /usr/i686-pc-mingw32)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

Could this "patch" be applied in cmake svn, please?
All the best,
Florent


More information about the CMake mailing list