Setting up toolchains

Hans-Bernhard Bröker HBBroeker@t-online.de
Mon Sep 27 21:06:13 GMT 2021


Am 27.09.2021 um 13:27 schrieb Anthony Webber:

> Anyway, I am trying to set up my gcc toolchains in Cygwin, by which I 
> mean that I'm trying to set up the environment so that the right 
> programs are called at the right time by build systems like cmake and 
> waf, or if I want to build in a more manual fashion. Particularly, I 
> want to be able to switch between toolchains easily.

That's hardly ever a question of "setting up" the toolchains.  It's 
rather a question of

a) which build system those programs you're trying to build uses, and
b) how you initialize/use said build systems.

GNU autoconf and cmake have relatively mature mechanisms for doing this.

For autoconf you just pass --host=... to configure, and that takes care 
of everything (assuming the package is capable of cross-building in the 
first place).  For cmake you can preload a cmake script like this:

cmake -C some/where/preload_mingw.cmake ../../path/to/source

where preload_mingw.cmake might look like this:

set(CMAKE_CXX_COMPILER "/usr/bin/x86_64-w64-mingw32-g++" CACHE FILEPATH 
"CXX compiler")
set(CMAKE_C_COMPILER "/usr/bin/x86_64-w64-mingw32-gcc" CACHE FILEPATH "C 
compiler")
set(CMAKE_CXX_FLAGS "-D_WIN32_WINNT=0x0601" CACHE STRING "")
set(CMAKE_C_FLAGS "-D_WIN32_WINNT=0x0601" CACHE STRING "")
set(WIN32 "1" CACHE STRING "")

The benefit of doing it this way is that the preload script can stay the 
same for quite a lot of packages, and the system default compiler does 
not even enter the picture, so there will be no misled tests.


More information about the Cygwin mailing list