[CMake] Behaviour of CACHE PATH variables
Brad King
brad.king at kitware.com
Wed Mar 25 11:29:28 EDT 2015
On 03/25/2015 10:15 AM, Roger Leigh wrote:
> Question: Why is TESTDIR2 transformed from "t2" to
> "/home/rleigh/pathtest/test/t2" (which is
> "$PROJECT_BINARY_DIR/$TESTDIR2)?
It looks like the behavior has been this way since 2003:
ENH: When fixing cache value with uninitialized type, collapse
full paths for PATH and FILEPATH. Closes Bug #82 - Specifying
relative path when entering path can break things
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a6567329
but was added without documentation back in our wild west days.
> Copying the GNUInstallDirs behaviour of wrapping in an "if (NOT DEFINED foo)" test
> mitigates the problem.
>
> For my usage, I'm defining project-specific install dirs derived from the
> toplevel GNUInstallDirs dirs. I'd quite like to be able to specify a relative
> (or absolute) path, and then later prepend the install prefix / appropriate
> GNUInstallDirs toplevel variable. Having the current working directory added
> by default screws this up quite badly!
>From the commit message above I think the intended behavior is
exactly to transform relative paths. The behavior has been this
way for so long I don't think we can change it now. We can update
the documentation to describe the behavior, but I think using the
approach in GNUInstallDirs is the solution for you.
-Brad
More information about the CMake
mailing list