[cmake-developers] [CMake 0014553]: add_subdirectory fails when using Ninja generator

Mantis Bug Tracker mantis at public.kitware.com
Fri Nov 8 11:07:48 EST 2013


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=14553 
====================================================================== 
Reported By:                Jan Rüegg
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   14553
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2013-11-08 11:07 EST
Last Modified:              2013-11-08 11:07 EST
====================================================================== 
Summary:                    add_subdirectory fails when using Ninja generator
Description: 
This is the setup:

./folder1/CMakeLists.txt:
  cmake_minimum_required(VERSION 2.8)
  set(LIBRARY_OUTPUT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/libs/")
  add_subdirectory(../folder2 ${CMAKE_CURRENT_BINARY_DIR}/folder2)

./folder2/CMakeLists.txt:
  project(foo)
  add_library(foo foo.cpp)

./folder2/foo.cpp:
  int main() {}


Steps to Reproduce: 
When I run cmake with the Unix Makefiles generator, everything works fine:

~/tmp/problem/folder1/build❯ cmake ..
-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
...
-- Configuring done
-- Generating done
-- Build files have been written to: /home/jan/tmp/problem/folder1/build

~/tmp/problem/folder1/build❯ make
Scanning dependencies of target foo
[100%] Building CXX object folder2/CMakeFiles/foo.dir/foo.cpp.o
Linking CXX static library /home/jan/tmp/problem/folder1/libs/libfoo.a
[100%] Built target foo

However, using the Ninja generator doesn't work:

~/tmp/problem/folder1/build❯ cmake -GNinja ..
-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
...
-- Configuring done
-- Generating done
-- Build files have been written to: /home/jan/tmp/problem/folder1/build

~/tmp/problem/folder1/build❯ ninja
ninja: error: '../libs/libfoo.a', needed by 'all', missing and no known rule to
make it


Additional Information: 
~/tmp/problem/folder1/build❯ ninja --version
1.4.0

~/tmp/problem/folder1/build❯ cmake --version
cmake version 2.8.12
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2013-11-08 11:07 Jan Rüegg      New Issue                                    
======================================================================




More information about the cmake-developers mailing list