[cmake-developers] [CMake 0013105]: Ninja generator renders a previously working build environment destroyed upon re-configure failure

Mantis Bug Tracker mantis at public.kitware.com
Thu Apr 5 05:49:01 EDT 2012


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=13105 
====================================================================== 
Reported By:                Andreas Mohr
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   13105
Category:                   CMake
Reproducibility:            always
Severity:                   major
Priority:                   high
Status:                     new
====================================================================== 
Date Submitted:             2012-04-05 05:49 EDT
Last Modified:              2012-04-05 05:49 EDT
====================================================================== 
Summary:                    Ninja generator renders a previously working build
environment destroyed upon re-configure failure
Description: 
This destruction of the build environment does NOT happen with Makefile
generator, thus it is a bug which needs fixing...
This is a grave problem since I'm relying on a multi-staged build (even
incorporating several vcproj2cmake elements, necessitating integration of even
another conversion run prior to the CMake --> build conversion run), thus it's
important to always preserve a working build environment to keep e.g.
reconversion targets (vcproj2cmake rebuilder targets) available even in case of
re-configure (i.e., re-generation) runs failing (e.g. due to CMake syntax
issues).

Tested with very recent git head.

I recently submitted a very similar issue at
http://public.kitware.com/Bug/view.php?id=13040 , thus tried to analyze the
(instantly provided, thanks!) patch and check what to do with similar use of
cmGeneratedFileStream in cmGlobalNinjaGenerator.cxx, but so far I haven't found
where exactly handling is broken. Possibly from cmGeneratedFileStream point of
view everything is "fine" after Ninja generation, thus it does atomically rename
the (newly broken, due to CMake configure run failure!!) into the (prior,
working!) build.ninja file.
I'll try to spend some more time tracking down this issue, but if anyone knows
where to look, that would be awesome :)

Thanks!

Steps to Reproduce: 
cmake_minimum_required(VERSION 2.8)
project(ninja_reconfigure_destroy_test CXX)

if(NOT CMAKE_GENERATOR MATCHES "Ninja")
  message(FATAL_ERROR "CMAKE_GENERATOR is not set to Ninja!")
endif(NOT CMAKE_GENERATOR MATCHES "Ninja")

file(WRITE "test.cpp"
"int main()
{
  return 0;
}")

set(file_list
  test.cpp
  # test_not_existing_file.cpp # <====== UNCOMMENT THIS LINE!
)

add_library(ninja_reconfigure_destroy_test SHARED ${file_list})

Additional Information: 
Output of actual test run, providing evidence of a destroyed build configuration
(thus any and all targets gone fishin', potentially even some which need to
remain executable to sucessfully get the CMake-side syntax back into working
order!!):

build]$ cmake -DCMAKE_GENERATOR=Ninja ..
-- The CXX compiler identification is GNU 4.1.2
-- Check for working CXX compiler using: Ninja
-- Check for working CXX compiler using: Ninja -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to:
/home/amoh/Projects/cmake_tests/ninja_reconfigure_destroy_test/build
[amoh at lxamoh build]$ ninja
[1/2] Building CXX object
CMakeFiles/ninja_reconfigure_destroy_test.dir/test.cpp.o
../test.cpp:4:2: warning: no newline at end of file
[2/2] Linking CXX shared library libninja_reconfigure_destroy_test.so
[amoh at lxamoh build]$ ninja
ninja: no work to do.
[amoh at lxamoh build]$ vi ../CMakeLists.txt 
[amoh at lxamoh build]$ ninja
[1/1] Re-running CMake...
FAILED: /usr/local/bin/cmake
-H/home/amoh/Projects/cmake_tests/ninja_reconfigure_destroy_test
-B/home/amoh/Projects/cmake_tests/ninja_reconfigure_destroy_test/build
-- Configuring done
CMake Error at CMakeLists.txt:19 (add_library):
  Cannot find source file:

    test_not_existing.cpp

  Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
  .hxx .in .txx


-- Build files have been written to:
/home/amoh/Projects/cmake_tests/ninja_reconfigure_destroy_test/build
ninja: error: rebuilding 'build.ninja': subcommand failed
[amoh at lxamoh build]$ ninja
ninja: error: loading 'build.ninja': line 18, col 20: unknown build rule
'RERUN_CMAKE'
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2012-04-05 05:49 Andreas Mohr   New Issue                                    
======================================================================




More information about the cmake-developers mailing list