[CMake] Behaviour of CACHE PATH variables
Roger Leigh
rleigh at codelibre.net
Wed Mar 25 12:23:08 EDT 2015
On Wed, Mar 25, 2015 at 11:29:28AM -0400, Brad King wrote:
> 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.
OK. It's a shame this can't be fixed, but entirely understandable.
A comment explaining the behaviour would be appreciated; it will certainly
save the next person encountering this special case from a good bit of
headscratching!
Thanks,
Roger
--
.''`. Roger Leigh
: :' : Debian GNU/Linux http://people.debian.org/~rleigh/
`. `' schroot and sbuild http://alioth.debian.org/projects/buildd-tools
`- GPG Public Key F33D 281D 470A B443 6756 147C 07B3 C8BC 4083 E800
More information about the CMake
mailing list