[cmake-developers] [CMake 0015216]: Ninja makes bad phony targets with parallel "sub" directory and custom CMAKE_LIBRARY_OUTPUT_DIRECTORY

Mantis Bug Tracker mantis at public.kitware.com
Wed Oct 22 09:44:36 EDT 2014


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=15216 
====================================================================== 
Reported By:                Joseph Lisee
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15216
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2014-10-22 09:44 EDT
Last Modified:              2014-10-22 09:44 EDT
====================================================================== 
Summary:                    Ninja makes bad phony targets with parallel "sub"
directory and custom CMAKE_LIBRARY_OUTPUT_DIRECTORY
Description: 
I have project where the main build directory is on the same level as some "sub"
directories, for example:

  primary/CMakeLists.txt
  secondary/CMakeLists.txt
  primary/build/<CMake generated files>

When I use the CMAKE_LIBRARY_OUTPUT_DIRECTORY to put all the lib files into
primary/lib the build fails with ninja but keeps working with Make.

The ninja error:

ninja: error: '../lib/libtestlib.so', needed by
'CMakeFiles/main.dir/main.cpp.o', missing and no known rule to make it

Inside build.ninja the library is being built with the absolute path
"/tmp/ninja-parallel-sub-test/primary/lib/libtestlib.so" while other places
refer to it as "../lib/libtestlib.so".  

Adding the following phony rule fixes the error:

build ../lib/libtestlib.so: phony
/tmp/ninja-parallel-sub-test/primary/lib/libtestlib.so

Steps to Reproduce: 
Steps:

 * unzip attached zip files
 * cd primary
 * mkdir build
 * cmake .. -G Ninja
 * ninja

Switching to Make will result in primary/bin/main and primary/lib/libtestlib.so
appearing properly.

Make sure to clean up the primary/bin & primary/lib directory while switching
build systems, if not done ninja will appear to work only because it's not
trying to build the targets.

Additional Information: 
This is broken with the latest git head
fc9041d0249c113cb812d69ee0b8f1411f1eea15, CMake 3.0.2 and CMake 2.8.9.  These
bugs are related: 0014972, 0014414
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2014-10-22 09:44 Joseph Lisee   New Issue                                    
2014-10-22 09:44 Joseph Lisee   File Added: ninja-parallel-sub-test.zip         
          
======================================================================




More information about the cmake-developers mailing list