MantisBT - CMake
View Issue Details
0010769CMakeCMakepublic2010-05-27 17:462016-06-10 14:31
Ken Moreland 
Kitware Robot 
normalminorhave not tried
closedmoved 
CMake-2-8 
 
0010769: CMAKE_SOURCE_DIR wrong in cache init scripts
When you use the -C command to load a cache init script, CMAKE_SOURCE_DIR is incorrectly set to the binary directory while that file is executed. As a demonstration consider the following shell output. Note the value for CMAKE_SOURCE_DIR is the binary directory in CacheInit.cmake.

$ ls source
CMakeLists.txt CacheInit.cmake
$ cat source/CMakeLists.txt
PROJECT(TMP NONE)
MESSAGE("CMakeLists.txt CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
MESSAGE("CMakeLists.txt CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
$ cat source/CacheInit.cmake
MESSAGE("CacheInit.cmake CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
MESSAGE("CacheInit.cmake CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
$ cd binary/
$ cmake --version
cmake version 2.8.1
$ cmake -C ../source/CacheInit.cmake ../source
loading initial cache file ../source/CacheInit.cmake
CacheInit.cmake CMAKE_SOURCE_DIR: /Users/kmorel/tmp/binary
CacheInit.cmake CMAKE_BINARY_DIR: /Users/kmorel/tmp/binary
CMakeLists.txt CMAKE_SOURCE_DIR: /Users/kmorel/tmp/source
CMakeLists.txt CMAKE_BINARY_DIR: /Users/kmorel/tmp/binary
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/kmorel/tmp/binary
$

No tags attached.
Issue History
2010-05-27 17:46Ken MorelandNew Issue
2010-12-14 18:41David ColeAssigned To => David Cole
2010-12-14 18:41David ColeStatusnew => assigned
2011-02-09 14:26David ColeStatusassigned => backlog
2011-02-09 15:08David ColeAssigned ToDavid Cole =>
2014-04-14 04:29Paul MNote Added: 0035687
2016-06-10 14:28Kitware RobotNote Added: 0041705
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
(0035687)
Paul M   
2014-04-14 04:29   
This is affecting me. CMake 2.8.7 on Ubuntu LTS 12.04
Has a fix been released?

What is the status of this?
It has been quite some time now...
(0041705)
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.