[cmake-developers] [CMake 0013815]: CMake uses compiler settings under CMakeFiles without verifying that they match the current generator.

Mantis Bug Tracker mantis at public.kitware.com
Wed Dec 26 19:10:30 EST 2012


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=13815 
====================================================================== 
Reported By:                Stephen McCracken
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   13815
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2012-12-26 19:10 EST
Last Modified:              2012-12-26 19:10 EST
====================================================================== 
Summary:                    CMake uses compiler settings under CMakeFiles
without verifying that they match the current generator.
Description: 
The 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 Reproduce: 
1) 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


====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2012-12-26 19:10 Stephen McCrackenNew Issue                                    
======================================================================




More information about the cmake-developers mailing list