MantisBT - CMake
View Issue Details
0011940CMakeCMakepublic2011-03-08 11:452016-06-10 14:31
Nicolas Despres 
Kitware Robot 
normalminoralways
closedmoved 
i686Ubuntu10.10
CMake 2.8.4 
 
0011940: Wrong paths in generated Makefile when builddir is a symlink to an out-of-source directory.
When you have a directory layout like this:
/tmp/sourcedir
/tmp/sourcedir/_build -> /tmp/build
/tmp/build

And you call cmake /tmp/sourcedir from /tmp/sourcedir/_build the paths in the generated Makefile are wrong. See the steps to reproduce for more details.

I will try to add a test and a patch that fix it as soon as I have time.
$ cd /tmp
$ mkdir helloworld
$ cd helloworld
$ cat > CMakeLists.txt <<EOF
cmake_minimum_required(VERSION 2.8)
project(helloworld)

add_executable(helloworld
  src/main.cc
  )
EOF
$ mkdir src
$ cat > src/main.cc <<EOF
#include <iostream>

int main(void)
{
  std::cout << "Hello world\n" << std::endl;
  return 0;
}
EOF
$ mkdir /tmp/build
$ ln -s /tmp/build _build
$ cd _build
$ cmake ..
CMake Error: The source directory "/tmp" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
$ cmake /tmp/helloworld
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- 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
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/helloworld/_build
$ make
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/helloworld/_build
Scanning dependencies of target helloworld
make[2]: *** No rule to make target `../src/main.cc', needed by `CMakeFiles/helloworld.dir/src/main.cc.o'. Stop.
make[1]: *** [CMakeFiles/helloworld.dir/all] Error 2
make: *** [all] Error 2


I have attached the CMakeCache.txt
However doing the following works:
$ rm -rf /tmp/helloworld/_build /tmp/build
$ mkdir /tmp/build
$ cd /tmp/build
$ cmake /tmp/helloworld
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- 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
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/build
$ make
Scanning dependencies of target helloworld
[100%] Building CXX object CMakeFiles/helloworld.dir/src/main.cc.o
Linking CXX executable helloworld
[100%] Built target helloworld
No tags attached.
txt CMakeCache.txt (10,456) 2011-03-08 11:45
https://public.kitware.com/Bug/file/3742/CMakeCache.txt
Issue History
2011-03-08 11:45Nicolas DespresNew Issue
2011-03-08 11:45Nicolas DespresFile Added: CMakeCache.txt
2012-08-11 11:09David ColeStatusnew => backlog
2012-08-11 11:09David ColeNote Added: 0030239
2016-06-10 14:28Kitware RobotNote Added: 0041814
2016-06-10 14:28Kitware RobotStatusbacklog => resolved
2016-06-10 14:28Kitware RobotResolutionopen => moved
2016-06-10 14:28Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0030239)
David Cole   
2012-08-11 11:09   
Sending old, never assigned issues to the backlog.

(The age of the bug, plus the fact that it's never been assigned to anyone means that nobody is actively working on it...)

If an issue you care about is sent to the backlog when you feel it should have been addressed in a different manner, please bring it up on the CMake mailing list for discussion. Sign up for the mailing list here, if you're not already on it: http://www.cmake.org/mailman/listinfo/cmake [^]

It's easy to re-activate a bug here if you can find a CMake developer who has the bandwidth to take it on, and ferry a fix through to our 'next' branch for dashboard testing.
(0041814)
Kitware Robot   
2016-06-10 14:28   
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.