[cmake-developers] [CMake 0011940]: Wrong paths in generated Makefile when builddir is a symlink to an out-of-source directory.

Mantis Bug Tracker mantis at public.kitware.com
Tue Mar 8 11:45:49 EST 2011


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=11940 
====================================================================== 
Reported By:                Nicolas Despres
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   11940
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2011-03-08 10:45 CST
Last Modified:              2011-03-08 10:45 CST
====================================================================== 
Summary:                    Wrong paths in generated Makefile when builddir is a
symlink to an out-of-source directory.
Description: 
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.


Steps to Reproduce: 
$ 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


Additional Information: 
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

====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2011-03-08 10:45 Nicolas DespresNew Issue                                    
2011-03-08 10:45 Nicolas DespresFile Added: CMakeCache.txt                    
======================================================================




More information about the cmake-developers mailing list