MantisBT - CMake
View Issue Details
0015193CMakeCMakepublic2014-10-03 09:012016-06-10 14:31
Yichao Yu 
Kitware Robot 
normalminoralways
closedmoved 
x86_64LinuxArch Linux
CMake 3.0.2 
 
0015193: Error when one of the parent directory is a symlink to it's parent directory
If one of the parent directory of the source directory is a symlink to one of its parent directory, cmake fails at configure time on add_subdirectory.

Directory structure to reproduce this:
```
% tree
.
├── 1
│   ├── 2
│   │   └── cmake
│   │   ├── a
│   │   │   └── CMakeLists.txt
│   │   └── CMakeLists.txt
│   └── 4 -> .
└── 3 -> 1

6 directories, 2 files
```

The higher level `CMakeLists.txt` is
```
% cat 1/2/cmake/CMakeLists.txt
project(cmake-test)
cmake_minimum_required(VERSION 2.8)
add_subdirectory(a)
```

and the lower level `CMakeLists.txt` is empty.

When trying to build in `1/4/2/cmake/build`
```
% cmake ..
-- The C compiler identification is GNU 4.9.1
-- The CXX compiler identification is GNU 4.9.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Error at CMakeLists.txt:3 (add_subdirectory):
  add_subdirectory not given a binary directory but the given source
  directory "/home/yuyichao/tmp/cmake-test/1/4/4/4/2/cmake/a" is not a
  subdirectory of "/home/yuyichao/tmp/cmake-test/1/4/4/2/cmake". When
  specifying an out-of-tree source a binary directory must be explicitly
  specified.


-- Configuring incomplete, errors occurred!
See also "/home/yuyichao/tmp/cmake-test/1/4/2/cmake/build/CMakeFiles/CMakeOutput.log".
```

Another real life example can be found in the comment here[1] and the qtcurve issue here[2].

[1] http://kde-look.org/content/show.php?content=40492 [^]
[2] https://github.com/QtCurve/qtcurve/issues/77 [^]
No tags attached.
Issue History
2014-10-03 09:01Yichao YuNew Issue
2016-05-07 05:34Michal WirthNote Added: 0041035
2016-06-10 14:29Kitware RobotNote Added: 0042642
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
(0041035)
Michal Wirth   
2016-05-07 05:34   
Hi, just confirming same behavior with CMake 3.5.2
(0042642)
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.