[cmake-developers] [CMake 0014820]: CMAKE_EXECUTABLE_FORMAT behaves incorrectly after removing CMakeCache.txt

Mantis Bug Tracker mantis at public.kitware.com
Thu Mar 20 19:09:14 EDT 2014


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=14820 
====================================================================== 
Reported By:                Carl Worth
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   14820
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2014-03-20 19:09 EDT
Last Modified:              2014-03-20 19:09 EDT
====================================================================== 
Summary:                    CMAKE_EXECUTABLE_FORMAT behaves incorrectly after
removing CMakeCache.txt
Description: 
I am trying to build a project which uses cmake and that queries
CMAKE_EXECUTABLE_FORMAT. The project has been building inconsistently
for me, and I've tracked that down to CMAKE_EXECUTABLE_FORMAT returning
an incorrect result after I remove the CMakeCache.txt file. (Before
removing the cache, it returns a correct value of 'ELF'. After removing
the cache, it returns an incorrect value of ''.)

Steps to Reproduce: 
Here is a session showing the bug.

First, the contents of the files:

$ ls
CMakeLists.txt
$ cat CMakeLists.txt 
cmake_minimum_required (VERSION 2.8)

include (CMakeDetermineCompilerId)
if (CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF")
   message ("Correct. CMAKE_EXECUTABLE_FORMAT is '${CMAKE_EXECUTABLE_FORMAT}'")
else ()
   message ("Incorrect. CMAKE_EXECUTABLE_FORMAT is
'${CMAKE_EXECUTABLE_FORMAT}'")
endif ()

Then, correct results:

$ cmake .
-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
-- Check for working C compiler: /home/cworth/bin/cc
-- Check for working C compiler: /home/cworth/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /home/cworth/bin/g++
-- Check for working CXX compiler: /home/cworth/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
Correct. CMAKE_EXECUTABLE_FORMAT is 'ELF'
-- Configuring done
-- Generating done
-- Build files have been written to: /home/cworth/src/cmake_bug
$ rm CMakeCache.txt 
$ cmake .
Correct. CMAKE_EXECUTABLE_FORMAT is 'ELF'
-- Configuring done
-- Generating done
-- Build files have been written to: /home/cworth/src/cmake_bug

Now, after remove CMakeCache.txt, the incorrect results:

$ rm CMakeCache.txt 
$ cmake .
Incorrect. CMAKE_EXECUTABLE_FORMAT is ''
-- Configuring done
-- Generating done
-- Build files have been written to: /home/cworth/src/cmake_bug

Finally, I can get to correct results again by removing the CMakeFiles
directory:

$ rm -r CMakeFiles/
$ cmake .
-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
-- Check for working C compiler: /home/cworth/bin/cc
-- Check for working C compiler: /home/cworth/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /home/cworth/bin/g++
-- Check for working CXX compiler: /home/cworth/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
Correct. CMAKE_EXECUTABLE_FORMAT is 'ELF'
-- Configuring done
-- Generating done
-- Build files have been written to: /home/cworth/src/cmake_bug

I'm assuming that it is a valid thing to remove CmakeCache.txt and
expect things to still work. After all, cmake itself tells me to do
that in some cases:

$ cmake . -GNinja
CMake Error: Error: generator : Ninja
Does not match the generator used previously: Unix Makefiles
Either remove the CMakeCache.txt file or choose a different binary directory.


Additional Information: 
Thanks in advance for any information, (particularly if I am doing anything
wrong).

-Carl
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2014-03-20 19:09 Carl Worth     New Issue                                    
======================================================================



More information about the cmake-developers mailing list