[CMake] Toolchain changes even though specified on the command line

J Decker d3ck0r at gmail.com
Mon Mar 7 16:10:53 EST 2011


I have several compilers setup on my box for various reasons.

I definately know this shows up when building for mingw and using the
wrong command prompt with say visual studio in the path, and gcc not
in the path.

First, I create a new build output directory go into that directory
and run a command line that specifies -G "MinGW Makefiles"......  then
run 'make install' and of course the project builds;  and I keep this
around for  a long time and keep revisiting, every time running the
full cmake command line specifying all the parameters I want to use;
it looks something like this

'cmake -G "MinGW Makefiles"  /sack -DCMAKE_BUILD_TYPE=Debug
-DCMAKE_INSTALL_PREFIX=/build/mingw_mono32_sack_core -DNEED_FREETYPE=1
-DNEED_JPEG=1 -DNEED_PNG=1 -DNEED_ZLIB=1 -DBUILD_MONOLITHIC=1'

Then in a command shell that has watcom as the environment; it has
tools 'nmake' and 'cl' etc which are supposedly clones of microsoft
for compatiblity.

the following is the output

M:\build\mingw\sack\mono32_core>cmake -G "MinGW Makefiles"  /sack
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_INSTALL_PREFIX=/build/mingw_mono32_sack_core -DNEED_FREETYPE=1
-DNEED_JPEG=1 -DNEED_PNG=1 -DNEED_ZLIB=1 DBUILD_MONOLITHIC=1
CMake Error: your RC compiler: "windres" was not found.   Please set
CMAKE_RC_COMPILER to a valid compiler path or name.
-- Configuring incomplete, errors occurred!
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_RC_COMPILER= c:/tools/unix/mingw/bin/windres.exe

-- Generating done
-- Build files have been written to: M:/build/mingw/sack/mono32_core


M:\build\mingw\sack\mono32_core>make install
-- Building for: Visual Studio 10
-- Check for working C compiler using: Visual Studio 10
-- Check for working C compiler using: Visual Studio 10 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 10...............


So now I realize my mistake and hit ctrl-C and go to the correct shell
but now when I run the build process I get




M:\build\mingw\sack\mono32_core>cmake -G "MinGW Makefiles"  /sack
-DCMAKE_BUILD_TYPE=Debug
DCMAKE_INSTALL_PREFIX=/build/mingw_mono32_sack_core -DNEED_FREETYPE=1
-DNEED_JPEG=1 -DNEED_PNG=1 -DNEED_ZLIB=1 DBUILD_MONOLITHIC=1
CMake Error: Error: generator : MinGW Makefiles
Does not match the generator used previously: Visual Studio 10
Either remove the CMakeCache.txt file or choose a different binary directory.

M:\build\mingw\sack\mono32_core>make install
... 1
-- Configuring done
-- Generating done
-- Build files have been written to: M:/build/mingw/sack/mono32_core
Scanning dependencies of target sack_bag
CMake Error: Directory Information file not found
[  1%] Building C object
CMakeFiles/sack_bag.dir/src/deadstart/deadstart_list.c.obj
'""' is not recognized as an internal or external command,
operable program or batch file.
make[2]: *** [CMakeFiles/sack_bag.dir/src/deadstart/deadstart_list.c.obj]
Error 1
make[1]: *** [CMakeFiles/sack_bag.dir/all] Error 2
make: *** [all] Error 2

------- So even though the makefiles were created with mingw, the
cache got deleted because it can't find 'windres'; and is now allowed
to configure for a different compiler than what was specified on the
command line.  I have to manually delete the CMakeCache.txt and start
over; which causes a recompilation of the entire project.

Maybe if the makefile output included the generator so it wouldn't
just invoke cmake with no generator, allwoing cmake to choose an
inappropriate generator for the output that already exists?  I do note
that since 'windres.exe' doesn't exist cmake deletes the
CMakeCache.txt; maybe if it just didn't do that?


More information about the CMake mailing list