MantisBT - CMake
View Issue Details
0014553CMakeCMakepublic2013-11-08 11:072016-06-10 14:31
Jan Rüegg 
Kitware Robot 
normalminoralways
closedmoved 
Arch Linux, 64-bit
CMake 2.8.12 
 
0014553: add_subdirectory fails when using Ninja generator
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() {}
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
~/tmp/problem/folder1/build❯ ninja --version
1.4.0

~/tmp/problem/folder1/build❯ cmake --version
cmake version 2.8.12
No tags attached.
zip subdir.zip (907) 2013-11-26 06:18
https://public.kitware.com/Bug/file/4969/subdir.zip
Issue History
2013-11-08 11:07Jan RüeggNew Issue
2013-11-25 03:48Peter KuemmelNote Added: 0034539
2013-11-25 03:48Peter KuemmelAssigned To => Peter Kuemmel
2013-11-25 03:48Peter KuemmelStatusnew => assigned
2013-11-26 06:18Peter KuemmelFile Added: subdir.zip
2013-11-26 06:18Peter KuemmelStatusassigned => confirmed
2013-11-26 06:18Peter KuemmelNote Deleted: 0034539
2014-02-10 09:18Jan RüeggNote Added: 0035061
2014-04-13 05:42Peter KuemmelAssigned ToPeter Kuemmel =>
2014-07-30 06:36Jan RüeggNote Added: 0036497
2016-06-10 14:29Kitware RobotNote Added: 0042415
2016-06-10 14:29Kitware RobotStatusconfirmed => 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
(0035061)
Jan Rüegg   
2014-02-10 09:18   
Still not working for cmake 2.8.12.2
(0036497)
Jan Rüegg   
2014-07-30 06:36   
Still not working for cmake 3.0.0 :(
(0042415)
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.