[CMake] Setting up mingw toolchain for crosscompiling from Linux

Nathan Huesken cmake at lonely-star.org
Sun May 11 16:14:12 EDT 2008


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 
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Check size of void*
-- Check size of void* - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Checking for ClanLib
-- Checking for ClanLib -- headers
-- Checking for ClanCore
-- Checking for ClanCore -- /usr/lib64/libclanCore.so
-- Checking for other ClanLib components
-- Checking for ClanApp
-- Checking for ClanApp -- /usr/lib64/libclanApp.so
-- Checking for ClanDisplay
-- Checking for ClanDisplay -- /usr/lib64/libclanDisplay.so
-- Checking for ClanGL
-- Checking for ClanGL -- /usr/lib64/libclanGL.so
-- Checking for ClanGUI
-- Checking for ClanGUI -- /usr/lib64/libclanGUI.so
-- Checking for ClanGUIStyleSilver
-- Checking for ClanGUIStyleSilver -- /usr/lib64/libclanGUIStyleSilver.so
-- Checking for ClanMikMod
-- Checking for ClanMikMod -- /usr/lib64/libclanMikMod.so
-- Checking for ClanNetwork
-- Checking for ClanNetwork -- /usr/lib64/libclanNetwork.so
-- Checking for ClanSDL
-- Checking for ClanSDL -- /usr/lib64/libclanSDL.so
-- Checking for ClanSignals
-- Checking for ClanSignals -- /usr/lib64/libclanSignals.so
-- Checking for ClanSound
-- Checking for ClanSound -- /usr/lib64/libclanSound.so
-- Checking for ClanVorbis
-- Checking for ClanVorbis -- /usr/lib64/libclanVorbis.so
-- Configuring done
-- Generating done

But it is not using the correct C-compiler (should be /usr/bin/i686-mingw-gcc).
And when I type make, it is compiling as if I would not use any Toolchain file.

What am I doing wrong?
Thanks!
Nathan


More information about the CMake mailing list