[CMake] FOLLOW-UP: CMAKE - troubles finding executables/paths -Windows 7 / MinGW

Bill Hoffman bill.hoffman at kitware.com
Fri Jun 3 12:16:28 EDT 2011


On 6/3/2011 11:22 AM, Steve Westenbroek wrote:
> Thanks Bill and Bill for looking into this!
>
> I don't know if this was clear in my original post, but is seems that
> most of my troubles with CMake on my system stem from the fact that I
> have nearly half-a-dozen MinGW/MSYS installs on my system; each exists
> for a specific purpose, and each has it's own version of make:
>
> c:\MinGW-32\bin\make.exe
> c:\MinGW-64\bin\make.exe
> c:\OSGeo4W\apps\msys\bin\make.exe
> c:\Program Files (x86)\pythonxy\mingw\bin\make.exe
> c:\RTools\bin\make.exe
>
> None of these fits the patterns given in Modules/CMakeMinGWFindMake.cmake!
>
> I thought that I had expunged all references to MinGW in my system PATH
> variable, but it seems that one snuck in anyway. Somehow CMake was
> identifying 64-bit libraries in spite of the definitions (i.e.
> CMAKE_C_COMPILER, CMAKE_FORTRAN_COMPILER, etc.) all pointing to the
> 32-bit version of MinGW.
>
> I am now able to get Cmake to work by doing the following:
>
> 1) sanitize PATH variable of any MinGW references
> 2) create custom instance of cmd.exe in which LIB, INCLUDE, and
> CMAKE_MAKE_PROGRAM are defined
> 3) start CMake-gui from the command-line within the above environment
>
> CMake still claims CMAKE_MAKE_PROGRAM is undefined (why??), but after
> defining this within the GUI, I now get a working build.
>
> It would still be nice to have an easy way to override all the Windows
> registry and environment variables to ensure that CMake is targeting the
> appropriate toolchain. For whatever reason, I've never been able to get
> CMake to find make, ar, sh etc. on my system via the CMake find_program
> commands.
>

So, CMake should always work with a correctly setup environment.  By 
that I mean one where you can type mingw32-make and it can run gcc and 
g++ with no errors or problems.  CMAKE_MAKE_PROGRAM is a CMake cache 
variable not an environment variable, so setting it in the env will not 
do anything.  The same is true for VS nmake builds.  You have to run 
CMake from an environment where all the tools just work.  Same is true 
on Linux, the compiler and make must be installed and run from the 
command line that CMake is being run with.   To make things "easier", I 
added the registry searching stuff so that it could find mingw 
automatically without having a "correct" environment.  This part seems 
to no longer work with mingw as they seem to have changed some stuff.

Hope that helps.

-Bill


More information about the CMake mailing list