View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0013815CMakeCMakepublic2012-12-26 19:102016-06-10 14:31
ReporterStephen McCracken 
Assigned ToKitware Robot 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionmoved 
PlatformVisual Studio 11 Win64OSWindowsOS Version7
Product VersionCMake 2.8.10.2 
Target VersionFixed in Version 
Summary0013815: CMake uses compiler settings under CMakeFiles without verifying that they match the current generator.
DescriptionThe first time you run CMake in a clean directory, the enable_language(C) and enable_language(CXX) commands test the compilers for the currently-selected generator (say 32-bit Visual Studio 11) and caches the results in the files CMakeFiles/CMakeCCompiler.cmake and CMakeFiles/CMakeCXXCompiler.cmake.

If you then delete CMakeCache.txt and switch the generator to 64-bit Visual Studio 11 Win64, CMake will not re-test the compiler, and it will proceed with the incorrect cached results for the old (32-bit) generator.

This behavior can be very confusing when debugging CMake errors. In my case, find_package( PythonLibs 2.7 ) was failing because I was trying to use a 64-bit Python 2.7.3 installation with the 32-bit Visual Studio 11 generator. However, when I switched to 64-bit and deleted CMakeCache.txt (but not the CMakeFiles directory), PythonLibs still was not found because CMake was reading CMAKE_SIZEOF_VOID_P=4 from the CMakeFiles directory, which make it look for 32-bit registry settings for the Python installation directory.
Steps To Reproduce1) Create a simple CMakeLists.txt file with the following 2 lines:

   enable_language( CXX )
   message( STATUS "CMAKE_SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P}" )

2) Run cmake-gui with the Visual Studio 11 generator, and observe the output:
   CMAKE_SIZEOF_VOID_P=4

3) Delete the CMakeCache.txt file.

4) Run cmake-gui again from the same directory, but choose the Visual Studio 11 Win64 generator. Observe the incorrect output value:
   CMAKE_SIZEOF_VOID_P=4

TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0031944)
Rolf Eike Beer (developer)
2012-12-27 04:04

Switching the generator requires cleaning the build directory, and this means not only CMakeCache.txt but everything.
(0031945)
David Cole (manager)
2012-12-27 08:47

I second what Eike said: switching generators invalidates everything in your build tree. Blow the whole thing away and start from scratch.
(0031949)
Stephen McCracken (reporter)
2012-12-27 13:21

Requiring starting from scratch is ok as a policy, but why not put in some simple checks to catch this mistake? It would make the system more robust and possibly reduce the number of bug reports you receive.
(0042184)
Kitware Robot (administrator)
2016-06-10 14:28

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2012-12-26 19:10 Stephen McCracken New Issue
2012-12-27 04:04 Rolf Eike Beer Note Added: 0031944
2012-12-27 08:47 David Cole Note Added: 0031945
2012-12-27 13:21 Stephen McCracken Note Added: 0031949
2016-06-10 14:28 Kitware Robot Note Added: 0042184
2016-06-10 14:28 Kitware Robot Status new => resolved
2016-06-10 14:28 Kitware Robot Resolution open => moved
2016-06-10 14:28 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team