MantisBT - CMake
View Issue Details
0015216CMakeCMakepublic2014-10-22 09:442016-06-10 14:31
Joseph Lisee 
Kitware Robot 
normalminoralways
closedmoved 
LinuxUbuntu12.04
CMake 3.0.2 
 
0015216: Ninja makes bad phony targets with parallel "sub" directory and custom CMAKE_LIBRARY_OUTPUT_DIRECTORY
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:

 * 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.
This is broken with the latest git head fc9041d0249c113cb812d69ee0b8f1411f1eea15, CMake 3.0.2 and CMake 2.8.9. These bugs are related: 0014972, 0014414
No tags attached.
related to 0014972closed Brad King Ninja gen generates invalid phony dependencies for source files with in-source build 
related to 0014414closed Kitware Robot Ninja: Running compiler from build dir makes it being run from bad relative directory 
zip ninja-parallel-sub-test.zip (1,768) 2014-10-22 09:44
https://public.kitware.com/Bug/file/5283/ninja-parallel-sub-test.zip
Issue History
2014-10-22 09:44Joseph LiseeNew Issue
2014-10-22 09:44Joseph LiseeFile Added: ninja-parallel-sub-test.zip
2014-10-22 10:24Brad KingRelationship addedrelated to 0014972
2014-10-22 10:24Brad KingRelationship addedrelated to 0014414
2016-06-10 14:29Kitware RobotNote Added: 0042649
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0042649)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.