[CMake] FindSWIG and cross compiling

Giampiero Salvi giampi at kth.se
Mon Oct 26 10:04:31 EDT 2009


Hi,
I have a project that builds fine both on Linux and on mingw32 using 
cmake version 2.6-patch 2.

Now, I am trying to cross compile my project on a Linux (Ubuntu 9.04) 
machine for the target Windows platform using the mingw32 cross 
compiler. I have a toolchain more or less copied from 
http://www.itk.org/Wiki/CmakeMingw that looks like this:

# the name of the target operating system
SET(CMAKE_SYSTEM_NAME Windows)

# which compilers to use for C and C++
SET(CMAKE_C_COMPILER i586-mingw32msvc-gcc)
SET(CMAKE_CXX_COMPILER i586-mingw32msvc-g++)

# here is the target environment located
SET(CMAKE_FIND_ROOT_PATH  /usr/i586-mingw32msvc )

# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

My problem is that running

cmake -DCMAKE_TOOLCHAIN_FILE=Toolchain-mingw32.cmake

I get the error:

CMake Error at /usr/share/cmake-2.6/Modules/FindSWIG.cmake:55 (MESSAGE):
   SWIG was not found.  Please specify Swig executable location

If I remove the last line in the toolchain file, cmake finds swig, but I 
get other include-related errors.

Swig is run on the host platform to generate code, so shouldn't its 
configuration be independent of the target platform?

Any help?
Thank you!
Giampiero


More information about the CMake mailing list