[CMake] Setting up mingw toolchain for crosscompiling from Linux

Alexander Neundorf a.neundorf-work at gmx.net
Sun May 11 16:37:12 EDT 2008


On Sunday 11 May 2008, Nathan Huesken wrote:
> Hi,
>
> My cmake project works now!
> Now I want to crosscompile to Windows. I am under gentoo and installed
> mingw toolchain (which works, I can manually compile with it). Then I setup
> the Toolchain-mingw32.cmake as suggested here:
> http://www.cmake.org/Wiki/CmakeMingw
>
> # the name of the target operating system
> SET(CMAKE_SYSTEM_NAME Windows)
>
> # which compilers to use for C and C++
> SET(CMAKE_C_COMPILER i686-mingw32-gcc)
> SET(CMAKE_CXX_COMPILER i686-mingw32-g++)
>
> # here is the target environment located
> SET(CMAKE_FIND_ROOT_PATH /usr/i686-mingw32)
>
> # 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)
>
> Now I try to crosscompile with this toolchain:
> cmake -DCMAKE_TOOLCHAIN_FILE=./Toolchain-mingw32.cmake

Did you do this in a clean build tree or was there already a CMakeCache.txt in 
the source dir or in the build dir ?
If this is the case, then the settings from this CMakeCache.txt are used.

Alex

P.S. you are quite new to cmake, immediately starting with cross compiling is 
maybe not the easiest thing to do in the beginning, but let's see how it 
goes...


More information about the CMake mailing list