MantisBT - CMake
View Issue Details
0015436CMakeCMakepublic2015-03-07 06:242015-11-02 09:13
Benjamin Schindler 
Brad King 
normalminoralways
closedfixed 
linuxgentoo-
CMake 3.1 
CMake 3.3CMake 3.3 
0015436: ninja generator breaks in symlinked directory
I tried now cmake-3.0, 2.8.11 and 3.1 and all exhibit this issue:

I have a very simple project (helloworld would suffice) and use the ninja generator. The project fails to build with:

ninja: error: build.ninja:20: unknown build rule 'CXX_COMPILER'

Upon inspection, I noted that on the top, older generators produced this line in the ninja generator:

#############################################
# Include rules file.

include rules.ninja

This is not present in the tested versions thus leading to the described bug.
Create hello world project, produce ninja file and build. Should lead to:

ninja: error: build.ninja:20: unknown build rule 'CXX_COMPILER'
No tags attached.
patch v1-0001-Ninja-Improve-internal-check-for-generating-at-the-t.patch (1,665) 2015-03-09 09:29
https://public.kitware.com/Bug/file/5400/v1-0001-Ninja-Improve-internal-check-for-generating-at-the-t.patch
Issue History
2015-03-07 06:24Benjamin SchindlerNew Issue
2015-03-07 06:39Brad KingNote Added: 0038172
2015-03-07 06:55Benjamin SchindlerNote Added: 0038173
2015-03-07 07:03Benjamin SchindlerNote Added: 0038174
2015-03-09 09:29Brad KingFile Added: v1-0001-Ninja-Improve-internal-check-for-generating-at-the-t.patch
2015-03-09 09:29Brad KingTarget Version => CMake 3.3
2015-03-09 09:29Brad KingSummaryninja generator fails to produce include statement for rules => ninja generator breaks in symlinked directory
2015-03-09 09:30Brad KingNote Added: 0038183
2015-03-09 13:32Benjamin SchindlerNote Added: 0038188
2015-03-09 13:38Brad KingNote Added: 0038189
2015-03-09 13:38Brad KingAssigned To => Brad King
2015-03-09 13:38Brad KingStatusnew => resolved
2015-03-09 13:38Brad KingResolutionopen => fixed
2015-03-09 13:38Brad KingFixed in Version => CMake 3.3
2015-03-09 13:39Benjamin SchindlerNote Added: 0038190
2015-11-02 09:13Robert MaynardNote Added: 0039725
2015-11-02 09:13Robert MaynardStatusresolved => closed

Notes
(0038172)
Brad King   
2015-03-07 06:39   
The Ninja generator is widely used and well tested. We have not observed this issue, so please provide more detailed information about how to reproduce it.

There is a condition around generating the information here:

 http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmLocalNinjaGenerator.cxx;hb=v3.1.3#l51 [^]

so that it is only done once by the generator for the top level directory. Somehow the check in isRootMakefile must be failing for you even for the top level:

 http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmLocalNinjaGenerator.cxx;hb=v3.1.3#l183 [^]

Are you using symbolic links in the path anywhere?
(0038173)
Benjamin Schindler   
2015-03-07 06:55   
As a matter of fact, yes, I do use symlinks. The reason is this:
I have an ssd but I don't have space for the entire home directory, so the software develpment directory symlinks into a mnt directory mounted on the ssd.
(0038174)
Benjamin Schindler   
2015-03-07 07:03   
So after googling a bit, I was able to fix this by replacing the symlink by a bind-mount.
I don't know whether this is a cmake or ninja issue, but I think cmake should help a bit here. Either produce an error indicating the condition or properly support symlinks
(0038183)
Brad King   
2015-03-09 09:30   
Please try building CMake with the "v1-0001-Ninja-Improve-internal-check-for-generating-at-the-t.patch" applied.
(0038188)
Benjamin Schindler   
2015-03-09 13:32   
I just tried and the patch seems to fix the issue
(0038189)
Brad King   
2015-03-09 13:38   
I've applied the patch, thanks for testing:

 Ninja: Improve internal check for generating at the top-level
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a6b09085 [^]
(0038190)
Benjamin Schindler   
2015-03-09 13:39   
Thank you for the very quick support!
(0039725)
Robert Maynard   
2015-11-02 09:13   
Closing resolved issues that have not been updated in more than 4 months.